Encapsulate that which varies

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
m
m (Reverted edits by Ebybymic (Talk); changed back to last version by Tanmay Bhola)
 
(4 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
It is almost certain that at some point in time functionality of any program will need to change. It is very hard to predict specifics of future requirements, but is easier to predict what parts of the system might change. These parts that may change should be hidden behind interfaces (ie Encapsulated) to help minimize the effects caused by changes in these parts. A simple, every-day example is an instance variable hidden behind  a getter and/or setter. As long as the rest of your system is programmed to the interface you are "hiding" behind, variations in the components will have no effect outside of themselves.
 
It is almost certain that at some point in time functionality of any program will need to change. It is very hard to predict specifics of future requirements, but is easier to predict what parts of the system might change. These parts that may change should be hidden behind interfaces (ie Encapsulated) to help minimize the effects caused by changes in these parts. A simple, every-day example is an instance variable hidden behind  a getter and/or setter. As long as the rest of your system is programmed to the interface you are "hiding" behind, variations in the components will have no effect outside of themselves.
  
When writing software, have a look to see what might vary in the future, and plan for it. Do not attempt to add the functionality (see [[keep it simple]]), but use interfaces/encapsulation to allow any future functionality to added easily.
+
When writing software, have a look to see what might vary in the future, and plan for it. Do not attempt to add the functionality (see [[keep it simple]]), but use interfaces/encapsulation to allow any future functionality to be added easily.
  
 
==Conflicts==
 
==Conflicts==
Line 12: Line 12:
 
* [[Minimize accesses to variables]]
 
* [[Minimize accesses to variables]]
 
* [[Program to the interface not the implementation]]
 
* [[Program to the interface not the implementation]]
 +
* [[Stable abstractions principle]]

Latest revision as of 03:11, 25 November 2010

"The only constant is change" - Heraclitus

It is almost certain that at some point in time functionality of any program will need to change. It is very hard to predict specifics of future requirements, but is easier to predict what parts of the system might change. These parts that may change should be hidden behind interfaces (ie Encapsulated) to help minimize the effects caused by changes in these parts. A simple, every-day example is an instance variable hidden behind a getter and/or setter. As long as the rest of your system is programmed to the interface you are "hiding" behind, variations in the components will have no effect outside of themselves.

When writing software, have a look to see what might vary in the future, and plan for it. Do not attempt to add the functionality (see keep it simple), but use interfaces/encapsulation to allow any future functionality to be added easily.

Conflicts

See Also

Personal tools