• 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

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

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A better solution IMO is to throw an UnsupportedOperationException for methods not implemented by the concrete class.
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will implement all methods, then. I won't take any risks!
Thank you all for the replies!!
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic