• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

data class, extend or aggregate

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic