0% found this document useful (0 votes)
10 views6 pages

Object oriented analysis design & C++

The document defines the object model as a framework representing the structure, behavior, and interactions of objects in a system, highlighting key concepts such as classes, relationships, and the evolution of object-oriented programming. It outlines the historical development from procedural programming to modern object models, including the introduction of UML and design patterns. Additionally, it explains various object relationships, including association, aggregation, composition, inheritance, and dependency, which are essential for modeling real-world scenarios in software design.

Uploaded by

chappisumaiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

Object oriented analysis design & C++

The document defines the object model as a framework representing the structure, behavior, and interactions of objects in a system, highlighting key concepts such as classes, relationships, and the evolution of object-oriented programming. It outlines the historical development from procedural programming to modern object models, including the introduction of UML and design patterns. Additionally, it explains various object relationships, including association, aggregation, composition, inheritance, and dependency, which are essential for modeling real-world scenarios in software design.

Uploaded by

chappisumaiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Unit -1

Object model
Define object model?
An object model is a conceptual framework that represents the structure, behaviour,
and interactions of objects within a system. It encapsulates data (attributes) and
methods (functions) that operate on the data, using objects as instances of classes.
Key Points:
Objects and Classes: Objects are instances of classes, which define attributes (state) and
methods (behaviour).
Relationships: Objects can have relationships like association, inheritance, and
composition, helping model interactions in a system.
Evolution of the Object Model
The object model has evolved significantly over time, reflecting changes in how
software development approaches and systems are designed. It has grown from early
ideas of abstraction to become a central concept in modern programming. Here's a
breakdown of its evolution:
Pre-Object-Oriented Programming (Before 1960s)
Procedural Programming: Before the concept of objects, programming was procedural,
meaning that programs were written as a sequence of instructions (functions or
procedures) that operated on data. There was no concept of encapsulating data and
behavior together.
Languages: Early languages like Fortran, ALGOL, and COBOL focused on procedural
logic, where data and functions were separate, making it difficult to manage large and
complex systems.
Limitations: Procedural models often led to difficulties in managing the complexity of
large systems and reusing code.
The Birth of Object-Oriented Programming (1960s–1970s)
Simula (1967): The first object-oriented language, Simula, developed by Ole-Johan Dahl
and Kristen Nygaard at the Norwegian Computing Center (Norsk Regnesentral). Simula
introduced key concepts like objects, classes, inheritance, and encapsulation, marking
the beginning of object-oriented programming.
Simula's main innovation was modeling real-world entities (like cars, people, etc.) as
objects with both data and behavior, representing a shift away from purely functional
approaches.
The Rise of Object-Oriented Programming Languages (1980s–1990s)
C++ (1983): Created by Bjarne Stroustrup, C++ combined object-oriented features with
the procedural programming model of C. This allowed developers to write object-
oriented code while still leveraging the performance of procedural code.
C++ introduced class-based inheritance, polymorphism, and encapsulation to
mainstream software development, making OOP widely adopted in industry.
Object-Oriented Analysis and Design (OOAD): In the 1980s and 1990s, Object-
Oriented Analysis and Design (OOAD) became an important approach for designing
software systems. This method helped define how objects in a system should interact
and evolve, focusing on defining objects, their attributes, and behaviors before moving
on to implementation.
Grady Booch (Booch method) and Objectory (later UML) were important contributors
to formalizing object-oriented design.
Standardization and Visual Modeling (1990s–2000s)
Unified Modeling Language (UML) (1997): With the rise of large-scale object-oriented
systems, the need for standard ways to represent object models visually became clear.
UML was created as a standard modeling language to visualize, specify, construct, and
document the artifacts of object-oriented systems.
UML provided a common language for describing object models using diagrams like
class diagrams, object diagrams, sequence diagrams, and use case diagrams. This helped
standardize the way developers communicate object-oriented designs.
Design Patterns: In the 1990s, Design Patterns popularized by Gang of Four (Gamma,
Helm, Johnson, and Vlissides) helped standardize solutions to common object-oriented
design problems (e.g., Singleton, Factory, Observer, etc.). Design patterns made object
modeling more flexible, maintainable, and reusable.
Modern Object Models (2000s–Present)
Functional-Object Hybrid Models: With the rise of languages like Scala, Kotlin, and
Swift, the boundaries between functional programming and object-oriented
programming have blurred. These languages allow both immutable objects and higher-
order functions to coexist, offering a hybrid approach to software design.
Functional programming concepts like pure functions, immutability, and laziness are
increasingly being incorporated into object-oriented systems, leading to more modular
and scalable software architectures.
Applying the object model
Applying the object model refers to the practical use of object-oriented principles in
designing and implementing software systems. This involves defining objects, classes,
and their interactions to represent real-world entities and their behaviors in a
structured way.
Key steps in applying the object model:
Define Classes and Objects: Identify real-world entities and translate them into
classes. Each class represents a blueprint for creating objects (instances). For example,
in a Library System, classes could include Book, User, and Library.
Encapsulation: Bundle data (attributes) and behavior (methods) into classes. Ensure
that objects hide their internal state and provide methods to access or modify it. For
example, a Bank Account class might have private balance and public methods like
deposit() and withdraw() to interact with it.
Inheritance: Create hierarchies by defining subclasses that inherit properties and
behaviors from parent classes. For example, a SavingsAccount class can inherit from
BankAccount but add specific behaviour’s like interstate.
Polymorphism: Allow different objects to be treated as instances of the same class
through shared methods. This enables flexibility and reusability. For example, a draw()
method could be used for both Circle and Rectangle objects, even though their internal
behavior is different.
Relationships: Model how objects interact with each other, such as using association,
aggregation, or composition.
Objects and class
Class:
A class is a blueprint or template for creating objects. It defines the structure
(attributes/properties) and behaviour (methods/functions) that the objects created
from it will have.
A class itself does not hold data but defines what data the objects (instances) will hold.
A class can also define methods to manipulate or operate on the data (attributes) it
holds.
Example:
In a Car class:
Attributes: color, make, model
Methods: start(), accelerate(), stop()
Object:
An object is an instance of a class. When a class is defined, no memory is allocated.
However, when an object is created from that class, it represents a specific instance of
the class with its own unique data (attributes).
Objects interact with each other by calling methods defined in their classes.
Example:
Python
# Create an object (instance) of the Car class
my_car = Car("red", "Toyota", "Camry")
# calling methods on the object
my_car.start() # Output: The red Toyota Camry is starting.
my_car.stop() # Output: The red Toyota Camry is stopping.
Nature of Object Relationships Among Objects
In object-oriented programming (OOP), objects don't exist in isolation. They interact
with each other in various ways to model complex real-world scenarios. The
relationships between objects are fundamental to designing a system that is modular,
scalable, and maintainable. The nature of these relationships can be broadly classified
into the following types:
1. Association
Definition: Association represents a general relationship between two objects, where
one object uses or interacts with another. It is a "has-a" or "uses-a" relationship.
Nature: The objects in an association are independent of each other, meaning they can
exist independently. This relationship is often bidirectional, though it can be one-
directional as well.
Example: A Teacher and a Student. A Teacher teaches a Student, and a Student is
taught by a Teacher.
In code:
python
class Teacher:
def __init__(self, name):
self.name = name
def teach(self):
print(f"{self.name} is teaching.")
class Student:
def __init__(self, name):
self.name = name
def learn(self):
print(f"{self.name} is learning.")
Association: A teacher teaches a student
teacher = Teacher("Mr. Smith")
student = Student("John")
teacher.teach() # Mr. Smith is teaching.
student.learn() # John is learning.
2. Aggregation
Definition: Aggregation is a special form of association that represents a "whole-part"
relationship where one object is a part of another, but the part can exist independently
of the whole. The whole can contain multiple parts.
Nature: It is a has-a relationship, but the parts (objects) are not tightly bound to the
whole object. If the whole is destroyed, the parts can continue to exist.
Example: A Library and Books. A Library has many Books, but the Books can exist
independently of the Library (i.e., if the Library is destroyed, the Books can still exist
elsewhere).
In code:
python
class Book:
def __init__(self, title):
self.title = title
class Library:
def __init__(self):
self.books = []
def add_book(self, book):
self.books.append(book)
Aggregation: A Library contains Books
book1 = Book("The Great Gatsby")
book2 = Book("1984")
library = Library()
library.add_book(book1)
library.add_book(book2)
3. Composition
Definition: Composition is a stronger form of aggregation where the lifetime of the part
is managed by the whole. If the whole object is destroyed, the parts are also destroyed.
It represents a strong "has-a" or "part-of" relationship.
Nature: In composition, the part cannot exist independently of the whole. It is a tighter
relationship than aggregation.
Example: A House and Room. A Room is a part of a House, and without a House, a Room
doesn’t exist (i.e., if the House is destroyed, the Room is also destroyed).
In code:
class Room:
def __init__(self, room_name):
self.room_name = room_name
class House:
def __init__(self):
self.rooms = []
def add_room(self, room_name):
room = Room(room_name)
self.rooms.append(room)
Composition: A House contains Rooms
house = House()
house.add_room("Living Room")
house.add_room("Bedroom")
4. Inheritance
Definition: Inheritance represents an "is-a" relationship where one object (the
subclass) inherits attributes and behaviours (methods) from another object (the
superclass). It allows a new class to take on the characteristics of an existing class,
promoting code reuse.
Nature: Inheritance is a hierarchical relationship where the child class (subclass)
extends or modifies the behaviour of the parent class (superclass).
class Animal:
def speak(self):
print("Animal speaks")
class Mammal(Animal):
def walk(self):
print("Mammal walks")
class Dog(Mammal):
def bark(self):
print("Dog barks")
Inheritance: Dog inherits from Mammal, and Mammal inherits from Animal
dog = Dog()
dog.speak() # Animal speaks
dog.walk() # Mammal walks
dog.bark() # Dog barks
5. Dependency
Definition: Dependency represents a "uses" relationship between objects where one
object depends on another to function properly, but the dependent object does not own
or directly control the other.
Nature: It is a weaker relationship than association, meaning that the dependent object
may only use the other object temporarily or intermittently.
Example: A Car object might depend on a Fuel object. The Car uses the Fuel to run, but
the Fuel is not owned or controlled by the Car.
class Fuel:
def __init__(self, type):
self.type = type
class Car:
def __init__(self):
self.fuel = None
def add_fuel(self, fuel):
self.fuel = fuel
print(f"Fuel of type {self.fuel.type} added to car")
Dependency: Car depends on Fuel
fuel = Fuel("Diesel")
car = Car()
car.add_fuel(fuel)
Nature of Object Relationships (Short)
In object-oriented programming (OOP), objects interact with each other through
different types of relationships. These relationships define how objects are connected
and how they communicate within a system. The main types of object relationships are:
Association: A general relationship where one object uses or interacts with another. It
is a "has-a" relationship but the objects can exist independently.
Example: A Teacher teaches a Student.
Aggregation: A "whole-part" relationship where the part can exist independently of the
whole. It represents a "has-a" relationship, but the part can live on its own.
Example: A Library has many Books, but books can exist independently.
Composition: A stronger form of aggregation where the part cannot exist without the
whole. If the whole object is destroyed, the part is destroyed as well.
Example: A House contains Rooms, and rooms cannot exist without the house.
Inheritance: A hierarchical relationship where one object (subclass) inherits attributes
and behaviors from another (superclass). It represents an "is-a" relationship.
Example: A Dog is-a Mammal.
Dependency: A relationship where one object depends on another to function, often
temporarily. It represents a "uses-a" relationship.
Example: A Car depends on Fuel to run.
Each of these relationships helps to define how objects in a system are structured and
how they interact with one another.

You might also like