Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DataClient and Adapter class

 
Klaas van Gelder
Ranch Hand
Posts: 111
Java Linux PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all again...,

Some other issue now. To obtain a "proxy" to call the database methods and take care of the locking, I have created a DataAdapter class, implementing the DataClient interface.
(is this an example of the Adapter pattern or of the Proxy pattern... ?)

The interface contains the following code:


These methods are literal copies of the Data class methods, but the signatures are not very uniform. Why passing the recnum to getRecord and a complete DataInfo object to delete ?
And why pass a String[] to add() and a DataInfo to modify() ? I always prefer real object types over arrays
Of course, the methods can be overloaded. My personal feeling is that it is better to pass "keys" instead of complete objects to, for example, a Delete method.

Furthermore, the class names FieldInfo and DataInfo are pretty confusing. Is it a good idea to create some extra classes encapsulating only the data we really need for our Adapter class ?

Gtz Klaas
 
mike acre
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why passing the recnum to getRecord and a complete DataInfo object to delete ?


I guess because read just reads, but delete is more destructive.
If someone changes the record you were deleteing, maybe you don't want to delete it anymore? So in delete you can do something like:



same kind of reasoning for add v modify

Now we both need someone to confirm this.

Are the old hands on holiday?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Klass,

I agree with Mike's suggestions (including the "holiday" issue - some parts of Europe are on summer holidays already ).

As for the String[] as a parameter - we may not ever know a real reason for this. There are some requirements in the assignment that are there just to make candidates do things they would not ordinarily do . You will find this in real life assignments as well - you will be told that something has to be done a certain way, and unless you are the boss, you will have to follow the instructions given. If you wanted a guess as to a possible reason for why this String[] instruction exists, there might be another application which will be using String[] instead of a Value Object.

Regards, Andrew
 
Klaas van Gelder
Ranch Hand
Posts: 111
Java Linux PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, got that !
In the FBN-specs, however, there appears to be no posiibility for adding or deleting records for the user. This is not strange, this only would be the task of some "administrator" who can add or delete flights.
But in the Data class, the methods add and delete ARE implemented. Thus fao, I left the implementations in the DataAdapter class empty, just throwing an UnsupportedOperationException.
Is this the right way ? Or should I implement these methods to be prepared on "future enhancements" (such as adminsitration functionality) ?
If not, then I would think that only the modify method should use the locking mechanism !

Greetz, Klaas
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic