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

? Classes and Objects

Uploaded by

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

? Classes and Objects

Uploaded by

abinayaponvel05
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

📘 The Object Model – Detailed Notes

❖ What Is the Object Model?


 The Object Model is the conceptual framework of object-oriented technology.
 It brings together key principles:
o Abstraction
o Encapsulation
o Modularity
o Hierarchy
o Typing
o Concurrency
o Persistence

These elements work synergistically to build robust, scalable software systems.

❖ Evolution of the Object Model


📘 Programming Language Generations (Wegner’s Classification)

1️⃣ First Generation (1954–1958)

 Focus: Mathematical expressions, scientific computing


 Languages:
o FORTRAN I
o ALGOL 58
o Flowmatic
o IPLV

2️⃣ Second Generation (1959–1961)

 Focus: Algorithmic abstraction


 Features: Subroutines, block structure, file handling
 Languages:
o FORTRAN II
o ALGOL 60
o COBOL
o LISP

3️⃣ Third Generation (1962–1970)

 Focus: Data abstraction


 Languages:
o PL/1
o ALGOL 68
o Pascal
o Simula (introduced classes and data abstraction)

4️⃣ Generation Gap (1970–1980)

 Focus: Efficiency and standardization


 Languages:
o C
o FORTRAN 77

5️⃣ Object-Oriented Boom (1980–1990)

 Focus: Pure object-oriented design


 Languages:
o Smalltalk 80
o C++
o Ada83
o Eiffel

6️⃣ Emergence of Frameworks (1990–Today)

 Focus: GUI, portability, enterprise computing


 Technologies:
o Visual Basic
o Java & J2EE
o Python
o .NET Framework
o Visual C#
o Visual Basic .NET

❖ Topology of Programming Languages


📘 First & Second Generation

 Programs built from subprograms and data blocks


 Errors in one part affect the whole system

📘 Late Second & Third Generation

 Introduced structured programming


 Subprograms used as abstraction mechanisms
 Supported parameter passing

📘 Late Third Generation

 Supported modular structure


 Allowed independent compilation of program parts

📘 Object-Oriented Languages

 Introduced data-driven design


 Modules represent logical collections of classes and objects
 Shift from verbs (procedures) to nouns (objects)

❖ Foundations of the Object Model


Key Contributions:
1. Computer Architecture
o Capability systems
o OS-level support
2. Programming Languages
o Simula, Smalltalk, CLU, Ada
3. Programming Methodology
o Modularization
o Information hiding
4. Database Models
o Persistent object storage
5. Artificial Intelligence
o Intelligent object behavior
6. Philosophy & Cognitive Science
o Real-world modeling and abstraction

❖ Object-Oriented Phases
1️⃣ OOA – Object-Oriented Analysis

 Phase: Requirement gathering


 Focus: Analyze system using classes and objects
 Goal: Build a real-world model of the problem domain

2️⃣ OOD – Object-Oriented Design

 Phase: User requirement


 Focus: Identify objects and their relationships
 Goal: Create logical and physical models using object decomposition

3️⃣ OOP – Object-Oriented Programming

 Phase: System implementation


 Focus: Write programs as collections of objects
 Requirements:
o Objects with named operations and hidden state
o Objects have types (classes)
o Classes support inheritance
Would you like this turned into a printable chart, visual diagram, or a quiz to reinforce your
understanding?

📘 Major Elements of Object Model


These are the four core pillars of object-oriented thinking:

1️⃣ Abstraction

 What it means:
Abstraction means showing only the important details and hiding the unnecessary ones.
It helps you focus on what an object does, not how it does it.
 Why it's useful:
It simplifies complex systems and helps you think clearly.
 Types of Abstraction:
o Entity Abstraction: Represents real-world things.
Example: A TemperatureSensor object with properties like temperature and
location.
o Action Abstraction: Represents operations or actions.
Example: A sort() method that sorts data.
o Virtual Machine Abstraction: Groups operations for higher-level control.
Example: A GraphicsEngine that handles drawing, shading, etc.
o Coincidental Abstraction: Random grouping of unrelated operations (not
recommended).

2️⃣ Encapsulation

 What it means:
Encapsulation means wrapping data and methods together inside a class and hiding
internal details from outside access.
 Why it's useful:
It protects data and ensures that objects are used correctly.
 Example:
A BankAccount class with a private balance variable. You can only access or change it
using methods like deposit() or withdraw().
3️⃣ Modularity

 What it means:
Modularity means dividing a program into separate modules (like building blocks),
each handling a specific part of the system.
 Why it's useful:
It makes code easier to manage, test, and reuse.
 Example:
