Occasionally DAOs (and more often ORM frameworks like Reactor and Transfer) will just validate that data will be persistable - ³yup, that FirstName is less than 50 characters, so it¹ll fit just fine in a varchar(50)². That is fine. However, as Brian mentioned, you¹re going to want to have some kind of Object.validate() method that handles validating the property values (is this a valid state, is that a well formed email address, etc.) - often delegating the actual validation code to a composed Validator bean.
Best Wishes, Peter On 10/3/07 11:25 AM, "Brian Kotek" <[EMAIL PROTECTED]> wrote: > > > On 10/2/07, Ronan Lucio <[EMAIL PROTECTED]> wrote: >> >> So I have Business Logic inside DAOs. >> Is it a good practice? >> If not, how can it be sure any user would be added >> without the required fields? > > I would say that isn't a good idea. Validation really has nothing to do with > data persistence. A DAO is meant to deal with an external persistence > mechanism (in this case, a database). That's it (or that's supposed to be it). > The database doesn't know or care if the value in the email column is actually > a valid email address. That is a business rule, so I'd say it belongs in the > business object. Or as Ronan mentions, in a Validtor object that the business > object can use to validate itself (separation of concerns = good). Hope that > helps. > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CFCDev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfcdev?hl=en -~----------~----~----~----~------~----~------~--~---
