• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLyBird - Data Interface

 
Bod Toki
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • 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?
 
Brian Kelly
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • 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)...
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3819
10
  • Mark post as helpful
  • send pies
  • 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.
 
Lucy Hummel
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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.
 
Tilo Hemp
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • 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
 
Luiz Reginaldo Curado
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic