Showing posts with label design. Show all posts
Showing posts with label design. Show all posts

Monday, October 1, 2012

Association, Aggregation, Composition, Abstraction, Generalization, Realization, Dependency

Association, Aggregation, Composition, Abstraction, Generalization, Realization, Dependency:

These terms signify the relationships between classes. These are the building blocks of object oriented programming and very basic stuff. But still for some, these terms look like Latin and Greek. Just wanted to refresh these terms and explain in simpler terms.

Association

Association is a relationship between two objects. In other words, association defines the multiplicity between objects. You may be aware of one-to-one, one-to-many, many-to-one, many-to-many all these words define an association between objects. Aggregation is a special form of association. Composition is a special form of aggregation.
Example: A Student and a Faculty are having an association.

Aggregation

Aggregation is a special case of association. A directional association between objects. When an object ‘has-a’ another object, then you have got an aggregation between them. Direction between them specified which object contains the other object. Aggregation is also called a “Has-a” relationship.

Composition

Composition is a special case of aggregation. In a more specific manner, a restricted aggregation is called composition. When an object contains the other object, if the contained object cannot exist without the existence of container object, then it is called composition.
Example: A class contains students. A student cannot exist without a class. There exists composition between class and students.

Difference between aggregation and composition

Composition is more restrictive. When there is a composition between two objects, the composed object cannot exist without the other object. This restriction is not there in aggregation. Though one object can contain the other object, there is no condition that the composed object must exist. The existence of the composed object is entirely optional. In both aggregation and composition, direction is must. The direction specifies, which object contains the other object.
Example: A Library contains students and books. Relationship between library and student is aggregation. Relationship between library and book is composition. A student can exist without a library and therefore it is aggregation. A book cannot exist without a library and therefore its a composition. For easy understanding I am picking this example. Don’t go deeper into example and justify relationships!

Abstraction

Abstraction is specifying the framework and hiding the implementation level information. Concreteness will be built on top of the abstraction. It gives you a blueprint to follow to while implementing the details. Abstraction reduces the complexity by hiding low level details.
Example: A wire frame model of a car.

Generalization

Generalization uses a “is-a” relationship from a specialization to the generalization class. Common structure and behaviour are used from the specializtion to the generalized class. At a very broader level you can understand this as inheritance. Why I take the term inheritance is, you can relate this term very well. Generalization is also called a “Is-a” relationship.
Example: Consider there exists a class named Person. A student is a person. A faculty is a person. Therefore here the relationship between student and person, similarly faculty and person is generalization.

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, you can understand this as the relationship between the interface and the implementing class.
Example: A particular model of a car ‘GTB Fiorano’ that implements the blueprint of a car realizes the abstraction.

Dependency

Change in structure or behaviour of a class affects the other related class, then there is a dependency between those two classes. It need not be the same vice-versa. When one class contains the other class it this happens.
Example: Relationship between shape and circle is dependency.


Refer how these are used in representing relationships among classes in a UML class diagram at
http://en.wikipedia.org/wiki/Class_diagram



'via Blog this'

Nice Interview article complemented with my comments

The Guerrilla Guide to Interviewing - Joel on Software:

"Introduction - sound passionate

Question about recent project candidate worked on - sound passionate

Impossible Question - sound passionate | ask questions - gather constraints| out of box approach like lookup services - use any information to arrive at a solution - Get It Done approach (Approach is important to solving - information gathering (asking the right questions) and deriving meaningful information resulting into a probable solution

C Function - again look and improving time and space efficiency (use binary techniques), recursion, caching(memoization) or lazy caching of part computations.

Are you satisfied? - look for bugs in ur own software - be diplomatic but firm with your answer.

Design Question - Ask questions (gather constraints) | seek who are the actors| seek the purpose of
something being designed| seek future constraints| seek how the system is going to evolve | 
capacity planning | seek performance metrics|seek business metrics| seek time and cost metrics

Then proceed to design implementation - seek entities and their relationships such as has-a, is-a, uses-a and cardinality relationships | trim and truncate unnecessary stuff| start bottom up approach

Follow these pointers:


:: Keep it simple

:: Don't over-design

:: Keep it nimble and have the ability to extend as needed

:: Deisgn should be evolutionary - should evolve with change

:: Start bottom - up (identify the objects first and then 

group them to find the inherent relationships between them)

Your design should represent these inherent relationships
such as :

    => has-a, is-a, uses and cardinality relationship

and then further applying creational, structure and behavior patterns

The Challenge - Be passionate and be firm on what you know. Don't give in 
to the challenges which don't approve of your opinion. Stay firm on what you
believe is correct (this is tricky - you have to know u r right)


Do you have any questions?"



Project future?

where do you see this project going in the next 2 years?

Is the project growing? (CTO)

Responsibilities


in the grand scheme of things where do you see this project and where do you see me?

Do you value leadership qualities?

Leadership criteria?



What are your developers role everyday?

How much coding are they doing? Are they implementing new functionality
everyday?


'via Blog this'