• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Extending or Modifying?!

 
Alex Zhang
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I started my developer assignment for a while, and I am trying to work them out?
I have two questions about the assigment:
The first question is I don't know whether I should extend the Data.java or just modify it. As I have a consideration that other implementation may take place to the lock and unlock mechanism in this scenerio, so I think I should extend it
Am I right? Or any suggestion?
The secnd question is
As I have created an Inner Class in my extended Data class and a vector to store an instance this class which has two fields: the alive record number and the lock status of this record.
I use this for the lock and unlock mechanism.
Someone said it is rather complicated, isn't it?
And what should I do to improve it?
Thanks for your kindly attention.
 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex,
If you find that you can directly use the methods implemented in Data class with out modifying them and that you only need more other methods, I think you only need to add more methods to the class. This means you better to modifying the class by adding more methods.
However, if you find that some existing methods you have to modify to suite you need, I think you'd better to extend the Data class and overid those methods you need to modify. In this way, it is clearer in terms of implementation.
Ruilin
I hope the comment
 
Doug Melzer
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may be appropriate to both modify and extend it. Try to think about situations where subclassing may be beneficial.
 
Alex Zhang
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much for all your ideas.
Actually I have modified the writeRecord and readRecord methods for correcting the deprecated statements. And extends the Data class to implements the lock and unlock mechanism and the criterfind in my assignment.
Is it a right way to do so?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic