Tuesday, December 20, 2005
The Daily WTF
A co-worker just sent me this URL. I had a good chuckle looking at some of the code posted on this website so I figured I'd post it here for posterity. There's an RSS feed too so you can keep up to date with the latest WTFs.
Sunday, December 18, 2005
RadRails
I decided I would try downloading the latest milestone version of Eclipse 3.2M4 and set up an IDE without all the Java development tools and just the RDT (Ruby Development Tools) that would start up faster and let me do some Rails development with less clutter. Then somehow I stumbled upon the RadRails Eclipse plugin (gotta love surfing the web). So far it seems really quite good. I can run the WEBrick server, view my PostgreSQL database, hit the web application all within Eclipse! And it also gives me a colour coded RHTML editor and better code completion than RDT. I even just subscribed to their Podcast. I haven't used it extensively yet but so far I'm quite impressed.
Thursday, December 15, 2005
Rails 1.0
Well I obviously haven't been using my Mac for a couple days (where all my Ruby RSS feeds live) because I missed the 1.0 release of Ruby on Rails. I just went to the new flashy Ruby on Rails page and checked out one of their videos about creating a flickr front end. Holy moly! It may be an old video for all I know, but that is one very cool demo. Mmmm, AJAX and Ruby on Rails good!
Tuesday, December 13, 2005
Revolution
I was just listening to the Beatles' Revolution... Very appropriate lyrics for software development don't you think?
You say you want a revolution
Well, you know
We all want to change the world
You tell me that it's evolution
Well, you know
We all want to change the world
But when you talk about destruction
Don't you know that you can count me out
Don't you know it's gonna be all right (3x)
You say you got a real solution
Well, you know
We'd all love to see the plan
You ask me for a contribution
Well, you know
We're doing what we can
[...]
Monday, December 12, 2005
Buying Mac Software
With the popularity of the iPod, the fortunes for the Mac have been looking brighter too and with that, more retailers are carrying Macs. In Calgary, BestBuy and London Drugs are recognizable chains that carry the Mac. So with that in mind, I went shopping for a game for my son for Christmas. Well it wasn't a terribly pleasant experience. While the shelves are loaded with software for Windows PCs, Mac software is far more difficult to come by. BestBuy was the worst. They had NOTHING. London Drugs faired a little better but only had a few titles like "Mac OS X Tiger". I went to these stores first because their locations are more convenient to my place of work.
But in the end I went to WestWorld Computers on Centre Street in Calgary and was greeted with a recently rennovated showroom. There was lots of hardware and software on display and some knowledgable salesmen walking around. I immediately found what I was looking for and made my purchase. My lesson? Forget the big box stores and go for the focussed reseller.
PS: iPods are very hot Christmas items. People were buying them at all three locations.
But in the end I went to WestWorld Computers on Centre Street in Calgary and was greeted with a recently rennovated showroom. There was lots of hardware and software on display and some knowledgable salesmen walking around. I immediately found what I was looking for and made my purchase. My lesson? Forget the big box stores and go for the focussed reseller.
PS: iPods are very hot Christmas items. People were buying them at all three locations.
Thursday, December 08, 2005
RoR & Foos together at last
Even as my spare time dwindles with the responsibilities of hosting the family Christmas celebrations at our house this year, I still try to find the time to continue my Ruby on Rails education. In 2005 I looked at a lot of technologies but RoR is one of the first to actually have me interested enough to do more than just read a book. Let me explain...
At work we have a foosball ladder which consists of a white board and a dry erase pen. While refreshingly low tech I thought "here's a problem just waiting to be automated with software!". Okay it doesn't really need software but it's a complex enough problem for me to get my feet wet with Rails. I unabashedly looked at the ladder options already on the web and (ahem) borrowed some of their ideas. I need to store information about players, teams, the ladders themselves, matches and the games in those matches and then I can go onto bells and whistles like enabling online challenge negotiations, the ability to mark a players status, and showing player/team stats.
So already I have several tables in a PostgreSQL database with a variety of relationships between them and I'm slowly figuring out what I can do with RoR's ORM tool ActiveRecord. So far I've been pretty happy with the support for optimistic locking, one-to-one (belongs_to & has_one), one-to-many (has_many), and many-to-many (has_and_belongs_to_many) relationships, dynamic finders, and transaction support.
I especially like being able to just play around in Ruby. I can mess with the tables, add and remove columns, change names, etc and then quickly see my changes take shape in my Ruby object model by running a simple Ruby script to create some objects and save them to the database. And no requirement to compile, or generate ORM XML mapping files has me feeling quite empowered.
At work we have a foosball ladder which consists of a white board and a dry erase pen. While refreshingly low tech I thought "here's a problem just waiting to be automated with software!". Okay it doesn't really need software but it's a complex enough problem for me to get my feet wet with Rails. I unabashedly looked at the ladder options already on the web and (ahem) borrowed some of their ideas. I need to store information about players, teams, the ladders themselves, matches and the games in those matches and then I can go onto bells and whistles like enabling online challenge negotiations, the ability to mark a players status, and showing player/team stats.
So already I have several tables in a PostgreSQL database with a variety of relationships between them and I'm slowly figuring out what I can do with RoR's ORM tool ActiveRecord. So far I've been pretty happy with the support for optimistic locking, one-to-one (belongs_to & has_one), one-to-many (has_many), and many-to-many (has_and_belongs_to_many) relationships, dynamic finders, and transaction support.
I especially like being able to just play around in Ruby. I can mess with the tables, add and remove columns, change names, etc and then quickly see my changes take shape in my Ruby object model by running a simple Ruby script to create some objects and save them to the database. And no requirement to compile, or generate ORM XML mapping files has me feeling quite empowered.
Wednesday, December 07, 2005
Testing
I came in to work this morning only to listen to a QA lead and a senior developer discuss the almighty importance of tests (specifically unit tests). "They are the specifications, blah, blah, blah". But you know what I didn't hear, the importance of the actual software itself! Agile-development, test-first, test-driven, whatever-process-comes-next are all well and good but don't get so damn attached to it that you don't focus on what's really important, the software. Don't get me wrong, tests are important but they come a distant second to the system under development.
Thursday, December 01, 2005
Work's a drag
A few Pragmatic Programmer tips are:
During some informal polling among other developers I get a pretty divere set of opinions. Some agree with me (but not on the same remedies), others are apathetic, and others feel that everything is just fine. So naturally I don't feel that comfortable pulling the handbrake. I just hope there isn't a sudden stop and a loud bang associated with this ride.
I guess there's a reason they call it "work".
- Provide Options, Don't Make Lame Excuses
Instead of excuses, provide options. Don't say it can't be done; explain what can be done. - Don't Live with Broken Windows
Fix bad designs, wrong decisions, and poor code when you see them. - Be a Catalyst for Change
You can't force change on people. Instead, show them how the future might be and help them participate in creating it. - Remember the Big Picture
Don't get so engrossed in the details that you forget to check what's happening around you.
During some informal polling among other developers I get a pretty divere set of opinions. Some agree with me (but not on the same remedies), others are apathetic, and others feel that everything is just fine. So naturally I don't feel that comfortable pulling the handbrake. I just hope there isn't a sudden stop and a loud bang associated with this ride.
I guess there's a reason they call it "work".
Remarkable developers use remarkable technologies to do remarkable things.- Chad Fowler
[...]
If you don't have passion for software development you will not become a remarkable software developer, period.
Tornado Foosball

