I'm just starting to get serious with design patterns, and one that looks particularly useful is the Data Access Object. I've written an abstract DAO class that can be easily extended to support specific, concrete uses, and it works great.

I have one question, though: what's the "right" way to combine the data persistence functionality of a DAO with other functionality? For example, let's say I have a Client object. That object has methods such as approvePlan(), cancelPlan(), sendEmail(), etc. Would these methods and my data-access methods go in the same class? Or would I instantiate a separate ClientDAO object, and set that as a property of my Client object? That seems cleaner in some ways, but then my Client object would have to have a bunch of getters and setters that just invoke the corresponding getters and setters of the ClientDAO object...which seems unclean. Unless, I'm missing something, which is entirely possible.

Any help would be appreciated! Thanks!

    Write a Reply...