Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

I have been working with Object Oriented Programming Languages for last 8 years. However, I had never had the time to analyse the OOPS concepts, though I always had answers for the interview questions ready, like, Abstraction is data hiding etc. Later, when I started taking interviews I found that almost all programmers have the answers (one word or sentence) ready, though they do not understand the basics of concepts and why these concepts are important. Here I am trying to provide my view of OOPS concepts, hoping that this would help programmers understand the concepts to the core

Archive · View All
August 2012 5
March 2013 2

OOPS - Classes and their relations

Aug 3 2012 3:18AM by Saugat   

In my previous post (OOPS - A detailed understanding of concepts), I had tried to provide a detailed understanding of basic concepts of OOPS (Class, Object, Abstraction,  Encapsulation, Polymorphism and Inheritance). In this blog I am providing an overview of relationships between the classes.

 

Generalization / Specialization

Generalization and Specialization both refer to inheritance, but the way in which it is implemented or looked into makes the difference. If many similar existing objects are combined to form a superclass to do the job of its subclass', then it is known as Generalization. When viewed from the perspective of a base class, it is generalization because the base class has functions or operations that may be commonly used by all of its subclasses.

If some new subclasses are created from an existing superclass to do specific job of the superclass, then it is known as specialization. When viewed from the perspective of the derived class, it is specialization because even though the common functionalities from the super class are available, the derived classes perform their own operations or functions specific to the purpose of their creation.

Both concepts can be implemented using inheritance only. But the order of creation of the subclass and the superclass drives the concept name.

Inheritance

Inheritance is a way to reuse code of existing objects, or to establish a subtype from an existing object. In classical inheritance where objects are defined by classes, classes can inherit attributes and behavior (i.e., previously coded algorithms associated with a class) from pre-existing classes called base classes or superclasses or parent classes or ancestor classes. The new classes are known as derived classes or subclasses or child classes. The relationships of classes through inheritance give rise to a hierarchy.

Limitations

Consider a class Person that contains a person's name, address, phone number, age, and gender. We can define a subclass of Person called Student that contains the person's grade point average and classes taken, and another subclass of Person called Employee that contains the person's job-title, employer, and salary.

  • Singleness: Using single inheritance, a subclass can inherit from only one superclass. Person can be either a Student or an Employee, but not both. Using multiple inheritance partially solves this problem.
  • Static: It does not allow a Student object to become an Employee object while retaining the state of its Person superclass. Although similar behavior can be achieved with the decorator pattern.

Symbol

clip_image002

 

Association

Association is a relationship where all object have their own lifecycle and there is no owner e.g., Teacher and Student classes. Multiple students can associate with single teacher and single student can associate with multiple teachers but there is no ownership between the objects and both have their own lifecycle. Both can be created and deleted independently.

Features:

  • Relationship between objects (One to Many, Many to Many).
  • Objects have independent lifecycles.
  • There is no owner.
  • Objects can be created and deleted independently.

Symbol

clip_image002[4]

Association is the more general term that define the relationship between two classes, where as the aggregation and composition are relatively special.

 

Aggregation

Aggregation is a specialized form of Association where all object have their own lifecycle but there is an ownership and child object cannot belong to another parent object e.g., Department and Teacher (Parent and Child). A single teacher cannot belong to multiple departments, but if we delete the department teacher object will not destroy. It can be thought of as “has-a” relationship.

Features:

  • “Has-a” relationship between objects
  • Object have independent life-cycles
  • Parent-Child relationship, Parent owns child

Symbol

clip_image002[6]

 

Composition

Composition is again a specialized form of Aggregation. It is a strong type of Aggregation. Child object does not have their independent lifecycle and if parent object is deleted all child object will also be deleted, e.g., relationship between House and Rooms. House can contain multiple rooms there is no independent life of room and any room cannot belongs to two different houses and if we delete the house room will automatically be deleted.

Features

  • Strong Type of Aggregation.
  • Parent-Child relationship, Parent owns child.
  • Only parent object has independent life-cycle.

Symbol

clip_image002[8]

 

Realization

Realization is a relationship between the blueprint class and the object containing its respective implementation level details. This object is said to realize the blueprint class. In other words, this can be described as the relationship between the interface and the implementing class, e.g., a particular model of a car ‘Ford-Ikon’ that implements the blueprint of a car realizes the abstraction.

Symbol

clip_image002[10]

 

Dependency

If change in structure or behavior of one class affects the other related class, then there is a dependency between those two classes. It need not be the same vice-versa. This usually happens when one class contains the other class, e.g., Relationship between shape and circle is dependency.

Symbol

clip_image002[12]

Tags: 


Saugat
514 · 0% · 71
3
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"OOPS - Classes and their relations" rated 5 out of 5 by 3 readers
OOPS - Classes and their relations , 5.0 out of 5 based on 3 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]