Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

URLyBird - Data Interface

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have modified the original data interface that was given in my assignment, basically, by making throwing more general exceptions. I did this because I needed my Data class and my RemoteData class to implement thesame data interface (this way the GUI does not care which implementation it is working with - network or standalone).

My question is, Is this allowed, are you allowed to modifiy the given data interface in any way?
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.

You'll fail.

You can't change the interface.

I used an Adapter on top of the class implementing the interface to do what you did...

Or you could extend one of the specified Exceptions but you MUST implement the interface that you're given...

(in my proj, there were no IOExceptions so I threw non-checked exceptions for these...meaning I implmented the interface but also threw other exceptions)...
 
Enthuware Software Support
Posts: 4585
45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's right. You shouldn't change the interface. Read the instructions carefully. They are quite picky on things for which they have used "must" in the instructions.
 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bod,

I agree with the two others. Please don't do it, if you want to passe the exam. Otherwise, leave it as it is.
 
Bod Toki
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all. I have changed that. Now I use an adapter class. Thanks once again.
 
Bod Toki
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The interface throws a RecordNotFoundException. I am creating the class extending IOException instead of Exception. Is that alright?
 
Lucy Hummel
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Bod,

Good that you change to an Adapter and I do not think that it is a good idea to extend the RecordNotFoundException from IOException. If I were you, I would not do it.

I do not see a valid point to do it.
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

as far as I understand, it probably would be possible to let RecordNotFoundException inherit from IOException, as long as it is well motivated... for example, FileNotFoundException also inherits from IOException.

Actually, I am planning to extend both Exceptions appearing in the interface from a common parent (not IOException), because both indicate a database problem.

This makes life easier when it comes to the remote calls, and adds an extra layer of abstraction from the concrete implementation.

Any comments are appreciated...
Regards
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just another idea... As said before, DO NOT change the DBMain interface. If necessary, make your own exceptions as RuntimeExceptions. Runtime exceptions do not require change your interface, because they do not have to be declared in the method throws.
 
reply
    Bookmark Topic Watch Topic
  • New Topic