Really big nasty chunks! I guess I’ve been spoilt by working with rails, and to be fair it’s not really ASP.Net I don’t like, it’s ADO.Net. I mean really, who wants to write 12 lines of code to fill a grid with data from a database!
1. construct a new SqlConnection object
2. construct a new SqlCommand object
3. construct a new SqlParameter object
4. set the parameter name
5. set the parameter value
6. add the parameter to the select command
7. construct a new DataSource object
8. construct a new SqlDataAdapter object
9. fill the DataSource using the SqlDataAdapter
10. connect the DataSource property of the grid to the DataSource object constructed earlier
11. call the DataBind method of the grid to actually load the data
12. close the database connection
I guess it’s all supposed to be used via the GUI editing tools which should build a lot of that stuff for me automatically. I assume the GUI built data binding can handle parameters for the select.
Another feature of Rails that I’m missing in ASP.Net is partials. I’m using master pages to give me some of the things that I would have used a layout for in Rails, but there doesn’t seem to be anything quite like partials in ASP.Net 🙁 Fortunately for me it’s a simple application I have to build so there are only a couple of repeated sections of code.
Also, what’s up with not allowing the TextBox control to be bound to a DataSource? I’ve got better things to do with my time than to write a line of code for each TextBox on my form to fill it with data and another to then put that data back into a DataTable so I can have it saved to a database.
A word of advice to all ASP.Net developers who read this, don’t use Ruby on Rails. It will only make you realize how bad you’ve got it 😉
Songbird and multi-media keys under Linux
I’ve decided that under Linux I want to use Songbird as my music player. Unfortunately at the moment the latest developer release doesn’t support the multi-media keys on my keyboard 🙁 Not to be beaten I decided to do something about it and I’ve built my first XPCOM component along with some javascript glue to make it all work. Here is the Songbird extension, and here is the source. I won’t pretend it’s a great piece of work, but it does what I need it to do. The Play, Stop, Next and Previous buttons on my keyboard now work, but YMMV 😉
Enjoy
Working from Linux
I’ve been using Linux as my primary development environment in my day job for a couple of months now and for the most part I’m enjoying the change. It’s amazing that the same hardware running Linux seems to run so much faster than when running XP. Maybe I it’s just time for the semi-anual windows reinstall 😉
I thought I’d go the whole hog and try using Emacs as well. I tooled up with all the various Emacs bits and pirces I needed to make doing rails development under Emacs nice and off I went. It only took a couple of days to get used to the cursor movement and cut/copy/paste commands, but in the end I decided to go back to eclipse :(, and then spent the next day or so wondering why Ctrl-K and Alt-W didn’t do what I wanted 😉 I have to say I enjoyed the couple of weeks I spent with Emacs, but I’m still not ready to give up my modern UI addiction 😉
Maybe one day I’ll give XEmacs a go…
Another reason to hate windows
Well, yesterday the task bar and start menu on my Windows dev box decided to crash. I’ve got my explorer set up to open new explorer windows in their own process, so I didn’t loose my opened windows and so loose my place in svn (as well as cvs and darcs). Ordinarily when this happens I just restart explorer and up comes my start menu. Not this time however. I put up with no start bar for the rest of the day as I was busy doing things and didn’t want to mess up my flow. It was an interesting experience. Everything seems to work quite happily without the task bar, however maximizing my windows didn’t use the area at the bottom of the screen reserved for the start menu. I started to find the empty space at the bottom of the screen quite distracting.
This morning after taking my daughter for a swim at the local pool I decided that I’d had enough. I did a bit of research on the net to see if there were some magical command line arguments needed to pass to get my task bar back. I suppose I could have just rebooted the machine, but I was trying to avoid that as much as possible. Finally I thought to myself, “Everything is checked in to their various repositories, so I might as well close down all my explorer windows and see what happens when I start explorer.exe”. I did this and hey presto up came my task bar 🙂 It looks like if explorer starts and it doesn’t see any instances of itself running then it becomes the start bar and desk top.
The more I use windows the more I miss my mac. I really need to get an intel mac so I can run ‘doze in a vm for those rare occasions I need to do something in Visual Studio .Net or some other windows only program.
TextMate and Flex 2
I’ve been having a bit of a play with Adobe’s Flex 2 command line compiler. After doing a quick search around the net I found a couple of hints for using it with TextMate. Unfortunately none of them did quite what I wanted, so I built my own. Hopefully it will be useful for others 🙂
TextMate bundle for Flex 2 coding
It adds a new language type for mxml files, a few snippets with mx as the tab trigger and a build command bound to Command-B. By default it looks for your Flex install in the following places
- ~/Flex
- ~/flex_sdk_2
- /Developer/SDKs/Flex
- /Developer/SDKs/flex_sdk_2
- /Developer/Applications/Flex
- /Developer/Applications/flex_sdk_2
- /Applications/Flex
- /Applications/flex_sdk_2
Any errors or warnings are displayed in the output window and a click will take you to where the problem is.
Once your Flex app is building successfully it will be opened in Safari, or if you have a script called deploy in the same folder as your mxml file it will be executed instead.
Enjoy 🙂
before_create considered harmful
I had a fsck of a time today working with rails. Normally I love Ruby on Rails, but today it gave me the screaming shifts!
I had a model class to which I wanted to add some sensible default values to satisfy some constraints in the database.
The logical place for that was before_create, so I did something like the following
class MyModel < ActiveRecord::Base
def before_create
self.foo ||= true
self.bar ||= Time.now
self.baz ||= falseend
end
Now, I would have thought that would work, but whenever I tried to save an instance of my class to the database the save method would return false 🙁
Hmmmm. Ok, let’s add some logging code and see what the problem is… Are there any errors? Nope. Does the instance think it’s valid? Yes. OK, that’s weird. Maybe there is something going on and the exception is getting eaten by some other code in the application (there are three of us working on this code and we’re not all in the same state, so who knows what one of the others may have done 😉 ). I try creating an instance using the rails console. Same thing (which is to be expected, but I was starting to get a little desperate by this stage).
What was the next thing to do? Go through the code and remove things line by line until I start getting some exceptions. Finally in desperation I took out my before_create method, and lo and behold my error messages come back. It was then that I was struck by the thought that Ruby methods take their return value from the last expression evaluated in their body, so the before_create method was returning false. It seems that there is a nice undocumented “feature” in ActiveRecord that allows application code to stop an object being saved to the database by returning false from before_create, and I imagine before_save.
A little note to that affect in the documentation would have saved me quite a bit of time today.
Ah well. Live and learn I guess 🙂
emoooo.com is live
I’ve just put the finishing touches on a silly little project I’ve been working on this week called emoooo.com
Check it out 🙂
flvThing is released
I’ve released flvThing on the www.automagic-software.com web site. It seems to play every flv file I’ve thrown at it quite nicely 🙂
The flv files are played using the installed flash player which is hosted inside a WebView control. The application creates a tiny very stupid web server that serves up the flash files as well as the flv file for the flash player to load. It seems to work pretty well 🙂
OmniGraffle is SO cool!
I’ve been building a simple little app to play FLV files on the Mac and I should be releasing it some time over this weekend. I needed to make some icons and I threw them together in OmniGraffle Pro. Go check out www.omnigroup.com for more details.Â
Â
I’ve used it a few times for this sort of thing. Here’s an example of what somebody who has no graphic design skills can accomplish very quickly ;)Â
Â
 Â
Â
I’m pretty happy with it 🙂 It looks pretty good shrunk down to 128×128 and the alpha channel comes out when I export is as a PNG :)Â
Â
Blog spam and other stuff
I finally got around to cleaning up the spam on this blog.
Unfortunately it looks like I zapped a couple of legitimate comments in the process however 😉
I’ve been really busy of late working and looking after the monster baby (who just recently turned 1 year old).
On the train to and from work I’ve been building a simple little database tool for myself. I’ll probably be releasing an alpha some time soon (although when soon is I could not say exactly 😉 )
It’s a Objective-C cocoa app that connects to pretty much any database that has a JDBC driver.
It features syntax hilighting, simple code completion for SQL syntax (and I’m working on making it do code completion for database objects) and the big feature for me is tabbed based query results along with tabbed documents. It’s already pretty usable, although I still jump back to CocoaMysql on occasion for some things. If you’re feeling brave and want to give it a try feel free to email me at daniel@automagic-software.com