Thursday, October 8, 2009

OOP, Beans, Gateways, Services

Today - i went into a very old part of an application and revised some very old bus. logic. I am giving a facelift to part of a web site and while looking at a view page decided i would change a little logic. There was a call to the database in one of the view pages, since the beans being served up via the application to the view did not have all the data needed. This is a little lazy, to put a call to the db in a view, but understandable, especially if you do not have alot of background in MVC, Gateway, DAO, Front end controller design patterns, not to mention OOP.

After of a bit of consternation about what to do and finding another place in a related view file where i needed a bit more data, i decided to do it right. That meant going into the domain and finding the bean and dao responsible for getting and setting the data for the bean.

First, i needed to be sure i could add the little "bits" of data needed before adding them to the bean and dao. The data i wanted to add was from another database on the same server. No server linking needed! I spent a few minutes looking up how to do this and added the code to the read function of the dao that joined the existing table to a new one in onther db.

Next i added the getter and setter methods to the bean, reloaded the controller - since they cache my beans (since im using Coldspring and machii) - a couple MVC / oop frameworks.

Finally, i added the call to the new bit of data now being server up by the bean and whalla - im in busniess - logic all where it should be.

amen