hi All! needs your comments. i have extended Data class and subclass is newData. i extended Data class instead of adding new fuctionalities like cFind(), lock()/unlock(), but as we know synchronization is not part of inheritance. child class inherits methods but without syn.? so instead of inheritance, should i aggregate(has a) Data in newData and provide new fuctionalities and redirect call to methods of data class so that i will be able to get syn. feature also. my examination date 18th of this month. need your comments asap. thanks and regards, bhuvan.
I suggest if you can come up with convincing reasons to extend Data class, you are ok. I did it without extending the Data class because I was able to come up with only the reasons below, which are not impressive: 1) Make the Data constructor protected and thereby forcing the programmer to create the Singleton instance of the sub class. But when you have to deal with more tables, the programmer has to remember to implement Singleton. Instead you can create a server side Factory to make sure you create one instance of Data object for every table or db file. 2) It is possible for the Data object to delegate the value comparison during criteriaFind() to the sub class instance. Instead you can check for the String "any" in the CriteriaFind() method of the Data class. I think this is ok for the assignment. You can also use ideas by Mark's earlier posting about criteriaFind(). If the user types "any" in any search fields, you pass blank values to the server and if all the fields have blank values, the search will bring all the records. So after considerable thought, I decided to use a server side Factory to create only one instance of Data for each table or db file.
Originally posted by Bhuvan mehra: i extended Data class instead of adding new fuctionalities like cFind(), lock()/unlock()
As SP said: I assume you have convincing reasons why a method like criteriaFind() should not be part of Data.
but as we know synchronization is not part of inheritance. child class inherits methods but without syn.?
It's not quite like that. The base class functionality remains synchronized! So you only have to worry if there are any methods you are adding or overriding. When you override a method, the base class code remains synchronized but any code you add in the subclass will not be. Unless you add synchronization in the subclass as well. Whether you need to do this depends on how the subclass code works... - Peter
posted 18 years ago
thanks Peter, actually cfind() is part of Data but lock()/unlock() is part of child class. i was worried about cfind() and other inherited methods which are syn., but you said that my assumption is wrong that inheritable methods get inherited without syn. feature. thanks for making my concept correct. regards, bhuvan.
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
Devious Experiments for a Truly Passive Greenhouse!