Toggle menu
862
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

OOP Analysis Design Mandatory Principles: Difference between revisions

From Catglobe Wiki
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…'
 
No edit summary
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 02: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: