Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

modification or subclassing data - is this strictly one or the other ?

 
dean tomlinson
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the requirements under the section "extending suncertify.db.Data", it says ...

part ofthe assignment will be to enhance the Data class. You may do this by modification or subclassing, but you must document the approach and reason for your choice

this seems to relate to where you implement criteriaFind, lock and unlock. as we are expected to fix the deprecated methods in data regardless.
does anyone know if this is strictly a case of one or the other ?
currently i have implemented criteriafind in Data and i did this this becasue Data was not a complete implementation of a local DataAccess (the interface which enables my gui to seemlessly work in local and reomte mode) resource without it.
i have also created a SharedData class that, together with the SharedDataConnection class provides the locking functionality.
wondering if to totally leave Data - apart from fixing the deprecated code, incase it is being used in other fly by night systems, and create a new subclass for local use perhaps called SingleUserData, which would implement criteriafind. my sharedData could then extend this to provide locking functionality ?
any comments greatly appreciated as always - dean
 
Steven Sloggett
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by dean tomlinson:
wondering if to totally leave Data - apart from fixing the deprecated code, incase it is being used in other fly by night systems, and create a new subclass for local use perhaps called SingleUserData, which would implement criteriafind. my sharedData could then extend this to provide locking functionality ?

There's nothing wrong with fixing the deprecated methods and adding 'criteriaFind' to the 'Data' class even if it is in use elsewhere. The class will still perform the same.
Also, the requirements implies that the Fly by Night application we have to create is the first application to use 'Data'.
This undergraduate did some work using the Java programming language and started to produce a rudimentary database system.
The Information Systems Department Manager now wishes to extend this work into a usable application.
 
raphael Bereh
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will probably not need the 2 methods .
But you have to think about the reasons why you will subclass rather than modify !
For instance, if modifying will cause problems with you application not being compatible anymore with legacy clients, you should not ! Subclass instead in this case. Other reason you should consider :
- are you tracking code modification ?
- Version control ?
hope this helps.
 
dean tomlinson
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi steven,
There's nothing wrong with fixing the deprecated methods and adding 'criteriaFind' to the 'Data' class even if it is in use elsewhere. The class will still perform the same.

originally i did add criteriaFind to Data (which meant modifying Data) but also created a subclass called SharedData which had locking functionality.
therefroe i think this is against the requirment ...
part of the assignment will be to enhance the Data class. You may do this by modification or subclassing, but you must document the approach and reason for your choice

becasue i am not doing one or the other - but both.
i'm assuming this constraint is there to restrict what can be done. i remember reading that this assignment would involve working around some less than ideal features that exist in the supplied code.
what do you think ?
 
dean tomlinson
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi raphael,
you have to think about the reasons why you will subclass rather than modify !
For instance, if modifying will cause problems with you application not being compatible anymore with legacy clients, you should not ! Subclass instead in this case.

i am interpretting from
part of the assignment will be to enhance the Data class. You may do this by modification or subclassing, but you must document the approach and reason for your choice

that you can either modify Data so that it has an inmplementation for criteriaFind lock and unlock, or you can choose to leave it as is, and create subclasses of Data to provide this functionality.
therefroe i think the reason why subclassing is needed, is becasue the locking functionality should not be used by the database for local mode, only when the database is being used within a data server.
therefore creating 2 subclasses of Data (1 for local and 1 for shared use) is a better solution than modifying Data to do everything.
what do you guys think ?
[ June 04, 2002: Message edited by: dean tomlinson ]
 
Steven Sloggett
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by dean tomlinson:
becasue i am not doing one or the other - but both.

That's ok too.
You modify 'Data' to add 'criteriaFind'. That's one issue. You sub-classed 'Data' to add locking. That's another issue. They are both valid solutions.
 
dean tomlinson
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm not sure they are 2 seperate issues. they are listed as one "issue" in the requirements. just beneath the line that says you may enhance the Data class by modifcation or subclassing.
i've got a complete system but are now getting really pedantic about doing exactly what is asked for in the requirements, and have started to bin things that were not.
 
Steven Sloggett
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by dean tomlinson:
i'm not sure they are 2 seperate issues. they are listed as one "issue" in the requirements. just beneath the line that says you may enhance the Data class by modifcation or subclassing.
i've got a complete system but are now getting really pedantic about doing exactly what is asked for in the requirements, and have started to bin things that were not.

Sure, but ultimately, what ever you do, so long as it is reasonable and justified it is ok. There are always many ways to do solve the problems - of which, your solution is one.
 
dean tomlinson
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi mark,
have you got any comment on my originla post.
it kind of relates to your advise that i should not change any of the thrwos clauses in the Data class.
i am still a bit uneasy about the fact that my DataAccess.lock method throws IOException if the record number was not found, and not DatabaseException.
any thoughts on if it is strictly a case of do everything in Data or create subclasses.
if you have any knoweldge that this is not a strict requirement, i am thinking of making my SingleUserData class delegate to Data rather than extend, then i can clean up this lock method's exception, and i'll be much happier that my DataAcccess interface is good.
this will be my last question - but obviuolsy i'll stick around to help others like you've done so generously.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I thought the original Data class that they give you does not throw any exception in the lock method. In mine there is no exception thrown in lock or unlock.
Ok so what is SingleUserData, is this your DataAccessLocal class that implements DataAccess for local mode?
And what is SharedData class, is this your DataAccessRemote class that implements DataAccess for remote mode?
I included the implementation of lock, unlock, and criteriaFind in the original Data class provided, meaning I modified it. I still believe modifying the class is better than extending it.
If you use the LockManager class you do not need to implement lock or unlock, which I think is cleaner. As far as CriteriaFind is concerned, I ahd to add two private methods to make mine work, I think this is one of the key areas that I lost points in. I could have had a helper file to have those methods, and either not have to implement criteriaFind, or just have that one method, which creates the helper class and passes it the reference of the Data class, to be able to loop through the records.
Mark
 
dean tomlinson
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi mark,
thanks for your reply. yes the lock method in my data class throws ioexception - and the javadoc comment for the method, says it will throw this if the recrod number is invalid, but really to test if a recrod exists you need to use getRecord, and that throws DatabaseException in my original data class.
so really i feel the lock method should also throw DatabaseException, but infact inside my lock method i am calling gerRecord to validate the record nmuber entered, then if a DatabaseException is thorwn, I convert this into an IOException to satisfy that stupid Data interface.
Anyway it's got too late for me to change anything now. it's 10pm and my exam is at 2pm tommorow (and i've not finshed documneting !).
i'm just gonna explain that i didn't want to change the interface of Data (due to the way this could impact other subclasses / projects ) and say that i read the requirmenets to say that i could only modify OR subclass data.
at the end of the day i think we hav to be able to justify the pro's and cons of our design, and talk about the constraints we worked around.
thanks for all your help. i'll let you know how it went.
cheers - dean
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic