Wednesday, July 8, 2009

One of the times where the motivation to work on code is lower than I'd like is at the beginning of a project, where nothing is there. This happens quite a bit with personal projects. At work, starting projects from scratch is very rare. One problem is that there are lots of things that I have ideas about, but there is no framework that they'll fit in. Once the framework is in place, the motivation to work on something because much higher, because, when I have an idea, I can get straight to work on it and see how it works.

I generally get started by working bottom-up, making some components that I think I'll be using. Once I have some components, I'll work top-down, building out a skeleton framework. Once a sufficient framework is in place, it gets a lot more fun, where I can add stuff and test it out immediately.

The Spring Framework inversion of control container is really helpful throughout this process. I can make an initial implementation of a component by hard-coding its return values. After testing the framework around that component, I can swap the implementation for another test implementation that saves everything in memory. After that, I can swap it for a real implementation that stores stuff in a database. All that is also possible using hand-coded factory methods, but with the Spring Framework, it is available at every level -- each component can be injected with other components that can be swapped in or out in the configuration file, all without having to code up more factory methods.

No comments:

Post a Comment