This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Design suggestions request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Design suggestions request" Watch "Design suggestions request" New topic
Author

Design suggestions request

Rajesh So
Ranch Hand

Joined: Oct 08, 2002
Posts: 133
Hi,
1) In most places of the given code, Database Exception is thrown for obvious reasons. For example, invariant() throws because the database is not in a readable order, add() throws for attempting to duplicate keys, the data to be added in db is insufficient.
These conditions are very much expected and not exceptional. Hence, can they be checked for and returned as boolean �false� to the caller? But I am puzzled on how to send the caller the reason on why the operation was failed. I arrived to this decision of limiting Exception only to unexpected situations based on this article,
http://www.javaworld.com/javaworld/jw-08-2000/jw-0818-exceptions-p2.html
In that case, what situations and how situations can be considered �Exception� ?
2) In the archives, there were suggestions for using Synchronized blocks over entire method synchronization. When I tried doing that, I lose safety. I feel we cannot use sync blocks in this project. For example,

When control enters the synchronized block, no other thread is allowed to enter inside the block, but the 'DataInfo newData' of the method signature can be accessed by the next arriving thread. This argument, used inside the block could then get corrupted, since work is going on inside the block. Hence, can we conclude that we cannot use blocks in our project and to assure safety, the entire method has to be synced?
3) Methods �size�, �seek� resemble some of the methods of Java API. Can this be a reason for it to be renamed?
4) I am not bringing the Connection and Data interfaces under the same interface. Decoupling them will help Connection to be independent of any Data interfaces. If another Data interface comes up with different signatures, 2 people are not affected (Connection and the Client side interface) , only the implementation of Connection would need modification. Is this a good idea?
5) Lock method specifies that �No timeouts is specified for this�. So should we not implement timeouts. Is�nt not specifying timeout gives rise to locking forever?
6) Can the primary key of the db be sorted through Map? I wish to maintain a Map of Primary keys of LiveRecords of the db. It would help is standard easy search.
7) Some people in archives say of using many Connection objects for many clients. Since we have to provide 'stub' of one implementation to each of the client, how can we provide many Connection objects. I was planning to have one Connection implementation and having its methods synchronized. Is this direction wrong?
Please give your suggestions. My voucher deadline for submission of exam is on or before 31 dec 02.
Thanks in advance,
Rajesh
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Rajesh, for your submission there are no deadlines. The only deadline that can occur is if you bought the Essay Exam voucher.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
John Smith
Ranch Hand

Joined: Oct 08, 2001
Posts: 2937
These conditions are very much expected and not exceptional.
While you could probably make a case that adding a record with a duplicate key
is not an exceptional condition, the corrupt database file certainly is such
a condition.

...but the 'DataInfo newData' of the method signature can be accessed
by the next arriving thread.

Not really, -- your "newData" is an argument to a method call, and each thread gets
and operates on its own copy.
Methods �size�, �seek� resemble some of the methods of Java API.
Can this be a reason for it to be renamed?

It's actually vise-versa, -- they are named as such to resemble (to conform to)
Java API.

Lock method specifies that �No timeouts is specified for this�.
So should we not implement timeouts. Is�nt not specifying timeout
gives rise to locking forever?

Yes, in theory a client can wait indefinitely. But don't worry about it,
your assignment doesn't ask you to address this issue.
Can the primary key of the db be sorted through Map?
I wish to maintain a Map of Primary keys of LiveRecords of the db.
It would help is standard easy search.

I would strongly recommend that you don't complicate your design for the performance reasons.
Some people in archives say of using many Connection objects for many clients.
Since we have to provide 'stub' of one implementation to each of the client,
how can we provide many Connection objects. I was planning to have one Connection
implementation and having its methods synchronized. Is this direction wrong?

The idea is to use a distinct remote object for every client as a means of identifying
that client for record locking. Normally you would accomplish this by implementing
some sort of "factory" that creates these remote objects on demand.

Eugene.
Rajesh So
Ranch Hand

Joined: Oct 08, 2002
Posts: 133

for your submission there are no deadlines. The only deadline that can occur is if you bought the Essay Exam voucher.
Mark

I bought the voucher 2-3 months before during the Java Certification day discount offer. I was told by the authorities that I have to take up the exam before 31 dec 2002, else the voucher will expire.
Currently, I am half way through and am meeting a lot of issues, which I am doubtful of completing in another 8-9 hours.
Please tell me if I am mislead.

The idea is to use a distinct remote object for every client as a means of identifying
that client for record locking. Normally you would accomplish this by implementing
some sort of "factory" that creates these remote objects on demand.

I am making my Data class independent of any client connection. If a thread wants to modify a record, that particular record number is stored in Set (A java.util.Set , held by a LockManager object). After the modify() is over, the record number is removed from the set. Also if exceptions come during modify(), the record number is removed from set. This is simple, but is it right?
Rajesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design suggestions request
 
Similar Threads
Exceptions
suncertify.db.Data
Difference between JCA adapter and JDBC
Printing PreparedStatements to log file
Parsing Java Source Code Files