Simple OO Design Question...

todonnell69

Member
Joined
Jun 8, 2005
Messages
15
Programming Experience
5-10
Sorry if this is posted in the wrong forum, not sure where else to look...
I am working on a VB.NET program to catalog my video collection. I have designed a class called VideoTitle. One of the methods I believe this class should implement is an Add Video method. When a video gets added, it will need to look at my DB to get the next ID number that it will be assigned.
Here's the question... In best practices, would the code within the class itself do the read from the DB to get the next ID, or would that be done outside the class, in the form's code that instantiates the VideoTItle object?
My thinking is that I should use a constructor that takes parameters including the ID, so I'm thinking the DB read/writes should be kept out of the class code, is this the best way?
Thanks in advance...
 
It sounds to me like the VideoTitle class is encapsulating an actual DVD movie you have in your collection. The DVD itself is the object being added to the collection, rather than the object doing the adding, so the AddVideo method should not be part of that class.
 
Yeah he is right you can go in the following way
MovieCollection -> contains the videos [could be catagorized]
Movie->A DVD/CD could be an interface
MovieFactory->to create a movie concerte object
->Then you can make more inhertied types as well Like CD,DVD, and so on(concerte types)
MovieValue->the value object that will be passed to DataLayer


in DataLayer, you will have classes to connect DB,hadnle Db etc along with clsses like
MovieDAO ->which will actually call your data acess classes to populate the MovieValue and pass back to Movie concerte objects


As another tip, some people dont like to make a Value Type but it can be handy if network involvemnet is there.
 
Back
Top