ELEMENTS OF THE OBJECT MODEL:
Object model is the conceptual frame work for all things of object oriented. There are four major
elements of object model.
They are:
1. Abstraction
2. Encapsulation
3. Modularity
4. Hierarchy
1. Abstraction
Abstraction focuses on exposing only the essential features of an object while hiding the
implementation details.
Type Description
Represents something from the real or problem world (e.g., sensor,
Entity Abstraction
crop, account).
Groups related actions that perform similar tasks (e.g., sorting
Action Abstraction
operations).
Virtual Machine Encapsulates a set of operations used by higher-level control logic (e.g.,
Abstraction operating system, compiler).
Coincidental Groups unrelated operations together — poor design.
Abstraction
EXAMPLE:
2. Encapsulation
Encapsulation is the process of binding both attributes and methods together within a class.
Through encapsulation, the internal details of a class can be hidden from outside. It permits the
elements of the class to be accessed from outside only through the interface provided by the class.
EXAMPLE:
class Car {
private:
int speed; // Encapsulated data
public:
void setSpeed(int s) { speed = s; }
int getSpeed() { return speed; }
};
3.Modularity .
Modularization consists of dividing a program into modules which can be compiled separately, but which
have connections with other modules. Modularity is the property of a system that has been
decomposed into a set of cohesive and loosely coupled modules.
- modules can be compiled separately. modules in C++ are nothing more than separately compiled files,
generally called header files.
EXAMPLE:
A Car class can have separate modules for Engine, Wheels, and Transmission.
4. Hierarchy
Definition: Hierarchy establishes relationships between classes, such as
inheritance, where a derived class inherits properties and behaviors from a base
class.
SINGLE INHETITAE MULTI
There are three minor elements of the object model:
1. Typing
2. Concurrency
3. Persistence
1. Typing
Typing defines and enforces the kind of values (type) that an object or variable can
hold.
A type is a precise characterization of the structural or behavioral properties that a
collection of entities share.
In OOP, the class implements a type, so the words class and type are often used
interchangeably.
Feature Static Typing Dynamic Typing
Types of all variables are fixed at
Definition Types are determined at runtime.
compile time.
Also Known As Early binding / Static binding Late binding / Dynamic binding
When Checked Compile time Run time
Example
C++, Java Smalltalk, Python, JavaScript
Languages
Greater flexibility, polymorphism
Advantages Faster execution, early error detection
support
Disadvantages Less flexible More runtime errors possible
2. Concurrency
Concurrency refers to the ability of a system to perform multiple tasks at the same
time or to manage multiple threads of control that operate independently but may
interact.
In Object-Oriented Programming (OOP), concurrency focuses on process abstraction
and synchronization — in contrast to OOP’s usual focus on data abstraction,
encapsulation, and inheritance.
3. Persistence:
Persistence is the property of an object through which its existence transcends time and or space i.e.
objects continues to exist after its creator ceases to exist and/or the object's location moves from the
address space in which it was created. An object in software takes up some amount of space and exists
for a particular amount of time. Object persistence encompasses the followings.
• Transient results in expression evaluation
• Local variables in procedure activations
• Global variables where exists is different from their scope
• Data that exists between executions of a program
• Data that exists between various versions of the program
• Data that outlines the Program.