GeeksforGeeks » Miscellaneous
Object Oriented Design Principles
(6 posts)-
What are the principle of object oriented design? What a programmer should keep in mind while designing classes and interfaces?
-
Try to put members in private as many as possible.
-
:)
How will it help, we will land up in writing many getter/setter methods (properties). Yes, ofcourse information hiding is one key concept not to be overlooked.
But there are even crucial principles.
-
By making data members private, we can control the access to data members. If they are public, client can inadvertently violate the principle and can change them.
-
@venki
I think you can find your answer @ http://www.surfscranton.com/architecture/ObjectOrientedDesignPrinciples.htm
-
From ootips http://ootips.org/ood-principles.html
1. The Open/Closed Principle: Software entities (classes, modules, etc) should be open for extension, but closed for modification.
2. The Liskov Substitution Principle: Derived classes must be usable through the base class interface without the need for the user to know the difference. [See previous tip about LSP]
3. The Dependency Inversion Principle: Details should depend upon abstractions. Abstractions should not depend upon details.
4. The Interface Segregation Principle: Many client specific interfaces are better than one general purpose interface/
5. The Reuse/Release Equivalency Principle: The granule of reuse is the same as the granule of release. Only components that are released through a tracking system can be effectively reused.
6. The Common Closure Principle: Classes that change together, belong together.
7. The Common Reuse Principle: CClasses that aren't reused together should not be grouped together.
8. The Acyclic Dependencies Principle: The dependency structure for released components must be a directed acyclic graph. There can be no cycles.
9. The Stable Dependencies Principle: Dependencies between released categories must run in the direction of stability. The dependee must be more stable than the depender.
10. The Stable Abstractions Principle: The more stable a class category is, the more it must consist of abstract classes. A completely stable category should consist of nothing but abstract classes.
Reply
You must log in to post.