We got a new foosball table at work about a week ago, a Tornado Whirlwind. Now I can fully indulge my addiction to this fun but difficult-to-explain-to-your-wife game. The Tornado tables are very solidly built and are designed for a controlled game. So while we still have some slaptastic players whose style of play is better suited to the "speed-ball" rules, most are coming around to trying to intentionally score a goal rather than just smacking it as hard as you can and hoping something good happens.
Digital Cameras
iPhoto on the Mac was first released in January, 2002 and nearly four years later I've finally joined the party by buying the Canon PowerShot SD450 digital camera. I learned that size is a pretty big consideration when buying digital devices and generally the smaller the better. The less of a hindrance it is to take with you, the more likely you are to use it. That's certainly been my experience with my iPod shuffle. I sometimes wish I had the features and storage of the larger model but the size is perfect. The feature I like best about my new camera is its ability to rotate the image according to orientation of the camera when I'm playing back existing shots. Very cool!
Monday, November 21, 2005
Genealogy
What started out as an innocent school project for my daughter has turned into a full time project for me! What was a simple family tree has now turned into a genealogical expedition of epic proportions... well okay maybe not... But I have discovered some interesting facts:
Finally my software of choice has been a little Java application called GenealogyJ or GenJ for short. Having never touched a commercial tool that does this stuff I'm pretty impressed with GenJ. There's a nice little graphical viewer and lots of reports. The best part is that it stores all it's data in a UTF-8 encoded text file (in the standard Gedcom format) that's easily read in any text editor. That's pretty important to me so that my information will always be accessible even if GenJ should go the way of the Dodo.
For those of you who've been into this stuff for years and have some pointers, send me an e-mail or post a comment...
- my grandmother on my father's side came from Scotland
- my great Grandfather on my father's side was a candy maker in Germany
- my great grandparents on my mother's side came from England
Finally my software of choice has been a little Java application called GenealogyJ or GenJ for short. Having never touched a commercial tool that does this stuff I'm pretty impressed with GenJ. There's a nice little graphical viewer and lots of reports. The best part is that it stores all it's data in a UTF-8 encoded text file (in the standard Gedcom format) that's easily read in any text editor. That's pretty important to me so that my information will always be accessible even if GenJ should go the way of the Dodo.
For those of you who've been into this stuff for years and have some pointers, send me an e-mail or post a comment...
Wednesday, November 02, 2005
Chasing simplicity in programming
A new article on c|net discusses the new phenom "Ruby on Rails". Quotes from the article:
Like Java did a decade ago, Ruby on Rails is getting developers excited by making them more productive
The vision of Ruby on Rails, or RoR, is to combine the speed and ease-of-use of scripting language PHP with the "clean," structured approach of Java
Java Enterprise Edition software is a "complex monstrosity" that's hard to learn
Research company Burton Group recommends that corporate customers consider Ruby on Rails for new Web development projects
We took a pretty radical stand: Stored procedures and all things that make your database clever are evil
Thursday, October 27, 2005
Hibernate & Ruby

