Sunday 24 January 2010

Relationships, testing and non project problems

Relationships

So far this week I've looked into issues with relationships between races and swimmers. In order to represent this correctly I've created a raceRecord which belongs to race and also to a swimmer. I struggled with how to do this but I found the answer in Grails In Action (page 87 in case you're curious). Simply:

static belongsTo = [Race, Swimmer]

When the controllers and views are generated all seems to be as it needs to be.

Testing

Ok so I want to believe in the whole Test Driven Development (TDD) ideal but Grails just seems to be so easy to whip stuff up and tests are just not sexy to write. However I've promised myself that I'm going to do things right. I spent some time writing a couple of basic tests for the constraints on the domain classes. It was here that I added a grails plug in (the code coverage plugin). This allows me to run test-app -coverage to see stats on the amount of test coverage I have which I find pretty motivating. Now time for a little rant...

I know that test coverage in and of itself is not a concrete guarantee of code perfection but its got to be better than not testing at all. Yes the quality of the tests is fundamentally important but its not enough to say that just because tests can be poorly written so why even bother having them. Surely this goes to your own integrity to make sure your code (and your tests) does what its supposed to do. If it sounds like I'm excited, let's just say that this has been a bone of contention in my day job recently. Anyway the swim project will not progress any further until all domain classes have tests for constraints to start with. I've updated to the new Grails Textmate bundle too so this should make my test writing quicker.

OS and other disasters

I'd previously partitioned my MacBook hard drive to allow me to install Windows 7. After a couple of days I ditched it for Ubuntu and had been happy with that but with no time for OS experimentation decided to reclaim the partition for OS X. However I couldn't simply re attach the rogue partition and had to wipe and reinstall everything. I do have an external hard drive but its partition as FAT32 and therefore cannot be used by OS X's Time Machine. Therefore I had to manually copy my files over and then copy them back. This was a significant time cost and I think with such cheap hard drives I think I'll get another for Time Machine to avoid this drama next time. The whole process was made easy with MacPorts though.

In better news, I've started following this great blog from a mate of mine about his quest to build a python driven robot. Its well worth the read.

Sunday 17 January 2010

SwimClub: Steps 1 and 2

The swim project is to create a web app to host the swim club results. My weapons of choice are:
Framework - Grails (1.2)
Versioning - Git
Server - Tomcat
IDE - Netbeans although to date I've only needed Textmate

My first goal was to create a skeleton and then find something to host the site so that my mate (client) can check it out and provide feedback as we go. I've got an idea of where I'm going with the app but its really going to be quite fluid as I receive feedback. As mentioned in an earlier post we're trying to flesh out functionality here and will worry about the look and feel later.

Basic Structure

In order to think the structure through I've decided to create a bunch of basic domain classes. So far I've got a Meet which has many Races. These in turn have many RaceRecords. A RaceRecord has a Swimmer and a time. Eventually I'll refactor the Swimmer class so that it inherits from a User class as there will be other types of users not just the actual swimmers. Using scaffolding I've got basic CRUD operations for each of these domain classes. So far so good..

Hosting

Although this is just under development I still need to be able to host the app so that I can receive feedback as we go. I've decided to just host it locally and use DYNDNS to manage the dynamic IP. I followed the excellent instructions here to install Tomcat. No real issues so far. My only concern is stress on my old PowerPC iMac as its used by the family in addition to the hosting. It has only 1.5 GB Ram and I've created a completely new user for the test server to keep it all separate. Previously I've used Glassfish but that seems a little like overkill at this point, maybe later when I need something that's production worthy.

With all this done things are progressing nicely. Now I'm just waiting on some answers to questions for some fundamentals before progressing. BTW using Google Wave for this as it project work seems to be the only thing its good for. If you're keen let me know and I'll add you to the wave.

Wednesday 13 January 2010

Rant: The 4 Programmers You Meet In Heaven

Recently I finished reading Mitch Albom's The Five People You Meet In Heaven, a wonderful thought provoking book. It got me thinking about the people that have influenced my own life and more specifically those that have influenced my programming career. Now rather than embarrass these people by naming names I decided to rant about the types of people you meet in your programming journey.

The Kung Fu Zealots


These people I first encountered at Uni but I've meet a few since. They're passionate about their craft to the point that their ideas and way is better than anyone else's. It reminds me of the old time kung fu movies where rival schools battle it out because their way is the only true way. Their programming skills are an essential part of their identity so a criticism of their language/framework/way is a slur on them.
The reason these people make it to programming heaven is that they are so enthusiastic about their language and so can learn heaps from them. If only they could open their minds to other ideas...

The Soldiers


I am lucky enough to work with a couple of these guys. They're the ones who don't make a fuss, don't see what the big deal is, they just get stuff done. Programming might just be their job and perhaps they really enjoy it but they've got more going on in their life. Unlikely to ever been seen in a meeting, they're just about getting the result.
The reason they'll make it to programming heaven is their no muss no fuss attitude. Its not about ego its just about results. Much can be learned from the soldiers.

The Rock Stars


Few people fit into this category but fortunately I've met one. Brimming with energy for the programming craft regardless of style, their enthusiasm is infectious. Sure they may have a specific speciality but they're open to new ideas and new thinking. They're keen to hear about what you're into, how you do stuff and don't judge, only encourage.
Pretty obvious why these people make it to programming nirvana.

The non programming programmers


Ok I know it sounds weird but these are the people that just inspire you to learn more. Practical, hands on, these people could be rock stars if they'd gone down the programming track. They could be from any industry but its not their occupation that's important but they're attitude to learning. They just can't get enough knowledge.
These people make it due to the fact that their eagerness to think something through and understand the how and why of anything also inspires.

So that's my take so far. I hate to violate the DRY principle but all of these types of people have been inspirational to me. No doubt others have had different experiences and I know people shouldn't be put in boxes. Hopefully you've got sources of inspiration in your life too.

Tuesday 5 January 2010

New year .. new project

So its the New Year, a time when I usually make a resolution to lose weight and then after a couple of weeks its back to business as usual. This year I thought I'd like to bypass the diet resolve and make myself more accountable by blogging more. There probably aren't that many readers to this blog but the act of documenting the week to week progress of a project helps to keep me motivated.

Now what will I be blogging about? Well I've got a bit of a personal policy that I won't blog about my work at all however I'll keep all posts technical or IT related. I'm going to detail the whole start to (hopefully) finish of my next project - a record keeping system for a swim club. In addition to this I'll throw in the occasional rant just to keep it interesting.

The Problem


My mate is a swimming coach and he needs to be able to record times from meets and competitions. Sure he could use a spreadsheet but ideally he wants to link the data to a site that swimmers can access and track their own progress. Cost is an issue too so the hosting solution needs to be cheap (Google App Engine did you say?) I've looked a this problem before and time became an issue. Following the squash ladder project I think I've learned some more tricks so hopefully my productivity will be much improved.

More to follow soon...