I have a ‘Purchase Order’ class. It contains information about a single purchase order. I have a DAO class for database methods.
Where should the responsibility reside for the methods that will load and update the purchase order?
Should the PurchaseOrder class have ‘.update’, ‘insert’, ‘delete’, and ‘.load’ methods that use the DAO class directly, or should the PurchaseOrder class be ignorant of the DAO methods and have a POController class that manages these interactions?
The user will only be working on a single PurchaseOrder at a time.
Thanks!
The Purchase Order should be ignorant of the details of its persistence. This is the point of having some sort of data access layer, it handles the management of the object and the object itself can concentrate on just being a purchase order.
This also makes the system easier to test, as you can create mock Purchase orders and test the logic of how the system handles them without getting entangled in persistence issues.