In my previous project I was using the latest and greatest version of Hibernate and was happily employing the Hibernate Eclipse plugin for writing my HQL queries before embedding them in my application. But my current project uses an older version of Hibernate (2.1.x) so the Eclipse plugin is out of the question. Fortunately I can remember back to when I used the forerunner of the Eclipse plugin, a little program that was called Hibern8IDE. It later became part of the Hibernate extension tools and was then thankfully renamed "Hibernate Console". Fortunately it's still available for download from hibernate.org.
Now the only problem is that this project also uses Spring which informs Hibernate about the XDoclet-generated mapping files at runtime in a decidedly non-hibernate fashion. What I needed was to create a good old fashioned hibernate.cfg.xml which contains references to each *.hbm.xml file. But I wanted to script the generation of this file so that I wouldn't have to manually maintain the file as the collection of *.hbm.xml changes over time. So I turned to my new friend Ruby. The top and bottom part of this script use "here docs" to generate the boiler plate static XML. But then right in the middle I got this:
`find . -name '*.hbm.xml' -print`.each { |f|
f.gsub!(/.*(com\/company.*?)\n/, '\1')
puts "<mapping resource=\"#{f}\"/>"
}
The first line executes the Unix find command, and then begins an iterator over each line of that command's results. Then within the block I use a simple regex within the String's substitution method to get the Java package and file name. Then finally I print out an XML element whose resource attribute contains the name of the *.hbm.xml file. That's a lot of stuff in only four lines of code! Ruby is very expressive. Now I must emphasize the value of a good editor to color code something like that so a person can make sense of it. I definitely recommend the RDT plugin for Eclipse.
Thursday, October 20, 2005
Right & Wrong
Back in August I commented on Microsoft's aggressive moves against Adobe. I also mentioned that Apple could also make a move with it's new Core Image technology built into OS X. But at the time I didn't think it was all that likely. Well I was right that they could but I was wrong because they did.
Apparently Apple wants a piece of that image processing market. They just introduced Aperture. And although they're going to some pains to say it's complementary to Photoshop, I think it's definitely a competitor.
Apple really is becoming quite a software powerhouse... Fortunately for most software companies, they can feel secure that the only software they produce that isn't Macintosh-only is iTunes and Quicktime. But then again once somebody (like me for example) gets a taste of Mac, all that Microsoft stuff just feels like rubbish. With all the Apple stores around the U.S. with their little built in theaters, the brand new Quad PowerMacs will show this stuff off very well.
Apparently Apple wants a piece of that image processing market. They just introduced Aperture. And although they're going to some pains to say it's complementary to Photoshop, I think it's definitely a competitor.
Apple really is becoming quite a software powerhouse... Fortunately for most software companies, they can feel secure that the only software they produce that isn't Macintosh-only is iTunes and Quicktime. But then again once somebody (like me for example) gets a taste of Mac, all that Microsoft stuff just feels like rubbish. With all the Apple stores around the U.S. with their little built in theaters, the brand new Quad PowerMacs will show this stuff off very well.
Tuesday, October 18, 2005
HD Movie Trailers
Check out the new Movie Trailers page at Apple. A fair number of them are in HD. Normally I have to scale a video several times to fit my entire screen. These trailers fill my screen without any scaling at all.
Saturday, October 15, 2005
Ruby, Ruby, Ruby, Ruby
Remember when Steve Ballmer went all schizo and jumped around like a big Gorilla shouting "developers, developers, developers, developers"? Well I think I'm starting to get infected by a similar disease. I'm not a complete raving lunatic just yet but I'm really starting to dig Ruby. ;-)
After madly writing endless lines of Java code for the past three weeks that does next to nothing (see my previous rant) I'm elated to see that there are others in the world who believe less code is better.
To demonstrate, here are the steps you can take to create a dynamically generated page with Ruby on Rails.
1. > rails ./demo
2. > cd demo
3. > mv public/index.html public/index.html.old
4. > script/generate controller people list
5. modify config/routes.rb and add the line map.connect '', :controller => 'people', :action => 'list'
6. modify app/controllers/people_controller.rb (see listing below)
7. modify app/views/people/list.rhtml (see listing below)
8. > script/server
9. browse to localhost:3000
10. voila!
A couple of important points to notice is that Rails embraces the MVC design pattern. Model and Controller classes are separate while the View is off in its own place. The view is an .rhtml file because it's basically HTML with Ruby embedded within it. While those who've been doing JSP development may scoff at the mere idea of embedding "code" within a page and believe that custom tags is the only way to go, I have to admit that after doing JSF for a few weeks I actually like this a whole lot better. Remembering that Ruby is a 'scripting' language and that Rails uses Controller classes (like "code-behind") may help people get over their prejudice. Finally here a few links I've found very valuable during the last week:
What Is Ruby on Rails
Rolling With Ruby on Rails
Rolling with Ruby on Rails, Part 2
Ruby On Rails Documentation
why's poignant guide to Ruby
Rails Academy (videos)
app/controllers/people_controller.rb
app/views/people/list.rhtml
After madly writing endless lines of Java code for the past three weeks that does next to nothing (see my previous rant) I'm elated to see that there are others in the world who believe less code is better.
To demonstrate, here are the steps you can take to create a dynamically generated page with Ruby on Rails.
1. > rails ./demo
2. > cd demo
3. > mv public/index.html public/index.html.old
4. > script/generate controller people list
5. modify config/routes.rb and add the line map.connect '', :controller => 'people', :action => 'list'
6. modify app/controllers/people_controller.rb (see listing below)
7. modify app/views/people/list.rhtml (see listing below)
8. > script/server
9. browse to localhost:3000
10. voila!
A couple of important points to notice is that Rails embraces the MVC design pattern. Model and Controller classes are separate while the View is off in its own place. The view is an .rhtml file because it's basically HTML with Ruby embedded within it. While those who've been doing JSP development may scoff at the mere idea of embedding "code" within a page and believe that custom tags is the only way to go, I have to admit that after doing JSF for a few weeks I actually like this a whole lot better. Remembering that Ruby is a 'scripting' language and that Rails uses Controller classes (like "code-behind") may help people get over their prejudice. Finally here a few links I've found very valuable during the last week:
What Is Ruby on Rails
Rolling With Ruby on Rails
Rolling with Ruby on Rails, Part 2
Ruby On Rails Documentation
why's poignant guide to Ruby
Rails Academy (videos)
app/controllers/people_controller.rb
class PeopleController < ApplicationController
def list
@names=['Yukihiro Matsumoto', 'David Heinemeier Hansson']
end
end
app/views/people/list.rhtml
<html>
<head>
<title>This is my first Ruby page</title>
<link rel="stylesheet" type="text/css"
href="stylesheets/mystyle.css" />
</head>
<body>
<h1>Ruby/Rails People List</h1>
<table>
<% @names.each do |name| %>
<tr><td><%= name %></td></tr>
<% end %>
</table>
</body>
</html>
Saturday, October 08, 2005
Ruby On Rails

