• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Design suggestions request

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rajesh, for your submission there are no deadlines. The only deadline that can occur is if you bought the Essay Exam voucher.
Mark
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic