OOP Analysis Design Mandatory Principles

From Catglobe Wiki
Revision as of 03:28, 22 April 2010 by Catglobe (talk | contribs)
Jump to: navigation, search

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: