Suppose we want to develop a fee collection system for a school for this we will need to find out related objects and their interactions as happens in real life. In this way we can say that object orientation makes it easier for us to solve our real world problems by thinking solution of the problem in terms of real world objects.
OO Models:
Objects
Ali, Car, House, Tree
Interactions
Ali lives in the house
Ali drives the car
- Something tangible (Human being, School, House, Car).
- Something conceptual (that can be apprehended intellectually for example time, date and so on…).
- State (attributes)
- Well-defined behavior (operations)
- Unique identity
State (attributes)
Color
Model
Behavior (operations)
Accelerate
Start Car
Change Gear
State (attributes)
Hours
Seconds
Minutes
Behavior (operations)
Set/Get Hours
Set/Get Seconds
Set/Get Minutes
We will assign our own generated unique ID in the model for Time object.
State (attributes)
Year
Day
Month
Behavior (operations)
Set/Get Year
Set/Get Day
Set/Get Month
- Model is the abstraction of some real word scenario. It helps us to understand that scenario.
- Object oriented model of any scenario (problem) describes that scenario (problem) in the form of interacting objects.
- We use Object Orientation because it helps us in mapping real world problem in a programming language.
- Object Orientation is achieved using objects and their relationships.
- Properties of an object are described using its data members and behavior of an object is described using its functions.
- Objects may be tangible (physical) or intangible (also called conceptual or virtual).
- Generally when we have given a certain problem description, nouns in that problem description are candidates for becoming objects of our system.
- There may be more than one aspects of an object
- It is not necessary that every object has a specific role in implementation of a problem there may be some objects without any role, like school parking in our school.
- It is easier to develop programs using Object Oriented Programming because it is closer to real life.