Simple OO Design Question...

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...
[828 byte] By [todonnell69] at [2007-12-16]
# 1
Hi,

The next Id should not be retrieved by the Form Class - the form should not have any code related to business logic or data access. So the VideoTitle should retrieve this information via a Data Access Layer Class.

The Data Access Layer will be used by the VideoTitle to actually execute the query. So, your VideoTitle class builds the query and passes it to the Data Access Layer which executes it and returns the results.

Regards,
Vikram

Vikram at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified