CLASS: A class can be defined as a skeleton for an object or blueprint for an object or template for an object. A class defines all the variables and methods, an object should have. An object is an instance of a class.
Consider an example, let ‘fruit’ be a class, then mango is an object of the class fruit. The fruit class gives a blueprint or template to the object that the object should have like color, size etc. The fruit class just defines color and size whereas the object gives specific values to color and size.
OBJECT: Once you define a class it becomes a template for an object. By using this template we can create any number of objects, so object is an instance of a class.
COMPONENT: The collection of Classes is called as a “Component”.
PACKAGE: The collection of Components which are not reusable in nature are called as a “Package”.
SUBSYSTEMS: The collection of components which are reusable in nature are called as “Subsystems”.
1. ABSTRACTION: The elimination of irrelevant information and amplifications of essential information. Abstraction is nothing but finding out what is common among different things.
For example, consider a car which is a complex system and has several parts within it. A car contains few high-level components such as brake, handle, accelerator and gears etc.It is possible to describe the use of these components without giving details about the construction of these components. When details of the construction of anyone of these components is to be found out, the construction of remaining components is not considered. That means, only the abstract, view of a component is taken into consideration, as the object’s view is limited to few properties.
2. ENCAPSULATION: Encapsulation is the mechanism which binds together the code and the data. This encapsulation prevents the code and data from being accessed by other code defined outside the class. Encapsulation can be defined as the wrapping up of data and methods into a single unit known as a Class. A class defines the structure and behaviour that is shared by all its objects. A class consists of data and code, these elements are called members of the class. The data is referred to as instance variables and the code that uses the data is referred to as methods. With encapsulation, it is possible for objects to be treated as “black boxes” with each doing a specific task.
3. INHERITANCE: Inheritance is the process by which an object of one class known as subclass, acquires the properties of another class known as superclass. Inheritance is a powerful mechanism for reusing the code. Without inheritance, each object has to define all its properties. However, by inheritance, an object needs to define only those properties which makes it unique within its class. A subclass can inherit any number of super classes.
4. POLYMORPHISM: Polymorphism means the ability to take many forms. Basically, it is a “Single Instruction-Multiple operations”.
RELATIONSHIPS There are four types of relationships.
1. ASSOCIATION: It has a relationship.
•Unary: One way relationship or unidirectional.
•Binary: Both ways or bidirectional.
•Multiplicity: It is an important aspect of associations among objects. It tells the number of objects in one class that relate to a single object of the associated class.
•Reflexive: Sometimes, a class is an association with itself. Referred to as a reflexive association, it can happen when a class has objects that play a variety of roles.
2.GENERALIZATION: It is a special case of specialization. The design approach may br top-down or bottom-up approach. In top-down, the entities are identified and are subdivided. In contrast, a bottom-up approach, all the low-level entities are grouped to form a high level entity.
3.AGGREGATION: Aggregation represents a relationship between a whole object and its component parts.
Aggregation is the process of compiling information on an object, thereby abstracting a higher level object. In this manner, the entity person is derived by aggregating the characteristic name, address and social security number. Another form of aggregation is abstracting a relationship between objects and viewing the relationship as an object.
4.COMPOSITION: It is the ‘parts’ and its ‘whole’ relationship. The ‘Part’ also dies along with the ‘whole’. A composite is a strong type of aggregation. Each component in a composite can belong to just one whole.
MESSAGE SENDING: Objects work together in a system. Here, one object sends messages to another object which is nothing but a request to perform the activity. The receiving object performs the activity. These messages are sent by methods. Method names are represented by Camel Casing. It means initial word will be small alphabets and from second word onwords beginning alphabet is capital and the rest are small.