Morning All,
Im pretty much at the beginning of my first
Java application that has a local database at its back end.
Following some examples posted for me using the JPA im now looking at design
patterns etc but have a couple of questions up front.
1. When working with any kind of persistence (file, database), should the objects be responsible for the persistence e.g I have an Asset class, should this class have a method like addToDatabase() or is this better handled elsewhere. If so are there any principles that should be applied.
2. Im guessing the way to work with my objects and data is to create objects from the data rather than working with the data directly. E.g I have an Asset record in the database, I create a "new Asset(with its corresponding data) object", manipluate the object using its getters and setters and then write that data back to the database. Am I way off the mark?
I may be trying to run before I can walk but I have to start somewhere.
Cheers
Dan