In an earlier post I had pointed out use of TDD and Refactoring to write the domain logic for poll measurements.
Key activities still were to be done:
- Persist this data onto database.
- Create views to play with this data.
You may have guessed I believe in working demos. Not html prototypes. I want to see in code that I can do it atleast in 1 way what I or you claim to be possible.
So I started off with the view. The user would enter the montly data and check up with the measurements (quarterly etc). When satisfied he would want to persist the data. But I like to take baby steps. Hence I decide let me get the calculation on a view out of the way.
I now moved to bea workshop to do this. I have liked its struts framework. I designed a jsp. THe jsp would invoke a calculateMeasurement action on this web app controller. The action would load the domain objects from the form and invoke appropriate domain methods and inform the view. The view would update it with the measures. The thing I like about struts framework provided by bea is the ease of use in dropping actions and invoking views without making my hands dirty.
This to my surprise worked fine. Because my domain logic was pretty much in place. Now I moved to handle persistence. I saw my db structure and domain structure have pretty much 1-1 relationship. SO active record could be a choice. Somehow I feel active record makes my objects bloated. I tend to shy away from it. I just used a db control a db facade. I wrote the insert logic on this control. Next I created a controller action to handle inserts. It would just pass on to the db control required data. Also the choice of db was pointbase. :-). Spend only 5$ when you need to spend 5$. A 100$ would be stupid aint it? oracle = 100$ pointbase = 5$.
Similary I crated update action. For handling the object insert/update state, I didnt use a state pattern. I would use that if I had db objects. So for this very simple case an insert update flag would do. But as db - domain impedence mismatch increases I would have to refactor to a domain mapper somethign like hibernate which would take care of this.
As of now its pretty much stable demo. It lets you do what you want to. It persists to a database. Thus it does what it claims to.
I pretty much attribute all this to my agile learnings. Agile lets me ask right simple question. Or as these questions a result of my changed mindset? I have to yet to find an answer. ;-)
It must be noted that key is to:
- Take baby steps.
- Think on lines of TDD at each and every possible step.
- even if not agile use TDD, Refactoring.
When this project becomes multi member project: we must:
- Introduce automated builds.
- Introudce automated functional tests.
- If performance is a major factor right from start, have performance tests in place.
- Run functional and performance tests every night.
Stay Agile. Stay in Control. Claps.
Disqus comments are disabled.