I discovered a new version of the Ruby Development Tools (RDT) plugin for Eclipse yesterday. I hadn't used it in quite awhile, so I downloaded this new version, installed it and was quite pleasantly surprised. I opened an old project I had laying around and rediscovered the simplicity of Ruby. I wrote a Test::Unit subclass and ran it in the RDT test runner. Very nice. Just like running JUnit tests in Eclipse.
So I decided this is cool, lets try this Ruby on Rails thing that I keep reading about. Mac OS X Tiger comes installed with Ruby 1.8.2, the Apache web server and SQLite, so I was more than half way there to getting setup. I followed this little tutorial to install RubyGems, a packaging system for Ruby libraries and tools. After that, installing rails (i.e., "sudo gem install rails") and creating a little sample application was a breeze. My only hiccup was fixing a permissions problem with my sample app (i.e., the public, db, and logs files needed to be readable and writable by apache).
Setting up a rails app involves generating a bunch of files so I can't claim to know what's really going on under the covers, but it's a very cool thing to be able to edit data through a web UI so quickly. Rails has impressed me so far. Now I just need to build something of my own and decide for myself if all these Ruby/Rails productivity claims hold water.
Tuesday, October 04, 2005
LINQ
A friend of mine just sent me a video link to a interview with Anders Hejlsberg talking about LINQ (Language INtegrated Query). Take Java's Hibernate ORM (object relational mapping), mix in contextual type inference and then throw in homogenous query syntax (that has a close resemblance to SQL) across relational databases, XML data and in-memory objects and you get an idea of what LINQ is all about. It sounds very ambitious (and it is) but Anders does a great demo. The comments section on the board makes it sound revolutionary but if you've been playing in the ORM space for any amount of time it seems like a very natural evolutionary step. But I didn't see the "type inference" stuff coming. That's brilliant. Makes the query stuff much more powerful.
Sunday, October 02, 2005
Seam
After yesterday's rant about layers upon layers of code and XML based dependency injection I found Norman Richard's blog about a new web framework called Seam from JBoss. Apparently Gavin King, the guy who brought us Hibernate, is involved in this as well. That's a very good sign. From what I've read it looks like this might be just what I'm looking for. It's brand new and will undoubtedly have rough spots and missing functionality, but it really does seem to be headed in the right direction.
Saturday, October 01, 2005
6 days later
I've been in my new job for six days now and thought I'd post my thoughts about what I've done so far. The short answer is "not much". It's actually pretty amazing to me how little is done to prepare for a new person. And I'm not even talking about this specific company, it's a general problem. Even the most glaringly obvious things like getting ids and passwords for databases, version control systems and even permissions on file servers are almost never set up when I go to a new job. Sometimes the environment is responsive to new requests, other times... not so much.
Secondly, when being inserted into a team of people already madly coding away, nobody has the time to give you the lay of the land. So I spent at least a couple days looking a existing code to figure out what I need to do to make my code fit in with everything else. It all seems highly inefficient and a waste of my time and their money. Maybe when you consider just one developer, it may not seem like much but multiply a week of time for every new developer who walks through the door then it's easy to see a pretty big opportunity to save. Do the math with let's say 20 developers and you soon start to think "I could probably build a lot of stuff in 20 weeks".
Anyway, I did manage to build a single web page this past week. But what really impressed me was the number of files I needed to create/edit to enable this one page. I created:
In my last job, where I made the decisions about architecture and technologies, I had:
Having worked with a variety of people over the years I know there are those who believe that elegance is expressed with simplicity. Look at E=mc² for example. And then there are those who love to wallow in complexity. I love simple, efficient, elegant designs. I'm not sure I've found that here... Not yet anyway. Maybe I'll come to love it over time (my fingers are crossed).
Finally, let me comment on a couple of my statements in earlier posts:
Secondly, when being inserted into a team of people already madly coding away, nobody has the time to give you the lay of the land. So I spent at least a couple days looking a existing code to figure out what I need to do to make my code fit in with everything else. It all seems highly inefficient and a waste of my time and their money. Maybe when you consider just one developer, it may not seem like much but multiply a week of time for every new developer who walks through the door then it's easy to see a pretty big opportunity to save. Do the math with let's say 20 developers and you soon start to think "I could probably build a lot of stuff in 20 weeks".
Anyway, I did manage to build a single web page this past week. But what really impressed me was the number of files I needed to create/edit to enable this one page. I created:
- a domain object with Hibernate XDoclet annotations
- a DAO interface
- a Hibernate DAO implementation
- a DAO unit test
- a Service/Facade interface
- a Service implementation
- a Service unit test
- a JSF backing bean and a JSP page.
- an application resources properties file (despite the fact localization is not a requirement)
- two Spring XML files
- a JSF config XML file and
- added some XML to the tiles definition file.
In my last job, where I made the decisions about architecture and technologies, I had:
- XDoclet annotated domain objects (which included named queries)
- NO DAOs (I felt that the Hibernate abstraction and named queries were a sufficient data access layer)
- Service Objects (typically singletons with explicitly coded session and transaction management)
- XDoclet annotated Struts Action/Form objects + JSPs
- the typical smattering of JUnit test classes.
Having worked with a variety of people over the years I know there are those who believe that elegance is expressed with simplicity. Look at E=mc² for example. And then there are those who love to wallow in complexity. I love simple, efficient, elegant designs. I'm not sure I've found that here... Not yet anyway. Maybe I'll come to love it over time (my fingers are crossed).
Finally, let me comment on a couple of my statements in earlier posts:
- There is a simpler way to integrate Spring and JSF so that you can inject Spring configured beans into JSF managed beans. Using Spring's org.springframework.web.jsf.DelegatingVariableResolver configured within your faces config makes it all transparent. Yay! It may not be as good as using only one dependency injection framework but it's a good runner up.
- Secondly, you can integrate tiles into JSF by configuring org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl in your faces config file.
- Finally, I read Spring's documentation a little more closely and it appears you can use HibernateTemplate's execute method to call whatever Hibernate code you want. So I can now feel free to use that lovely Hibernate API all I want! ;-)
Subscribe to:
Posts (Atom)