aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes If I don't need the delete and create functions, what to do with the interface given Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "If I don Watch "If I don New topic
Author

If I don't need the delete and create functions, what to do with the interface given

Lucas cotta
Greenhorn

Joined: Oct 10, 2011
Posts: 21
Hi all!

My instructions do not require create or delete in the GUI, so I assume I don't need to implement the create and delete methods of the given interface.
But if this is true, what should I do in the class that implement the interface? Just return null?
I'm worried about "must implement this interface" means that I must implement all methods...
Did anyone loose points with this?

Thanks!!
arvind kushwaha
Ranch Hand

Joined: Aug 12, 2011
Posts: 32
hi.

Luscas cotta.

If you implements any class you have to provide implementation of all the method. If you think that this method is not full filling your need then donot write any think in body or donot implements the interface
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

A better solution IMO is to throw an UnsupportedOperationException for methods not implemented by the concrete class.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4457
    
    8

Check the instructions carefully, though. Yours may be different, but mine required me to implement the interface fully regardless of which methods were needed by the application.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5514
    
  13

You could take a risk and implement the given interface and for each method you don't use in the application throw an UnsupportedOperationException. Then extensively document in choices.txt why you followed this approach and you might pass with this approach. But it still is a risk you could possibly fail for not having an actual implementation for all methods. As far as I know no one so far took this risk, because it could be a costly one.

Hope it helps!
Happy New Year!


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Lucas cotta
Greenhorn

Joined: Oct 10, 2011
Posts: 21
I will implement all methods, then. I won't take any risks!
Thank you all for the replies!!
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1509
    
    5

Hi Lucas,

I agree with Roel. It is indeed risky to have an empty implementation.

For me too, requirements were similar (no necessity for create and delete operations, but given interface was containing those methods).

So, I wrote a descent working code for those methods, but did not expose those methods via RMI or did not provide any buttons on GUI. So, only way to invoke those methods was to write another class and call the methods.

Of course, I mentioned all these things in choices.txt.

All the best!


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: If I don't need the delete and create functions, what to do with the interface given