Difference between revisions of "OOP Analysis Design Mandatory Principles"

From Catglobe Wiki
Jump to: navigation, search
(Created page with '== Open & Closed Principle<br> == Description:<br> As the name itself, it's a principle instruct us how to close the main base behaviors of the original classes by preventi…')
 
Line 1: Line 1:
== Open &amp; Closed Principle<br> ==
+
== Open &amp; Closed Principle<br> ==
  
Description:<br>
+
=== Introduction:<br> ===
  
As the name itself, it's a principle instruct us how to close the main base behaviors of the original classes by preventing almost direct modifications, also to open existing classes to extend or make some changes by subclass and override on them,<br>
+
As the name itself, it's a principle instruct us how to close the main base behaviors of the original classes by preventing almost direct modifications, also to open existing classes to extend or make some changes by subclass and override on them.<br>  
  
Specification:<br>
+
=== Description:<br> ===
  
Class can be subclassed<br>
+
#Class can be subclassed for extension<br>
 +
#Class' behaviors can be overriden<br>
 +
#No modification is on the locked behaviors of base class (<u>related open behaviors aren't</u>)<br>
 +
#Modifications are on subclass<br>
 +
 
 +
=== Specification: ===
 +
 
 +
*Description #1 and #2 means that base class must assure the accessibilities and inheritance
 +
*Description #3 and #4 means that we have 2 methods for the base class extension:
 +
 
 +
#Allow the closed action might be overriden and reused on subclass
 +
#Allow some actions open on base class so that those actions might happen inside the closed action
 +
 
 +
=== Example:<br> ===
  
 
<br>
 
<br>

Revision as of 04:28, 22 April 2010

Open & Closed Principle

Introduction:

As the name itself, it's a principle instruct us how to close the main base behaviors of the original classes by preventing almost direct modifications, also to open existing classes to extend or make some changes by subclass and override on them.

Description:

  1. Class can be subclassed for extension
  2. Class' behaviors can be overriden
  3. No modification is on the locked behaviors of base class (related open behaviors aren't)
  4. Modifications are on subclass

Specification:

  • Description #1 and #2 means that base class must assure the accessibilities and inheritance
  • Description #3 and #4 means that we have 2 methods for the base class extension:
  1. Allow the closed action might be overriden and reused on subclass
  2. Allow some actions open on base class so that those actions might happen inside the closed action

Example: