This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Lucas cotta
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A better solution IMO is to throw an UnsupportedOperationException for methods not implemented by the concrete class.
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9168
76
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Lucas cotta
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will implement all methods, then. I won't take any risks!
Thank you all for the replies!!
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic