Unit 1
Unit 1
Ghaziabad
Introduction: The meaning of Object Orientation, object identity, Encapsulation, information hiding, polymorphism,
generosity, importance of modelling, principles of modelling, object oriented modelling, Introduction to UML, conceptual
model of the UML, Architecture.
1. What is modeling?
A model is an abstraction of something for the purpose of understanding it before building it. Because, real systems that
we want to study are generally very complex. In order to understand the real system, we have to simplify the system.
2. Why do we model?
We build models so that we can better understand the system we are developing.
3. Importance of Modeling
1. The right models will highlight the most critical development problems. Wrong models will mislead you,
causing you to focus on irrelevant issues.
For Example: We can use different types of diagrams for different phases in software development.
4. No single model is sufficient. Every non-trivial system is best approached through a small set of nearly independent
models.
6. Objects are instances of classes. They contain data and provides services. The data forms the attributes of the
object. The services are known as methods (also known as operations or functions).
7. Object Identity
Means that every object is unique and can be differentiated from other objects .Each time and object is created
the object identity is defined.
8. Encapsulation in OOP Meaning: Encapsulation refers to the bundling of data, along with the methods that
operate on that data, into a single unit.
9. Object-Oriented Modeling
1. algorithms perspective.
2. object –oriented perspective.
In algorithms perspective main building block of all software is the procedure or function.This view leads
developers to focus on issues of control and the decomposition of larger algorithms into smaller ones.As
requirements change,it is very hard to maintain.
10. Objects Oriented Modeling Phases
• System Analysis
• System Design
• Object Design, and
• Final Implementation.
System Analysis
In this phase, the developer interacts with the user of the system to find out the user requirements and analyses
the system to understand the functioning of it. Based on this system study, the analyst prepares a model of the
desired system. This model is purely based on what the system is required to do.
System Design: At this stage, the complete system architecture is designed. This is the stage where the whole
system is divided into subsystems, based on both the system analysis model and the proposed architecture of
the system.
Object design decides the data structures and algorithms needed to implement each of the classes in the system withthe
help of implementation details given in the analysis model.
Final Implementation: At this stage, the final implementation of classes and relationships developed during object
design takes place a particular programming language, database, or hardware implementation (if needed).
Whole object oriented modeling is covered by using three kinds of models for a system description. These models are:
• object model,
• dynamic model, and
• functional model.(Discuss Later)
11. Advantages of Object Oriented Modeling
The systems designed using OOM are closer to the real world.
OOM designs encourage more reusability.
Reduces the development cost & time and increases quality.
Object Orientation is a modeling and development methodology based on object oriented concept.
In which each object represent a real world entity with the ability to interact itself and with other objects
Abstraction
In system development, Abstraction helps to focus on what an object is supposed to do, before deciding how it should be
implemented.
Encapsulation
Encapsulation enables you to combine data structure and behavior in a single entity. Encapsulation helps in system
enhancement. If there is a need to change the implementation of object without affecting its external nature, encapsulation
is of great help.
Polymorphism
The decision of which procedure to use is made implicitly by each object, based on its class polymorphism makes
maintenance easier because the calling code need not be modified when a new class is added.
Inheritance
13. CHARACTERISTICS OF OBJECT ORIENTED MODELING.
The notation for a class is a box with three sections. The top section contains the name of the class in boldface type,
the middle section contains the attributes(data variable) that belong to the class, and the bottom section contains the
class’s operations (Methods).
Figure shows the class Book. Attributes of Book are title, author, publisher along with their data types.
Operations on Book are open(), close(), read().
A link is a physical or conceptual connection between objects for example, a student Name XYZ study in IGNOU.
Association
It is a relation between two classes.
If two classes in a model need to communicate with each other, there must be a link between them, and that can be
represented by an association (connector).
Note that every association has roles.
Multiplicity
Multiplicity in an association specifies how many objects participate in a relationship.
Multiple students can associate with a single Department and single student can associate with multiple Departments, but
there is no ownership between the objects and both have their own lifecycle. Both can create and delete independently
Aggregation (whole/part)
It is type of Association.
It is telling about ownership.
Department Teacher
Math t1
Science t2
IT t3
#include <iostream>
using namespace std;
class X
{
private:
int d;
public:
void set_value(int k)
{
d=k;
void show_sum(int n)
{
cout<<"sum of "<<d<<" and "<<n<<" = "<<d+n<<endl;
}
};
class Y
{
public:
X a;
void print_result()
{
a.show_sum(5);
}
};
int main()
{
Y b;
b.a.set_value(20);
b.a.show_sum(100);
b.a.print_result();
}
Generalization is the relationship between a class, and it defines a hierarchy of abstraction in which subclasses (one or
more) inherit from one or more superclasses.
15 Unified Modeling Language (UML) is a general purpose modelling language. The aim of UML
is to define a standard way to visualize the system has been designed.
UML is not a programming language, it is rather a visual language. The Object Management Group
(OMG) adopted Unified Modelling Language as a standard in 1997. Its been managed by OMG ever
since. International Organization for Standardization (ISO) published UML as an approved standard
in 2005. UML has been revised over the years and is reviewed periodically.
Do we really need UML?
Complex applications need collaboration and planning from multiple teams and hence require a
clear and concise way to communicate amongst them.
Businessmen do not understand code. So UML becomes essential to communicate with non
programmers essential requirements, functionalities and processes of the system.
A lot of time is saved when teams are able to visualize processes, user interactions and static
structure of the system.
State Diagrams,
Activity Diagrams
Interaction Diagrams.
1. Class – A class defines the blue print i.e. structure and functions of an object.
2. Objects – Objects help us to decompose large systems and help us to modularize our system.
Modularity helps to divide our system into understandable components so that we can build our
system piece by piece. An object is the fundamental unit (building block) of a system which is
used to depict an entity.
3. Inheritance – Inheritance is a mechanism by which child classes inherit the properties of their
parent classes.
4. Abstraction – Mechanism by which implementation details are hidden from user.
5. Encapsulation – Binding data together and protecting it from the outer world is referred to as
encapsulation.
6. Polymorphism – Mechanism by which functions or entities are able to exist in different forms.
1.Things
A diagram can be viewed as a graph containing vertices and edges. In UML, vertices are replaced by things,
and the edges are replaced by relationships. There are four types of things in UML. They are:
Interface: Graphically interface is represented as a circle or a class symbol stereotyped with interface.
Use Case: A use case is a collection of actions, defining the interactions between a role (actor) and the
system.
Example: A use case is a written description of how users will perform tasks on your website.
collaboration
A collaboration diagram, also known as a communication diagram Describe the relationships and interactions among
software objects in the Unified Modeling Language (UML).
Active Class: A class whose objects can initiate its own flow of control (threads) and work in parallel with other
objects. Graphically active class is represented as a rectangle with thick borders.
Behavioral Things
Represents the dynamic aspects of a software system.
Interaction: A behavior made up of a set of messages exchanged among a set of objects to perform a
particular task.
State Machine: The state machine diagram is also called the Statechart or State Transition diagram, which
shows the order of states underwent by an object within the system.
Grouping Things
Package: A general purpose mechanism for organizing elements into groups. Graphically package is
represented as a tabbed folder.
Annotational Things
Note: A symbol to display comments. Graphically note is represented as a rectangle with a dog ear at the top
right corner.
Relationships
Dependency: A semantic relationship, in which a change in one thing (the independent thing) may cause
changes in the other thing (the dependent thing). This relationship is also known as “using” relationship.
Realization: Defines a semantic relationship in which one class specifies something that another class will
perform. Example: The relationship between an interface and the class that realizes or executes that interface.
Diagram –Discuss Later
Common Mechanisms
Why UML is easy to learn and use? It’s because of the four common mechanisms that apply throughout the UML. They
are:
1. Specifications
2. Adornments
3. Common divisions
4. Extensibility mechanisms
Specifications: Behind every graphical notation in UML there is a precise specification of the details that element
represents. For example, a class icon is a rectangle and it specifies the name, attributes and operations of the class.
Adornments: The mechanism in UML which allows the users to specify extra information with the basic
notation of an element is the adornments.
In the above example, the access specifiers: + (public), # (protected) and – (private) represent the visibility of
the attributes which is extra information over the basic attribute representation.
Common Divisions: In UML there is clear division between semantically related elements like: separation
between a class and an object and the separation between an interface and its implementation.
Extensibility Mechanisms
The extensibility mechanisms in UML are:
Stereotypes – Extends the vocabulary of UML. Allows users to declare new building blocks (icons) or extend the
basic notations
Tagged Values – Extends the properties of an UML building block. Allows us to specify extra information in the
elements specification. Represented as text written inside braces and placed under the element name. The general
syntax of a property is: { property name = value }
Constraints – Extends the semantics of a UMLs building block such as specifying new rules or modifying existing
rules. Represented as text enclosed in braces and placed adjacent or beside the element name.