It is part of programming folk law that we should throw away our first version of any software. Essentially, we are writing software that has never existed before and need to find the best approach. One problem I’ve always had with this is that not all of what we write is that bad on the first run. This may be because we’ve written something similar before or it’s so very simple that we can verify it works properly.
On the other hand, the technique of Refactoring promotes the evolution of software from a throw-away first edition to hardened quality. Refactoring is about improving what already works with each visit.
Yesterday, I realized I needed to choose Throwing Away. If you’ve been following my blog for the past week or so, you’ll know that I am writing a wedding application to track all the events related to my up-coming wedding next year. It uses the Model View Presenter (MVP) pattern as well as being architected via Test Driven Design.
Yesterday, I realized that I had written my Presenter to be the only Presenter in the entire application. This isn’t according to how the MVP works. It should be one presenter instance per view and a lot of the time, it’s a customized presenter built with a single task in mind: tasks such as adding a record, generating a report, etc. My Model suffered the same problem. My MVP had become closer to MVC (Model View Controller) and as a result, I had a monolith Presenter and Model.
Thinking about it deeply first, I decided to throw away my monolith Presenter and add another layer for the Model, abstracting it away from the business logic. I believe I have made the right choice.
If you want to learn more about MVP, there are some great resources. A new one I’m liking is http://www.codeproject.com/KB/architecture/DotNetMVPFramework_Part2.aspx.
Kind Regards
Glenn