[Fwd: Re: Where can you place business logic using BaseBeans approach?]
Vic Cekvenich <[email protected]>
| Newsgroups | gmane.comp.java.mvc.devel |
|---|---|
| Message-ID | <[email protected]> |
repost -------- Original Message -------- Subject: Re: [MVC-Programmers] Where can you place business logic using BaseBeans approach? Date: Mon, 17 Mar 2003 04:43:17 -0500 From: Vic Cekvenich <[email protected]> Organization: baseBeans Engineering Newsgroups: MVC-Programmers References: <[email protected]> Rick Reumann wrote: > Imagine an example where you are told that the user > requirement is that the user must be able to enter an annual salary: > > Enter your annual salary: ____ > > So naturally your UserFormBean would have an annualSalary property. > > However, you are stuck with an old database that requires the salary for > a person to be entered in as "salary per week" so at some point a > conversion needs to be done (annualSalary/52) and a different field name > of weeklySalary needs to be entered. > > Now, the quick and easy way would be to create another field in your > UserFormBean called weeklySalary and when the setMethod for annualSalary > is done it would also do a calculation and set weeklySalary. > > Of course the above is horrible approach. Definitely don't want to be > doing business logic like that in a FormBean. However doing it in the > DAO would be foolish also since the DAO should concern itself only with > the database field "weeklySalary" and shouldn't need to care that it's > getting the data in some obscure way as "annualSalary." > > So under this framework where would you handle such a business process? Bean has a DAO helper is best practice, IMO. You would derive a field in bean, or dao and I have even faked a field in SQL, so any of the 3. Another way to ask a question: If I was not doing Struts, how would I do this (fake a field in this case)? ..V > > Thanks, >