Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data class method implementation

 
Tony Bouer
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I look at spec but I didn't find any information telling I must implement (I mean write code) all methods of Data interface my Data class implement. Could I simple overload the methods I want use and write code just for them. For example I don 't want to write code to find provided I want to provide a specific find method just for name and location fields. What do you think about it ?

Tks,
Tony
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Java Ranch, Tony.

I made myself that same question a couple of weeks ago when I started to implement the DBAccess interface.

My specification states clearly that the GUI must provide functionality to search and display records, and let the user book an available room.

Therefore I concluded that it was not necessary to offer implementations to create or delete records.

This is what I am doing, although I cannot guarantee it is the correct thing to do. I implemented the DBAccess interface in a class that I call DBAccessImpl. I just implemented the method to read, search and update records following the specification provided by Sun within the instructions file and DBAccess interface comments.

After that I created my own wrapper class over this DBAccessImpl. This one is main Remote Object, and it offers the services that I, ultimately, will provide to the client application.

So, my recommendation is that you actually implement the methods the interface require, develop code for those you really need, the ones you do not need can throw UnsupportedOperationException and if you want to offer simpler functionality to the clien applications, create wrapper class over this implementation, offering all the nice features you want to provide.

Regards,
Edwin Dalorzo
 
Jason Moors
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would recommend that you implement the delete and create methods, I believe some people have thrown a Runtime Exception stating that the method is unsupported, however I don't know if they were marked down for this approach, and for the sake of a few lines I think it's better to be safe than sorry! and at least proves your not a lazy programmer

The assignment also mentions that the user interface should be designed with the expectation of future functionality enchancements.

I have implemented the methods and have found them very useful during testing, as it enabled me to create a simple utility to generate new records.

Jason
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic