Infolinks In Text Ads

Rules for using Inheritance In Java(Very imortant rules when to use inheritance)

 There are some important rules for inheritance usage, and this rules is called Coad's Rules
Use inheritance only when all of the following criteria are satisfied:
  • A subclass expresses "is a special kind of" and not "is a role played by a"
  • An instance of a subclass never needs to become an object of another class.
  • A subclass extends, rather than overrides or nullifies, the responsibilities of its superclass.
  • A subclass does not extend the capabilities of what is merely autility class
  • For a class in the actual Problem Domain, the subclass specializes a role, transaction or device
Both composition and inheritance are important methods of reuse. Inheritance was overused in the early days of OO development . Over time we've learned that designs can be made more reusable and simpler by favoring composition. Of course, the available set of composable classes can be enlarged using inheritance. So composition and inheritance work together But our fundamental principle is:
Favor Composition Over Inheritance

Newer Post Older Post

Leave a Reply

Powered by Blogger.