© Tyler Technologies 2013
1
Agenda
• Encapsulation
• Inheritance
• Polymorphism
• Association
• Aggregation
• Composition
© Tyler Technologies 2013
2
What is Encapsulation?
• Encapsulation is the condition of being enclosed. (as in a
capsule)
• With programming perspective, Enclosing “attributes” and
“methods” within a class would be called Encapsulation.
© Tyler Technologies 2013
3
Encapsulation Example
• Attributes are set to private.
• Methods defined are usually set to public.
• Methods may also be set to private, these methods
would only be called from with in the class.
© Tyler Technologies 2013
4
Encapsulation - Benefits
• Encapsulation hides the implementation details.
• Ensures that structural change remains local:
– Changing the class internal code doesn’t effect any code on the outside.
– Changing the implementation inside a method does not effect the class
which is calling it.
• Encapsulation allows adding some logic while accessing
any attribute.
– E.g. in Accessor methods
• Hiding implementation details reduces complexity
implying easier maintenance.

OOP Principles Encapsulation Inheritance.pptx

  • 1.
    © Tyler Technologies2013 1 Agenda • Encapsulation • Inheritance • Polymorphism • Association • Aggregation • Composition
  • 2.
    © Tyler Technologies2013 2 What is Encapsulation? • Encapsulation is the condition of being enclosed. (as in a capsule) • With programming perspective, Enclosing “attributes” and “methods” within a class would be called Encapsulation.
  • 3.
    © Tyler Technologies2013 3 Encapsulation Example • Attributes are set to private. • Methods defined are usually set to public. • Methods may also be set to private, these methods would only be called from with in the class.
  • 4.
    © Tyler Technologies2013 4 Encapsulation - Benefits • Encapsulation hides the implementation details. • Ensures that structural change remains local: – Changing the class internal code doesn’t effect any code on the outside. – Changing the implementation inside a method does not effect the class which is calling it. • Encapsulation allows adding some logic while accessing any attribute. – E.g. in Accessor methods • Hiding implementation details reduces complexity implying easier maintenance.

Editor's Notes

  • #1 Agenda The following topics shall be discussed in this presentation: Encapsulation Inheritance Polymorphism Association Aggregation Composition
  • #2 Basic Definition of the term Encapsulation: “Encapsulation refers to the condition of being enclosed, as in a capsule.“ Relating the Encapsulation concept with a capsule really helps in associating the word “encapsulation” with what it actually means, also it benefits in recalling the definition and the idea later on. In essence Capsule is a one word definition for Encapsulation.
  • #3 This is how you achieve Encapsulation by bundling appropriate attributes and methods, i.e. by creating a class. The class diagram shows attributes to be privately accessible while all the functions are public.
  • #4 Changes made to the code creates maintainability issues. Usually fields in a class are changed more often than the class’s constructors or methods. Encapsulation makes sure that when fields are changed, necessary changes can comparatively easily be done in the same class, and this change remain local to that class only, eliminating the chances of an external class being modified.