aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes URLyBird: Question concerning Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "URLyBird: Question concerning "Data" class" Watch "URLyBird: Question concerning "Data" class" New topic
Author

URLyBird: Question concerning "Data" class

Alex Duran
Greenhorn

Joined: Jan 29, 2007
Posts: 8
I'm currently working on URLyBird (1.1.2) and the instructions contain the following statement:

Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface:

[Definition of sunceritfy.db.DB interface follows...]

My question is - what is the scope of a "data access class"?

Minimally, it's clear that the class declaration for suncertify.db.Data must look like:



But does "Data Access Class" also mean that all aspects of the data access - including locking, file access, etc. must also be contained within the suncertify.db.Data class?

For example, let's say I wanted implement the "create" method in Data.java as follows:



where "doCreate" would be defined as an abstract method (thereby making suncertify.db.Data an abstract class) that would be overridden by subclasses that provide an implementation (e.g. a FixedFieldDataFile subclass would provide an implementation required for this assignment). In other words, I'd use a Template Method pattern.

Would the above approach (and similar) where implementation details have become the responsibility of classes other than suncertify.db.Data violate the requirement that mandates that suncertify.db.Data serve as the "Data Access Class"?

Thank you.


SCJP
Alex Duran
Greenhorn

Joined: Jan 29, 2007
Posts: 8
One correction...the line in the 2nd code example that reads:



Should have read:

Rudolph Jen
Ranch Hand

Joined: Nov 17, 2006
Posts: 37
> But does "Data Access Class" also mean that all aspects of the data access - including locking, file access, etc. must also be contained within the suncertify.db.Data class?

IMHO it doesn't. The class "Data.java" must implement the provided interface, thats it. I did not put all following needed logic in that one class, or even in one big method. My Data.class delegates some issues to other classes, because I would like to get the cohesion on a good healthy level.

> Template Method pattern.

I am a fan of the Template Method myself, but I don't see the reason to use it here. Sorry Perhaps I am to dump to see it.

Best Regards,
R


SCJP<br />SCJD (in progress)
Alex Duran
Greenhorn

Joined: Jan 29, 2007
Posts: 8
Rudolph,

Thank you for your reply.

The intent behind using Template Method is that if, for some reason the format of the data file were to change or the database were to change to something that did not use a file at all, those changes would be encapsulated elsewhere. The checks for pre-conditions, post-conditions, etc. could remain in the suncertify.db.Data class, however, since these will not change unless the interface of suncertify.db.DB changes.

What do you think? Maybe I have lost my mind
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URLyBird: Question concerning "Data" class
 
Similar Threads
URLyBird 1.2.1 Passed!
URLyBird interface?
URLyBird 1.2.3
DB Interface (URLyBird 1.1.2)
(URLyBird) Do I need to implement the create & delete methods?