In a Hydroponics Gardening System:
o One module handles GrowingPlans (like FruitGrowingPlan,
GrainGrowingPlan)
o Another module handles the User Interface
 In C++:
o .h files → interface (header files)
o .cpp files → implementation

4️⃣ Hierarchy

 What it means:
Hierarchy means organizing classes in levels, where some classes are more general and
others are more specific.
 Types of Hierarchy:
o Inheritance ("is-a"):
Example: FruitGrowingPlan is a type of GrowingPlan.
o Aggregation ("part-of"):
Example: A Garden contains Plants and a GrowingPlan. These are part of the
garden.
 Why it's useful:
It helps reuse code and organize relationships between classes.

📘 Minor Elements of Object Model


These are supporting features that enhance object-oriented design:

1️⃣ Typing

 What it means:
Typing ensures that objects are used correctly based on their type.
 Types:
o Strong Typing: Strict rules; prevents errors.
Example: You can't add a number to a string.
o Weak Typing: More flexible; can lead to errors.
 Static Typing:
Type is known at compile time (e.g., C++, Java)
 Dynamic Typing:
Type is known at runtime (e.g., Python, Smalltalk)
 Why it's useful:
Prevents bugs, improves performance, and helps document code.

2️⃣ Concurrency

 What it means:
Concurrency allows multiple objects to work independently at the same time.
 Why it's useful:
It makes programs faster and more responsive.
 Example:
ActiveTemperatureSensor checks temperature regularly and notifies the user when it
changes.
 Ways to implement:
o Language features (e.g., Ada tasks)
o Class libraries (e.g., C++ AT&T Task Library)
o Hardware interrupts (e.g., sensors triggering actions)

3️⃣ Persistence

 What it means:
Persistence means an object continues to exist even after the program ends or moves to
another location.
 Why it's useful:
It allows saving data between sessions or across versions.
 Examples:
o Saving user settings
o Storing game progress
o Keeping data in databases

📘 Summary Mnemonics
 Major Elements:
AEMH → Abstraction, Encapsulation, Modularity, Hierarchy
 Minor Elements:
TCP → Typing, Concurrency, Persistence

Would you like me to turn this into a printable chart or a quiz to test your understanding?

Absolutely, Abinaya! Here's a structured and exam-friendly summary of Applying the Object
Model, including its benefits and real-world applications. I’ve formatted it to make revision
easier and clearer.

📘 Applying the Object Model – Summary


Notes

✅Benefits of the Object Model


The Object Model offers several advantages over traditional structured programming:

1. Expressive Power

 Unlocks full potential of object-oriented languages like C++, Object Pascal, and Ada.
 Prevents misuse or underutilization of advanced language features.

2. Software Reusability

 Encourages reuse of:


o Code
o Designs
o Frameworks
 Leads to faster development and lower maintenance costs.

3. Resilience to Change

 Systems are built on stable intermediate forms.


 Easier to modify, extend, and maintain over time.

4. Natural Cognitive Mapping


 Aligns with human thinking and real-world modeling.
 Easier for non-programmers to understand object-oriented concepts.

📘 Application of the Object Model


Object-Oriented Analysis (OOA) and Object-Oriented Design (OOD) are powerful tools to
manage complexity in large systems.

📘 Real-World Domains Where Object Model Is Applied:

Domain Example Use Case


✈️ Air Traffic Control Managing aircraft data and flight paths
🎞️ Animation Modeling characters and scenes
🎞️ Business Software Insurance systems, payroll, CRM
🎞️ Business Data Processing Inventory, billing, and transaction systems
🎞️ CAD Designing mechanical or architectural models
🎞️ Databases Object-relational mapping, data modeling
🎞️ Expert Systems AI-based decision-making tools
🎞️ Office Automation Document management, scheduling systems
🎞️ Robotics Modeling sensors, actuators, and control logic
🎞️ Telecommunication Call routing, network management
🎞️ Telemetry Systems Remote data collection and monitoring

Would you like me to turn this into a visual mind map or flashcards for quick revision? Or
maybe a mini case study showing how OOP is used in one of these domains like animation or
robotics?

📘 Classes and Objects – Detailed Notes

1. What is a Class?
 A class is a blueprint or template for creating objects.
 It defines:
o Attributes (properties or variables)
o Methods (functions or behaviors)

Example:

class Car {
String color;
int speed;

void drive() {
// driving logic
}
}

2. What is an Object?
 An object is a real instance of a class.
 It has:
o State → values of its attributes
o Behavior → actions it can perform
o Identity → unique existence in memory

Example:

Car myCar = new Car();


myCar.color = "Red";
myCar.speed = 60;

3. Nature of an Object
✅ State

 Represents current values of attributes.


 Changes based on actions or events.
✅ Behavior

 Defined by methods.
 Depends on current state.

✅ Identity

 Each object is unique, even if it has the same data.

4. State of an Object
 Includes all data stored in the object.
 Can change over time.

Example: VendingMachine object:

 moneyInserted = 10
 selectedDrink = "Cola"

5. Behavior of an Object
 Behavior is how an object acts or reacts.
 Depends on state and method called.

Example:

 If money < price → no action


 If money ≥ price → dispense drink

6. Operations on Objects
Type Description Example
Modifier Changes object’s state deposit(), append()
Selector Reads state without changing it getBalance(), length()
Iterator Accesses all parts in order forEachItem()
Constructor Creates and initializes object new BankAccount()
Destructor Destroys or cleans up object delete account

7. Roles and Responsibilities


 Role: How an object behaves in a context.
 Responsibilities: Tasks or services the object performs.

Examples:

 BankAccount: deposit/withdraw, report dividends


 Person: parent, doctor, gardener

8. Identity of an Object
 Identity makes each object distinct.
 Even identical data ≠ same object.

Example:

DisplayItem item1 = new DisplayItem();


DisplayItem item2 = item1;
DisplayItem item3 = new DisplayItem();
9. Relationship Among Objects
 Objects interact by calling each other’s methods.

Example: Customer object calls deposit() on BankAccount object.

10. Nature of a Class


 Defines structure and behavior of objects.

Example:

class Employee {
String name;
int id;
void work() { ... }
}

11. Relationship Among Classes


✅ Inheritance ("is-a")

 One class inherits from another.


 Example: FruitGrowingPlan is a GrowingPlan

✅ Aggregation ("part-of")

 One class contains another.


 Example: Garden has Plants and GrowingPlan

12. Interplay of Classes and Objects


 Classes define rules.
 Objects are players that follow those rules.

13. Identifying Classes and Objects


 Nouns → likely classes
 Verbs → likely methods

Example:

 Classes: Book, Member, Librarian


 Methods: borrowBook(), returnBook()

14. Importance of Proper Classification


 Organizes code
 Improves understanding
 Avoids duplication

15. Key Abstractions and Mechanisms


 Focus on real-world entities and interactions
 Use:
o Abstraction
o Encapsulation
o Inheritance
o Polymorphism
Thanks for sharing that, Abinaya! Here's a clear, point-by-point explanation of Relationships
Among Objects in Object-Oriented Programming, formatted for easy understanding and exam
preparation. You can copy this directly into a document or notebook.

📘 Relationships Among Objects – Detailed Notes

❖ Overview
 Objects collaborate with each other to make a system work.
 Their relationships define how they communicate, depend, and interact.
 Two main types of relationships:
o Links
o Aggregation

1️⃣ Links
📘 What is a Link?

 A link is a connection between two objects.


 It allows one object (the client) to use the services of another (the supplier).
 It represents message passing or navigation between objects.

📘 Message Direction

 Usually unidirectional (one-way)


 Can be bidirectional (two-way communication)

📘 Roles in a Link

Role Description
Operates on other objects, but is not operated on. Often an
Controller
active object.
Server Only receives operations; does not act on others.
Can both send and receive operations. Represents a real-
Proxy
world object.

📘 Example:
In a control system:

 FlowController → Controller
 DisplayPanel → Server
 Valve → Proxy

2️⃣ Visibility Between Objects


For one object to send a message to another, the second object must be visible to the first. There
are four ways this can happen:

Visibility Type Description


Global Object Supplier is globally accessible to the client
Parameter in Operation Supplier is passed as a parameter
Part of Client Object Supplier is a member of the client object
Supplier is declared inside a method of the
Locally Declared in Operation
client

3️⃣ Synchronization Between Objects


When objects exchange messages, they must be synchronized to avoid conflicts. There are
three approaches:

Type Description
Sequential Only one active object interacts with the passive object at a time
Multiple active objects interact, but must coordinate (mutual
Guarded
exclusion)
Concurrent Passive object handles multiple threads safely on its own

4️⃣ Aggregation
📘 What is Aggregation?

 Aggregation is a whole/part relationship between objects.


 It allows navigation from the whole (aggregate) to its parts.
 It may or may not involve physical containment.

📘 Examples:
Whole Object Part Objects Type of Aggregation
Wings, landing
Airplane Physical containment
gear, cockpit
Shareholder Shares owned Logical relationship

📘 Difference Between Link and Aggregation

Feature Link Aggregation


Peer-to-peer or
Relationship Whole/part hierarchy
client/supplier
Navigation Between objects From whole to parts
May imply physical or logical
Containment Not implied
containment

You might also like