Hi all,
I'd greatly appreciate your thoughts on the following proposal for the B&S project's database layer.
Specified in the SUN's assignment,
DBMain interface and
Data class, which implements this interface and reads / writes to the database file, can be thought of as the actual data source implementation (similar to RDBMS: MySQL, etc). If we closely look at the methods in the DBMain interface then we can see that they are very generic, ie they have no references to contractors (eg,
String[] read(int recNo) throws RecordNotFoundException ). Therefore, we can assume that
DBMain can be used for accessing information not only from Contractor's table but from other tables as well (should they be added to the database file, eg, Customer table). That's why each instance of the
Data class is associated with the specific table (tableName is passed as a parameter into the constructor), for which it performs read/write operations.
Data class knows how to locate meta information on the table (in fact it will use schema description section in the database file)
In order to access and modify Contractor related data in any data source we create
data access object:
ContractorDAO interface. This interface defines methods such as:
create(Contractor contractor) throws DuplicateKeyExceptionContractor get(int contractorID) throws RecordNotFoundExceptionupdate(Contractor contractor) throws RecordNotFoundException ....
lock(Contractor contractor) throws RecordNotFoundException unlock(Contractor contractor) throws RecordNotFoundException Our project will contain just one concrete implementation of
ContractorDAO interface:
FileContractorDAO which in fact provides the means to access Contractor related data in our data source implementation (via
Data class)
FileContractorDAO creates an instance of
Data class with the
Data.CONTRACTOR_TABLE.
Also we'll have a business delegate that will have a local and remote interfaces (too much ejbs in my head
):
ContractorBO. This delegate will talk to
FileContractorDAO when it needs to access contractor's related data. Business object will perform tasks such as validating user input, booking contractor record, performing searches, etc. The GUI side will always talk to the database layer via
ContractorBO.
I think that this design proposal neatly fits into the DataAccessObject design
pattern.
Thanks a lot in advance for your comments.
[ August 23, 2005: Message edited by: Alex Sharkoff ]
[ August 23, 2005: Message edited by: Alex Sharkoff ]