As per my understanding following points should be Kept in mind while designing an OO system:
1. Encapsulate what varies: This makes code maintenance easy because by encapsulating what varies we have moved the code more susceptible to changes to one place and it can be modified without affecting the stable code, if needed in future. This way we have introduced low coupling b/w the code which varies and the code which stay same.
2. Program to an interface not an implementation: Stable code is the one which is closed for modification but open for extension. So by programming to an interface or abstraction we can actually modify the actual implementation anytime when required without affecting the code that uses interface. So this way we have flexible and extensible code.
3. Favor composition over inheritance: It allows to delegate some of the responsibilities to the composition objects.This way we can make changes to composition object implementation independently.
4. Classes should be open for extension but closed for modifications.
There is more to come...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment