Learning & Knowledge Education - India
© 2007 IBM Corporation
Object Oriented
Programming
Learning & Knowledge Education - India
© 2007 IBM Corporation
2
Day 1
Learning & Knowledge Education - India
© 2007 IBM Corporation
3
Object
Oriented (OO)
• People often use the acronym OO to stand for anything object-
oriented, yielding acronyms such as the following:
• OOP - Object-oriented programming
• OOA - Object-oriented analysis
• OOD - Object-oriented design
Learning & Knowledge Education - India
© 2007 IBM Corporation
4
History of Object Oriented Programming.
• OOP concepts started surfacing in the mid-1960s with a
programming language called Simula.
• It further evolved in the 1970s with advent of Smalltalk.
• A resurgence of interest in object-oriented methodologies
occurred in the mid-1980s. Specifically, OOP languages such as
C++ and Eifle became popular with mainstream computer
programmers
• OOP continued to grow in popularity in the 1990s, most notably
with the advent of Java.
• In 2002, in conjunction with the release of the .NET Framework,
Microsoft introduced a new OOP language, C#
Learning & Knowledge Education - India
© 2007 IBM Corporation
5
Procedural Programming
• Procedural languages organize the program in a linear fashion—
they run from top to bottom.
• In other words, the program is a series of steps that run one after
another.
• This type of programming worked fine for small programs that
consisted of a few hundred code lines, but as programs became
larger, they became hard to manage and debug.
Learning & Knowledge Education - India
© 2007 IBM Corporation
6
Structured Programming
• In an attempt to manage the ever-increasing size of the programs, structured
programming was introduced to break down the code into manageable
segments called functions or procedures.
• This was an improvement, but as programs performed more complex
business functionality and interacted with other systems, the shortcomings of
structural programming methodology began to surface:
Programs became harder to maintain.
Existing functionality was hard to alter without adversely affecting all of
the system’s functionality.
New programs were essentially built from scratch. Consequently, there
was little return on the investment of previous efforts.
Programming was not conducive to team development. Programmers
needed to know every aspect of how a program worked and could not
isolate their efforts on one aspect of a system.
It was hard to translate business models into programming models.
Learning & Knowledge Education - India
© 2007 IBM Corporation
7
Benefits of Object Oriented Programming
• A more intuitive transition from business analysis models to software
implementation models
• The ability to maintain and implement changes in the programs more
efficiently and rapidly
• The ability to more effectively create software systems using a team
process, allowing specialists to work on parts of the system
• The ability to reuse code components in other programs and purchase
components written by third-party developers to increase the
functionality of programs with little effort
• Better integration with loosely coupled distributed computing systems
• Improved integration with modern operating systems
• The ability to create a more intuitive graphical user interface for the
users
Learning & Knowledge Education - India
© 2007 IBM Corporation
8
What is an Object?
• An object is a software construct that encapsulates data, along
with the ability to use or modify that data, into a software entity.
• An object is a self-contained entity which has its own private
collection of properties (ie. data) and methods (ie. operations) that
encapsulate functionality into a reusable and dynamically loaded
structure.
Learning & Knowledge Education - India
© 2007 IBM Corporation
9
• Object-Oriented Programming :
A large application consists of component objects, which
interact with each other.
Can be used to develop various applications.
About Object Oriented Programming
Learning & Knowledge Education - India
© 2007 IBM Corporation
10
What is an Object (Continued)
• An object has:
 state
 behavior
the structure and behavior of similar objects are defined in
their common class.”
Learning & Knowledge Education - India
© 2007 IBM Corporation
11
Example
MyCar
Accelerate
Brake
Change Gear
brand : Maruti
speed : 45 kmph
gear : 3rd
wheels : 4
color : White
Learning & Knowledge Education - India
© 2007 IBM Corporation
12
What is an Object Oriented Program
• An Object-Oriented Program consists of a group of cooperating
objects, exchanging messages, for the purpose of achieving a
common objective.
Learning & Knowledge Education - India
© 2007 IBM Corporation
13
What is a Class?
• A class is a blueprint or prototype that defines the variables and the
methods common to all objects of a certain kind.
 blueprint: A class can't do anything on its own.
 defines: A class provides something that can be used later.
 objects: A class can only be used, if it had been "brought to life" by
instantiating it.
Learning & Knowledge Education - India
© 2007 IBM Corporation
14
Example
A Car
Accelerate
Brake
Change Gear
brand
speed
gear
wheels
color
Learning & Knowledge Education - India
© 2007 IBM Corporation
15
Methods
• An operation upon an object, defined as part of the declaration of a
class.
• The methods, defined in a class, indicate, what the instantiated
objects are able to do.
Learning & Knowledge Education - India
© 2007 IBM Corporation
16
Example
A Car
brand: Maruti
speed: 45 kmph
gear: 3rd
wheels: 4
color: White
Driver
Driver wants to increase the speed of the car?
speed: 50 kmph
Accelerate
Brake
Change Gear
Learning & Knowledge Education - India
© 2007 IBM Corporation
17
Question
A Car
brand: Maruti
speed: 50 kmph
gear: 3rd
wheels: 4
color: White
Driver
Driver wants to decrease the speed of the car?
Click To
Know
The
Answer
Accelerate
Brake
Change Gear
Learning & Knowledge Education - India
© 2007 IBM Corporation
18
Answer
A Car
brand: Maruti
speed: 50 kmph
gear: 3rd
wheels: 4
color: White
Driver
Driver wants to decrease the speed of the car?
speed: 45 kmph
Accelerate
Brake
Change Gear
Learning & Knowledge Education - India
© 2007 IBM Corporation
19
• Real-world programming
• Reusability of code
• Modularity of code
• Information hiding
Advantages of OOP
Learning & Knowledge Education - India
© 2007 IBM Corporation
20
• Encapsulation
• Inheritance
• Polymorphism
Features of OOPS
Learning & Knowledge Education - India
© 2007 IBM Corporation
21
• Encapsulation is the ability of an object to place a boundary around its
properties (ie. data) and methods (ie. operations).
• Grady Booch, defined the encapsulation feature as:
“Encapsulation is the process of hiding all of
the
details of an object that do not contribute to
its
essential characteristics.”
Encapsulation
Learning & Knowledge Education - India
© 2007 IBM Corporation
22
Encapsulation (Example)
MyCar
brand: Maruti
speed: 45 kmph
gear: 3rd
wheels: 4
color: White
Other object
Access Denied
Access Allowed
Accelerate
Brake
Change Gear
Learning & Knowledge Education - India
© 2007 IBM Corporation
23
“An Abstraction denotes the essential characteristics of an
object that distinguishes it from all other kinds of objects
and thus provides crisply defined conceptual boundaries,
relative to the perspective of the viewer.”
Abstraction
Encapsulation hides the irrelevant details of an
object and Abstraction makes only the relevant
details of an object visible.
Learning & Knowledge Education - India
© 2007 IBM Corporation
24
• Inheritance is the capability of a class to use the properties
and methods of another class while adding its own
functionality.
• Enables you to add new features and functionality to an
existing class without modifying the existing class.
Inheritance
Learning & Knowledge Education - India
© 2007 IBM Corporation
25
• Superclass and Subclass
A superclass or parent class is the one from which another
class inherits attributes and behavior.
A subclass or child class is a class that inherits attributes
and behavior from a superclass.
Inheritance (Continued)
Learning & Knowledge Education - India
© 2007 IBM Corporation
26
Employee
Secretary
Manager Programmer
Inheritance (Continued)
Learning & Knowledge Education - India
© 2007 IBM Corporation
27
• Single inheritance
Subclass is derived from only one superclass.
Types of Inheritance
Super class
/Base Class
(Parent)
Sub class
/Derived Class
(Child)
Learning & Knowledge Education - India
© 2007 IBM Corporation
28
• Multiple Inheritance
A subclass is derived from more than one super class.
Types of Inheritance (Continued)
Super Class
(Parent 1)
Super Class
(Parent 2)
Sub Class
(Child)
Learning & Knowledge Education - India
© 2007 IBM Corporation
29
• Derived from two Latin words - Poly, which means many, and
morph, which means forms.
• It is the capability of an action or method to do different things
based on the object that it is acting upon.
• In object-oriented programming, polymorphism refers to a
programming language's ability to process objects differently
depending on their data type or class.
Polymorphism
Learning & Knowledge Education - India
© 2007 IBM Corporation
30
Object Model
• The insight of object oriented programming is to combine the
state and behavior in a unit called an Object.
• A program consists of a network of interconnected objects that
call upon each other to solve a part of the puzzle.
• Each object has a specific role to play in the overall design of the
program and is able to communicate with other objects. Objects
communicate through messages, requests to perform a method.
Learning & Knowledge Education - India
© 2007 IBM Corporation
31
Basic questions while developing an OOP application
• What objects does the
application need???
• What functionality
should those objects
have????
Learning & Knowledge Education - India
© 2007 IBM Corporation
32
Objects are grouped into classes
• A class is a set of objects which share the common attributes
and common behavior.
• Classes are used to distinguish one type of object from another.
• A single object is simply an object of the class.
• The chief role of a class is to define the properties and
procedures and the applicability of its instances.
Learning & Knowledge Education - India
© 2007 IBM Corporation
33
Objects responds to Messages
• Message are non specific
function calls.
• Different Objects can respond to
the same message different
ways.
• Message is just an instruction.
• A message differs from a
function/method.
• Objects communicate with each
other via messages.
• What is a
Message???
Learning & Knowledge Education - India
© 2007 IBM Corporation
34
• The procedural programming methodology involves dividing a large
program into a set of subprocedures or subprograms that perform
specific tasks.
• The procedural programming methodology allows code reusability in
large applications.
• It emphasizes on procedures.
Summary
Learning & Knowledge Education - India
© 2007 IBM Corporation
35
• An object is defined as an instance of a class.
• In the object oriented approach, classes are designed such that they
can be reused.
• Object Oriented programming offers features such as Reusability,
Object oriented Modularity, and Information hiding.
• Encapsulation- Hides the implementation details of an object and
therefore hides its complexity.
• Abstraction- Focuses on the essential features of an object.
Summary (Continued)
Learning & Knowledge Education - India
© 2007 IBM Corporation
36
• Inheritance - Creates a hierarchy of classes and helps in reuse of
attributes and methods of a class.
• A superclass shares its attributes and behavior with its child classes.
• Polymorphism- Assigns a different meaning or usage to an entity in
different contexts.
Summary (Continued)
Learning & Knowledge Education - India
© 2007 IBM Corporation
37
1. _ _ _ _ _ programming involves a large program into a set of subprocedures or
subprograms that perform specific tasks.
a. Sequential
b. Procedural
c. Object Oriented
d. Rule-Based
2. _ _ _ _ _ among the following operates on the data.
a. Variables
b. Class
c. Method
d. All of the above
Test Your Understanding
Learning & Knowledge Education - India
© 2007 IBM Corporation
38
3. What is the acronym for OOP?
a. Object Oriented Programming
b. Object Orientation programming
c. Object Oriented Program
d. Object Oriented Procedure
4. _ _ _ _ _ _ is the concept that capsules data members and methods.
a. Abstraction
b. Polymorphism
c. Encapsulation
d. Inheritance
Test Your Understanding (Contd.)
Learning & Knowledge Education - India
© 2007 IBM Corporation
39
5. _ _ _ _ _ feature of OOPS that means ignoring the non-essential details of an
object and concentrating on its essential features?
a. Inheritance
b. Encapsulation
c. Abstraction
d. Polymorphism
6. Pick the odd one out.
a. State
b. Class
c. Behavior
d. Identity
Test Your Understanding (Contd.)
Learning & Knowledge Education - India
© 2007 IBM Corporation
40
Day 2
Learning & Knowledge Education - India
© 2007 IBM Corporation
41
Design related questions before building an application
• What classes exists and how are they related?
• How objects collaborate?
• Where should each objects be declared?
• How should multiple processes be scheduled?
Learning & Knowledge Education - India
© 2007 IBM Corporation
42
The following diagrams are used to answer the previous
questions.
• Class diagrams
• Object diagrams
• Sequence Diagrams
• Interaction diagrams
Learning & Knowledge Education - India
© 2007 IBM Corporation
43
UML
• The Unified Modeling Language (UML) is a standard language
for specifying, visualizing, constructing, and documenting the
artifacts of software systems, as well as for business modeling
and other non-software systems.
• The UML is a very important part of developing object oriented
software and the software development process.
• The UML uses mostly graphical notations to express the design
of software projects.
• Using the UML helps project teams communicate, explore
potential designs, and validate the architectural design of the
software.
Learning & Knowledge Education - India
© 2007 IBM Corporation
44
Primary goals of UML
• Provide users with a ready-to-use, expressive visual modeling language
so they can develop and exchange meaningful models.
• Provide extensibility and specialization mechanisms to extend the core
concepts.
• Be independent of particular programming languages and development
processes.
• Provide a formal basis for understanding the modeling language.
• Encourage the growth of the OO tools market.
• Support higher-level development concepts such as collaborations,
frameworks, patterns and components.
• Integrate best practices.
Learning & Knowledge Education - India
© 2007 IBM Corporation
45
Class Diagram
• Class diagrams are widely used to describe the types of objects
in a system and their relationships.
• Class diagrams model class structure and contents using design
elements such as classes, packages and objects.
• Class diagrams describe three different perspectives when
designing a system, conceptual, specification, and
implementation.
• These perspectives become evident as the diagram is created
and help solidify the design.
Learning & Knowledge Education - India
© 2007 IBM Corporation
46
Class Diagram
• A class icon is simply a rectangle divided into three
compartments. The topmost compartment contains the name of
the class.
• The middle compartment contains a list of attributes (member
variables),
• and the bottom compartment contains a list of operations
(member functions).
Class
Attribute
Operations()
Learning & Knowledge Education - India
© 2007 IBM Corporation
47
Class Diagram
• Attributes and operations may have their visibility marked as
follows:
"+" for public
"#" for protected
"-" for private
"~" for package
Learning & Knowledge Education - India
© 2007 IBM Corporation
48
Class Diagram
Circle
radius:double
center:Point
area:double
circumference:double
setRadius(double)
setCenter(Point)
Learning & Knowledge Education - India
© 2007 IBM Corporation
49
Association
• An Association represents a family of links. Binary associations
(with two ends) are normally represented as a line, with each end
connected to a class box.
• Higher order associations can be drawn with more than two
ends. In such cases, the ends are connected to a central
diamond.
• An association can be named, and the ends of an association
can be adorned with role names, ownership indicators,
multiplicity, visibility, and other properties.
• Associations can only be shown on class diagrams.
Learning & Knowledge Education - India
© 2007 IBM Corporation
50
 Each instance of type Circle seems to contain an instance of
type Point. This is a relationship known as composition
Circle
Point
Composition
Learning & Knowledge Education - India
© 2007 IBM Corporation
51
Composition (Contd.)
• The black diamond represents composition.
• It is placed on the Circle class because it is the Circle that is
composed of a Point.
• The arrowhead on the other end of the relationship denotes that
the relationship is navigable in only one direction. That is, Point
does not know about Circle.
Learning & Knowledge Education - India
© 2007 IBM Corporation
52
Composition (Contd.)
• Composition relationships are a strong form of containment or
aggregation. Aggregation is a whole/part relationship. In this
case, Circle is the whole, and Point is part of Circle.
• Composition is more than just aggregation. Composition also
indicates that the lifetime of Point is dependent upon Circle.
• This means that if Circle is destroyed, Point will be destroyed
with it.
Learning & Knowledge Education - India
© 2007 IBM Corporation
53
Inheritance
• The inheritance relationship in UML is depicted by a triangular
arrowhead.
• This arrowhead, points to the base class. One or more lines
proceed from the base of the arrowhead connecting it to the
derived classes.
Learning & Knowledge Education - India
© 2007 IBM Corporation
54
Inheritance
Shape
Erase()
Draw()
Square
Circle
Learning & Knowledge Education - India
© 2007 IBM Corporation
55
A taxonomy of people within the university
Learning & Knowledge Education - India
© 2007 IBM Corporation
56
• The weak form of aggregation is denoted with an open diamond.
This relationship denotes that the aggregate class (the class with
the white diamond touching it) is in some way the “whole”, and
the other is somehow part of the whole.
Window
Shape
Its Shapes
*
Aggregation
Learning & Knowledge Education - India
© 2007 IBM Corporation
57
Aggregation (Contd.)
• In this case, the Window class contains many Shape instances.
• In UML the ends of a relationship are referred to as its “roles”.
• Notice that the role at the Shape end of the aggregation is
marked with a “*“.
• This indicates that the Window contains many Shape instances.
• The role has been named. This is the name that Window knows
its Shape instances by i.e. it is the name of the instance variable
within Window that holds the shapes.
Learning & Knowledge Education - India
© 2007 IBM Corporation
58
Dependency
• Sometimes the relationship between a two classes is very weak.
They are not implemented with member variables at all.
• The relationship might be implemented as member function
arguments.
• Consider, for example, the Draw function of the Shape class.
Learning & Knowledge Education - India
© 2007 IBM Corporation
59
Dependency
Window
Shape
DrawingContext
itsContext
ItsShapes
*
draw(DrawingContext ctx)
Learning & Knowledge Education - India
© 2007 IBM Corporation
60
Interface
• There are classes that have nothing but pure virtual functions.
• In Java such entities are not classes at all;
• They are a special language element called an interface.
• UML has followed the Java example and has created some
special syntactic elements for such entities.
• The primary icon for an interface is just like a class except that it
has a special denotation called a stereotype.
Learning & Knowledge Education - India
© 2007 IBM Corporation
61
Interface
<<type>>
DrawingContext
setPoint(int x, int y)
clearScreen()
getVerticalSize():int
getHorizontalSize():int
Shape Window
DrawingContext
Learning & Knowledge Education - India
© 2007 IBM Corporation
62
Multiplicity
• The UML representation of an association is a line with an
optional arrowhead indicating the role of the object (s) in the
relationship, and an optional notation at each end indicating the
multiplicity of instances of that entity (the number of objects that
participate in the association).
• Common multiplicities are:
0..1 No instances, or one instance (optional, may)
1 Exactly one instance
0..* or *Zero or more instances
1..* One or more instances (at least one)
Learning & Knowledge Education - India
© 2007 IBM Corporation
63
Object Diagrams
• Although we design and define classes, in a live application
classes are not directly used, but instances or objects of these
classes are used for executing the business logic.
• A pictorial representation of the relationships between these
instantiated classes at any point of time (called objects) is called
an "Object diagram." It looks very similar to a class diagram,
and uses the similar notations to denote relationships.
Learning & Knowledge Education - India
© 2007 IBM Corporation
64
• Because an Object Diagram shows how specific instances of a
class are linked to each other at runtime, at any moment in time it
consists of the same elements as a class diagram; in other
words, it contains classes and links showing the relationships.
• However, there is one minor difference. The class diagram
shows a class with attributes and methods declared. However, in
an object diagram, these attributes and method parameters are
allocated values
Elements of an Object Diagram
Learning & Knowledge Education - India
© 2007 IBM Corporation
65
Class diagram
Order
date_received:
price
isprepaid
dispatch()
close
Customer
name
address
creditRating()
n 1
Learning & Knowledge Education - India
© 2007 IBM Corporation
66
Object diagram
order1:Order
date_received:12-05-02
price:200
isprepaid:true
dispatch()
Customer1:Customer
name: Nancy
address: Mumbai
creditRating()
order2:Order
date_received:12-05-02
price:340
isprepaid:false
dispatch()
Learning & Knowledge Education - India
© 2007 IBM Corporation
67
Interaction Diagrams
• Interaction diagrams model the behavior of use cases by
describing the way groups of objects interact to complete the
task. The two kinds of interaction diagrams are
 sequence and collaboration diagrams.
• Interaction diagrams are used when you want to model the
behavior of several objects in a use case.
• They demonstrate how the objects collaborate for the behavior.
• Interaction diagrams do not give a in depth representation of the
behavior.
Learning & Knowledge Education - India
© 2007 IBM Corporation
68
Sequence Diagrams
• Sequence diagrams generally show the sequence of events that
occur.
• Sequence diagrams demonstrate the behavior of objects in a use
case by describing the objects and the messages they pass.
• The diagrams are read left to right and descending
Learning & Knowledge Education - India
© 2007 IBM Corporation
69
Sequence Diagram
The example below shows an object of class 1 start the behavior by sending a
message to an object of class 2. Messages pass between the different objects
until the object of class 1 receives the final message.
Learning & Knowledge Education - India
© 2007 IBM Corporation
70
Sequence Diagram (Contd.)
The diagram depicts the activation and the life cycle of an object.
Learning & Knowledge Education - India
© 2007 IBM Corporation
71
Sequence Diagram
Learning & Knowledge Education - India
© 2007 IBM Corporation
72
Collaboration Diagram
• Collaboration diagrams show the relationship between objects and the
order of messages passed between them.
• The objects are listed as icons and arrows indicate the messages being
passed between them.
• The numbers next to the messages are called sequence numbers.
• As the name suggests, they show the sequence of the messages as
they are passed between the objects.
• There are many acceptable sequence numbering schemes in UML. A
simple 1, 2, 3... format can be used, as the example below shows, or for
more detailed and complex diagrams a 1, 1.1 ,1.2, 1.2.1... scheme can
be used.
Learning & Knowledge Education - India
© 2007 IBM Corporation
73
Collaboration Diagrams (Contd.)
Learning & Knowledge Education - India
© 2007 IBM Corporation
74
Collaboration Diagrams (Contd.)
Learning & Knowledge Education - India
© 2007 IBM Corporation
75
State Diagrams
• State diagrams are used to describe the behavior of a
Application.
• State diagrams describe all of the possible states of an object as
events occur.
• Each diagram usually represents objects of a single class and
track the different states of its objects through the Application.
Learning & Knowledge Education - India
© 2007 IBM Corporation
76
State Diagrams (contd.)
• State diagrams have very few
elements. The basic elements
are rounded boxes representing
the state of the object and arrows
indicting the transition to the next
state.
• The activity section of the state
symbol depicts what activities the
object will be doing while it is in
that state.
Learning & Knowledge Education - India
© 2007 IBM Corporation
77
State Diagrams (contd.)
• All state diagrams being with an
initial state of the object. This is
the state of the object when it is
created.
• After the initial state the object
begins changing states.
• Conditions based on the activities
can determine what the next
state the object transitions to.
Learning & Knowledge Education - India
© 2007 IBM Corporation
78
Example of a State Diagram
• Let us consider an example of a state diagram might look like for
an Order object.
When the object enters the Checking state it performs the
activity "check items." After the activity is completed the
object transitions to the next state based on the conditions [all
items available] or [an item is not available].
 If an item is not available the order is canceled. If all items
are available then the order is dispatched.
 When the object transitions to the Dispatching state the
activity "initiate delivery" is performed.
After this activity is complete the object transitions again to
the Delivered state.
Learning & Knowledge Education - India
© 2007 IBM Corporation
79
Example of a State Diagram (Contd.)
Learning & Knowledge Education - India
© 2007 IBM Corporation
80
Example of a State Diagram (Contd.)
Learning & Knowledge Education - India
© 2007 IBM Corporation
81
•Class diagrams are widely used to describe the types of objects in a
system and their relationships.
•Class diagrams model class structure and contents using design
elements such as classes, packages and objects.
•Class diagrams also display relationships such as containment,
inheritance, associations and others
•The association relationship is the most common relationship in a
class diagram.
• The association shows the relationship between instances of classes.
• Interaction diagrams model the behavior of use cases by describing
the way groups of objects interact to complete the task. The two kinds
of interaction diagrams are sequence and collaboration diagrams.
Summary
Learning & Knowledge Education - India
© 2007 IBM Corporation
82
1. Class diagrams are widely used to describe the types of
_______ in a system and their ___________________
• Objects and relationships
• Objects and Classes
• Objects and messages
• Encapsulation and Classes
2. A generalization is used when two classes are similar
• True
• false
Test Your Understanding
Learning & Knowledge Education - India
© 2007 IBM Corporation
83
Test your understanding
3. Example of a Dynamic diagram is:
• Class diagram
• State Diagram
• Object Diagram
• Component Diagram
Learning & Knowledge Education - India
© 2007 IBM Corporation
84
Test your understanding
Learning & Knowledge Education - India
© 2007 IBM Corporation
85
Test your understanding
4. The diagram represents a
• Class Diagram
• Object Diagram
• Sequence Diagram
• Use Case diagram
Learning & Knowledge Education - India
© 2007 IBM Corporation
86
End

More Related Content

PPTX
1669609053088_oops_final.pptx
PDF
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
PPTX
Object Oriented Programming Concepts
PPTX
object oriented programing lecture 1
PPTX
Intro to oop.pptx
PPT
16613874-Object-Oriented-Programming-Presentation.ppt
PDF
PPT
Unit 1- Basic concept of object-oriented-programming.ppt
1669609053088_oops_final.pptx
UNIT1- OBJECT ORIENTED PROGRAMMING IN JAVA- AIML IT-SPPU
Object Oriented Programming Concepts
object oriented programing lecture 1
Intro to oop.pptx
16613874-Object-Oriented-Programming-Presentation.ppt
Unit 1- Basic concept of object-oriented-programming.ppt

Similar to oops concepts for C++ language to understand basics (20)

DOCX
Ooad notes
PPTX
130704798265658191
PPT
Basic Java Concept - Practical Oriented Methodologies
PPTX
General oop concept
PPT
Share Unit 1- Basic concept of object-oriented-programming.ppt
PDF
lecture.in ooop object orented programmeg.pdf
PPTX
Unit 1 OOSE
PDF
Object And Oriented Programing ( Oop ) Languages
PPT
Object oriented programming
PDF
Computer_Programming_Part_II_Segment_01.pdf
PPTX
Intro to object oriented programming.pptx
PPTX
SKILLWISE - OOPS CONCEPT
PPTX
bbbnnjxhxshjsjskshsjsjshssddhjddjdjddhgd
PDF
6_Object-oriented-using-java.pdf object oriented programming concepts
PDF
Introduction to oops concepts
DOCX
Unit1 jaava
DOC
C# by Zaheer Abbas Aghani
DOC
C# by Zaheer Abbas Aghani
PDF
OOPS_Unit_1
PDF
Object-Oriented Programming in Java (Module 1)
Ooad notes
130704798265658191
Basic Java Concept - Practical Oriented Methodologies
General oop concept
Share Unit 1- Basic concept of object-oriented-programming.ppt
lecture.in ooop object orented programmeg.pdf
Unit 1 OOSE
Object And Oriented Programing ( Oop ) Languages
Object oriented programming
Computer_Programming_Part_II_Segment_01.pdf
Intro to object oriented programming.pptx
SKILLWISE - OOPS CONCEPT
bbbnnjxhxshjsjskshsjsjshssddhjddjdjddhgd
6_Object-oriented-using-java.pdf object oriented programming concepts
Introduction to oops concepts
Unit1 jaava
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
OOPS_Unit_1
Object-Oriented Programming in Java (Module 1)
Ad

Recently uploaded (20)

PPTX
FLIGHT TICKET API | API INTEGRATION PLATFORM
PPTX
AI Tools Revolutionizing Software Development Workflows
PPTX
Independent Consultants’ Biggest Challenges in ERP Projects – and How Apagen ...
PDF
Mobile App for Guard Tour and Reporting.pdf
PDF
Sanket Mhaiskar Resume - Senior Software Engineer (Backend, AI)
PDF
Odoo Construction Management System by CandidRoot
PPTX
Human-Computer Interaction for Lecture 2
PPTX
Foundations of Marketo Engage: Nurturing
PDF
WhatsApp Chatbots The Key to Scalable Customer Support.pdf
PDF
infoteam HELLAS company profile 2025 presentation
PPTX
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB
PPTX
UNIT II: Software design, software .pptx
PDF
IT Consulting Services to Secure Future Growth
PDF
SOFTWARE ENGINEERING Software Engineering (3rd Edition) by K.K. Aggarwal & Yo...
PPTX
Streamlining Project Management in the AV Industry with D-Tools for Zoho CRM ...
PPTX
Chapter_05_System Modeling for software engineering
PDF
Top 10 Project Management Software for Small Teams in 2025.pdf
PPTX
Chapter 1 - Transaction Processing and Mgt.pptx
PPTX
Post-Migration Optimization Playbook: Getting the Most Out of Your New Adobe ...
PDF
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
FLIGHT TICKET API | API INTEGRATION PLATFORM
AI Tools Revolutionizing Software Development Workflows
Independent Consultants’ Biggest Challenges in ERP Projects – and How Apagen ...
Mobile App for Guard Tour and Reporting.pdf
Sanket Mhaiskar Resume - Senior Software Engineer (Backend, AI)
Odoo Construction Management System by CandidRoot
Human-Computer Interaction for Lecture 2
Foundations of Marketo Engage: Nurturing
WhatsApp Chatbots The Key to Scalable Customer Support.pdf
infoteam HELLAS company profile 2025 presentation
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB
UNIT II: Software design, software .pptx
IT Consulting Services to Secure Future Growth
SOFTWARE ENGINEERING Software Engineering (3rd Edition) by K.K. Aggarwal & Yo...
Streamlining Project Management in the AV Industry with D-Tools for Zoho CRM ...
Chapter_05_System Modeling for software engineering
Top 10 Project Management Software for Small Teams in 2025.pdf
Chapter 1 - Transaction Processing and Mgt.pptx
Post-Migration Optimization Playbook: Getting the Most Out of Your New Adobe ...
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
Ad

oops concepts for C++ language to understand basics

  • 1. Learning & Knowledge Education - India © 2007 IBM Corporation Object Oriented Programming
  • 2. Learning & Knowledge Education - India © 2007 IBM Corporation 2 Day 1
  • 3. Learning & Knowledge Education - India © 2007 IBM Corporation 3 Object Oriented (OO) • People often use the acronym OO to stand for anything object- oriented, yielding acronyms such as the following: • OOP - Object-oriented programming • OOA - Object-oriented analysis • OOD - Object-oriented design
  • 4. Learning & Knowledge Education - India © 2007 IBM Corporation 4 History of Object Oriented Programming. • OOP concepts started surfacing in the mid-1960s with a programming language called Simula. • It further evolved in the 1970s with advent of Smalltalk. • A resurgence of interest in object-oriented methodologies occurred in the mid-1980s. Specifically, OOP languages such as C++ and Eifle became popular with mainstream computer programmers • OOP continued to grow in popularity in the 1990s, most notably with the advent of Java. • In 2002, in conjunction with the release of the .NET Framework, Microsoft introduced a new OOP language, C#
  • 5. Learning & Knowledge Education - India © 2007 IBM Corporation 5 Procedural Programming • Procedural languages organize the program in a linear fashion— they run from top to bottom. • In other words, the program is a series of steps that run one after another. • This type of programming worked fine for small programs that consisted of a few hundred code lines, but as programs became larger, they became hard to manage and debug.
  • 6. Learning & Knowledge Education - India © 2007 IBM Corporation 6 Structured Programming • In an attempt to manage the ever-increasing size of the programs, structured programming was introduced to break down the code into manageable segments called functions or procedures. • This was an improvement, but as programs performed more complex business functionality and interacted with other systems, the shortcomings of structural programming methodology began to surface: Programs became harder to maintain. Existing functionality was hard to alter without adversely affecting all of the system’s functionality. New programs were essentially built from scratch. Consequently, there was little return on the investment of previous efforts. Programming was not conducive to team development. Programmers needed to know every aspect of how a program worked and could not isolate their efforts on one aspect of a system. It was hard to translate business models into programming models.
  • 7. Learning & Knowledge Education - India © 2007 IBM Corporation 7 Benefits of Object Oriented Programming • A more intuitive transition from business analysis models to software implementation models • The ability to maintain and implement changes in the programs more efficiently and rapidly • The ability to more effectively create software systems using a team process, allowing specialists to work on parts of the system • The ability to reuse code components in other programs and purchase components written by third-party developers to increase the functionality of programs with little effort • Better integration with loosely coupled distributed computing systems • Improved integration with modern operating systems • The ability to create a more intuitive graphical user interface for the users
  • 8. Learning & Knowledge Education - India © 2007 IBM Corporation 8 What is an Object? • An object is a software construct that encapsulates data, along with the ability to use or modify that data, into a software entity. • An object is a self-contained entity which has its own private collection of properties (ie. data) and methods (ie. operations) that encapsulate functionality into a reusable and dynamically loaded structure.
  • 9. Learning & Knowledge Education - India © 2007 IBM Corporation 9 • Object-Oriented Programming : A large application consists of component objects, which interact with each other. Can be used to develop various applications. About Object Oriented Programming
  • 10. Learning & Knowledge Education - India © 2007 IBM Corporation 10 What is an Object (Continued) • An object has:  state  behavior the structure and behavior of similar objects are defined in their common class.”
  • 11. Learning & Knowledge Education - India © 2007 IBM Corporation 11 Example MyCar Accelerate Brake Change Gear brand : Maruti speed : 45 kmph gear : 3rd wheels : 4 color : White
  • 12. Learning & Knowledge Education - India © 2007 IBM Corporation 12 What is an Object Oriented Program • An Object-Oriented Program consists of a group of cooperating objects, exchanging messages, for the purpose of achieving a common objective.
  • 13. Learning & Knowledge Education - India © 2007 IBM Corporation 13 What is a Class? • A class is a blueprint or prototype that defines the variables and the methods common to all objects of a certain kind.  blueprint: A class can't do anything on its own.  defines: A class provides something that can be used later.  objects: A class can only be used, if it had been "brought to life" by instantiating it.
  • 14. Learning & Knowledge Education - India © 2007 IBM Corporation 14 Example A Car Accelerate Brake Change Gear brand speed gear wheels color
  • 15. Learning & Knowledge Education - India © 2007 IBM Corporation 15 Methods • An operation upon an object, defined as part of the declaration of a class. • The methods, defined in a class, indicate, what the instantiated objects are able to do.
  • 16. Learning & Knowledge Education - India © 2007 IBM Corporation 16 Example A Car brand: Maruti speed: 45 kmph gear: 3rd wheels: 4 color: White Driver Driver wants to increase the speed of the car? speed: 50 kmph Accelerate Brake Change Gear
  • 17. Learning & Knowledge Education - India © 2007 IBM Corporation 17 Question A Car brand: Maruti speed: 50 kmph gear: 3rd wheels: 4 color: White Driver Driver wants to decrease the speed of the car? Click To Know The Answer Accelerate Brake Change Gear
  • 18. Learning & Knowledge Education - India © 2007 IBM Corporation 18 Answer A Car brand: Maruti speed: 50 kmph gear: 3rd wheels: 4 color: White Driver Driver wants to decrease the speed of the car? speed: 45 kmph Accelerate Brake Change Gear
  • 19. Learning & Knowledge Education - India © 2007 IBM Corporation 19 • Real-world programming • Reusability of code • Modularity of code • Information hiding Advantages of OOP
  • 20. Learning & Knowledge Education - India © 2007 IBM Corporation 20 • Encapsulation • Inheritance • Polymorphism Features of OOPS
  • 21. Learning & Knowledge Education - India © 2007 IBM Corporation 21 • Encapsulation is the ability of an object to place a boundary around its properties (ie. data) and methods (ie. operations). • Grady Booch, defined the encapsulation feature as: “Encapsulation is the process of hiding all of the details of an object that do not contribute to its essential characteristics.” Encapsulation
  • 22. Learning & Knowledge Education - India © 2007 IBM Corporation 22 Encapsulation (Example) MyCar brand: Maruti speed: 45 kmph gear: 3rd wheels: 4 color: White Other object Access Denied Access Allowed Accelerate Brake Change Gear
  • 23. Learning & Knowledge Education - India © 2007 IBM Corporation 23 “An Abstraction denotes the essential characteristics of an object that distinguishes it from all other kinds of objects and thus provides crisply defined conceptual boundaries, relative to the perspective of the viewer.” Abstraction Encapsulation hides the irrelevant details of an object and Abstraction makes only the relevant details of an object visible.
  • 24. Learning & Knowledge Education - India © 2007 IBM Corporation 24 • Inheritance is the capability of a class to use the properties and methods of another class while adding its own functionality. • Enables you to add new features and functionality to an existing class without modifying the existing class. Inheritance
  • 25. Learning & Knowledge Education - India © 2007 IBM Corporation 25 • Superclass and Subclass A superclass or parent class is the one from which another class inherits attributes and behavior. A subclass or child class is a class that inherits attributes and behavior from a superclass. Inheritance (Continued)
  • 26. Learning & Knowledge Education - India © 2007 IBM Corporation 26 Employee Secretary Manager Programmer Inheritance (Continued)
  • 27. Learning & Knowledge Education - India © 2007 IBM Corporation 27 • Single inheritance Subclass is derived from only one superclass. Types of Inheritance Super class /Base Class (Parent) Sub class /Derived Class (Child)
  • 28. Learning & Knowledge Education - India © 2007 IBM Corporation 28 • Multiple Inheritance A subclass is derived from more than one super class. Types of Inheritance (Continued) Super Class (Parent 1) Super Class (Parent 2) Sub Class (Child)
  • 29. Learning & Knowledge Education - India © 2007 IBM Corporation 29 • Derived from two Latin words - Poly, which means many, and morph, which means forms. • It is the capability of an action or method to do different things based on the object that it is acting upon. • In object-oriented programming, polymorphism refers to a programming language's ability to process objects differently depending on their data type or class. Polymorphism
  • 30. Learning & Knowledge Education - India © 2007 IBM Corporation 30 Object Model • The insight of object oriented programming is to combine the state and behavior in a unit called an Object. • A program consists of a network of interconnected objects that call upon each other to solve a part of the puzzle. • Each object has a specific role to play in the overall design of the program and is able to communicate with other objects. Objects communicate through messages, requests to perform a method.
  • 31. Learning & Knowledge Education - India © 2007 IBM Corporation 31 Basic questions while developing an OOP application • What objects does the application need??? • What functionality should those objects have????
  • 32. Learning & Knowledge Education - India © 2007 IBM Corporation 32 Objects are grouped into classes • A class is a set of objects which share the common attributes and common behavior. • Classes are used to distinguish one type of object from another. • A single object is simply an object of the class. • The chief role of a class is to define the properties and procedures and the applicability of its instances.
  • 33. Learning & Knowledge Education - India © 2007 IBM Corporation 33 Objects responds to Messages • Message are non specific function calls. • Different Objects can respond to the same message different ways. • Message is just an instruction. • A message differs from a function/method. • Objects communicate with each other via messages. • What is a Message???
  • 34. Learning & Knowledge Education - India © 2007 IBM Corporation 34 • The procedural programming methodology involves dividing a large program into a set of subprocedures or subprograms that perform specific tasks. • The procedural programming methodology allows code reusability in large applications. • It emphasizes on procedures. Summary
  • 35. Learning & Knowledge Education - India © 2007 IBM Corporation 35 • An object is defined as an instance of a class. • In the object oriented approach, classes are designed such that they can be reused. • Object Oriented programming offers features such as Reusability, Object oriented Modularity, and Information hiding. • Encapsulation- Hides the implementation details of an object and therefore hides its complexity. • Abstraction- Focuses on the essential features of an object. Summary (Continued)
  • 36. Learning & Knowledge Education - India © 2007 IBM Corporation 36 • Inheritance - Creates a hierarchy of classes and helps in reuse of attributes and methods of a class. • A superclass shares its attributes and behavior with its child classes. • Polymorphism- Assigns a different meaning or usage to an entity in different contexts. Summary (Continued)
  • 37. Learning & Knowledge Education - India © 2007 IBM Corporation 37 1. _ _ _ _ _ programming involves a large program into a set of subprocedures or subprograms that perform specific tasks. a. Sequential b. Procedural c. Object Oriented d. Rule-Based 2. _ _ _ _ _ among the following operates on the data. a. Variables b. Class c. Method d. All of the above Test Your Understanding
  • 38. Learning & Knowledge Education - India © 2007 IBM Corporation 38 3. What is the acronym for OOP? a. Object Oriented Programming b. Object Orientation programming c. Object Oriented Program d. Object Oriented Procedure 4. _ _ _ _ _ _ is the concept that capsules data members and methods. a. Abstraction b. Polymorphism c. Encapsulation d. Inheritance Test Your Understanding (Contd.)
  • 39. Learning & Knowledge Education - India © 2007 IBM Corporation 39 5. _ _ _ _ _ feature of OOPS that means ignoring the non-essential details of an object and concentrating on its essential features? a. Inheritance b. Encapsulation c. Abstraction d. Polymorphism 6. Pick the odd one out. a. State b. Class c. Behavior d. Identity Test Your Understanding (Contd.)
  • 40. Learning & Knowledge Education - India © 2007 IBM Corporation 40 Day 2
  • 41. Learning & Knowledge Education - India © 2007 IBM Corporation 41 Design related questions before building an application • What classes exists and how are they related? • How objects collaborate? • Where should each objects be declared? • How should multiple processes be scheduled?
  • 42. Learning & Knowledge Education - India © 2007 IBM Corporation 42 The following diagrams are used to answer the previous questions. • Class diagrams • Object diagrams • Sequence Diagrams • Interaction diagrams
  • 43. Learning & Knowledge Education - India © 2007 IBM Corporation 43 UML • The Unified Modeling Language (UML) is a standard language for specifying, visualizing, constructing, and documenting the artifacts of software systems, as well as for business modeling and other non-software systems. • The UML is a very important part of developing object oriented software and the software development process. • The UML uses mostly graphical notations to express the design of software projects. • Using the UML helps project teams communicate, explore potential designs, and validate the architectural design of the software.
  • 44. Learning & Knowledge Education - India © 2007 IBM Corporation 44 Primary goals of UML • Provide users with a ready-to-use, expressive visual modeling language so they can develop and exchange meaningful models. • Provide extensibility and specialization mechanisms to extend the core concepts. • Be independent of particular programming languages and development processes. • Provide a formal basis for understanding the modeling language. • Encourage the growth of the OO tools market. • Support higher-level development concepts such as collaborations, frameworks, patterns and components. • Integrate best practices.
  • 45. Learning & Knowledge Education - India © 2007 IBM Corporation 45 Class Diagram • Class diagrams are widely used to describe the types of objects in a system and their relationships. • Class diagrams model class structure and contents using design elements such as classes, packages and objects. • Class diagrams describe three different perspectives when designing a system, conceptual, specification, and implementation. • These perspectives become evident as the diagram is created and help solidify the design.
  • 46. Learning & Knowledge Education - India © 2007 IBM Corporation 46 Class Diagram • A class icon is simply a rectangle divided into three compartments. The topmost compartment contains the name of the class. • The middle compartment contains a list of attributes (member variables), • and the bottom compartment contains a list of operations (member functions). Class Attribute Operations()
  • 47. Learning & Knowledge Education - India © 2007 IBM Corporation 47 Class Diagram • Attributes and operations may have their visibility marked as follows: "+" for public "#" for protected "-" for private "~" for package
  • 48. Learning & Knowledge Education - India © 2007 IBM Corporation 48 Class Diagram Circle radius:double center:Point area:double circumference:double setRadius(double) setCenter(Point)
  • 49. Learning & Knowledge Education - India © 2007 IBM Corporation 49 Association • An Association represents a family of links. Binary associations (with two ends) are normally represented as a line, with each end connected to a class box. • Higher order associations can be drawn with more than two ends. In such cases, the ends are connected to a central diamond. • An association can be named, and the ends of an association can be adorned with role names, ownership indicators, multiplicity, visibility, and other properties. • Associations can only be shown on class diagrams.
  • 50. Learning & Knowledge Education - India © 2007 IBM Corporation 50  Each instance of type Circle seems to contain an instance of type Point. This is a relationship known as composition Circle Point Composition
  • 51. Learning & Knowledge Education - India © 2007 IBM Corporation 51 Composition (Contd.) • The black diamond represents composition. • It is placed on the Circle class because it is the Circle that is composed of a Point. • The arrowhead on the other end of the relationship denotes that the relationship is navigable in only one direction. That is, Point does not know about Circle.
  • 52. Learning & Knowledge Education - India © 2007 IBM Corporation 52 Composition (Contd.) • Composition relationships are a strong form of containment or aggregation. Aggregation is a whole/part relationship. In this case, Circle is the whole, and Point is part of Circle. • Composition is more than just aggregation. Composition also indicates that the lifetime of Point is dependent upon Circle. • This means that if Circle is destroyed, Point will be destroyed with it.
  • 53. Learning & Knowledge Education - India © 2007 IBM Corporation 53 Inheritance • The inheritance relationship in UML is depicted by a triangular arrowhead. • This arrowhead, points to the base class. One or more lines proceed from the base of the arrowhead connecting it to the derived classes.
  • 54. Learning & Knowledge Education - India © 2007 IBM Corporation 54 Inheritance Shape Erase() Draw() Square Circle
  • 55. Learning & Knowledge Education - India © 2007 IBM Corporation 55 A taxonomy of people within the university
  • 56. Learning & Knowledge Education - India © 2007 IBM Corporation 56 • The weak form of aggregation is denoted with an open diamond. This relationship denotes that the aggregate class (the class with the white diamond touching it) is in some way the “whole”, and the other is somehow part of the whole. Window Shape Its Shapes * Aggregation
  • 57. Learning & Knowledge Education - India © 2007 IBM Corporation 57 Aggregation (Contd.) • In this case, the Window class contains many Shape instances. • In UML the ends of a relationship are referred to as its “roles”. • Notice that the role at the Shape end of the aggregation is marked with a “*“. • This indicates that the Window contains many Shape instances. • The role has been named. This is the name that Window knows its Shape instances by i.e. it is the name of the instance variable within Window that holds the shapes.
  • 58. Learning & Knowledge Education - India © 2007 IBM Corporation 58 Dependency • Sometimes the relationship between a two classes is very weak. They are not implemented with member variables at all. • The relationship might be implemented as member function arguments. • Consider, for example, the Draw function of the Shape class.
  • 59. Learning & Knowledge Education - India © 2007 IBM Corporation 59 Dependency Window Shape DrawingContext itsContext ItsShapes * draw(DrawingContext ctx)
  • 60. Learning & Knowledge Education - India © 2007 IBM Corporation 60 Interface • There are classes that have nothing but pure virtual functions. • In Java such entities are not classes at all; • They are a special language element called an interface. • UML has followed the Java example and has created some special syntactic elements for such entities. • The primary icon for an interface is just like a class except that it has a special denotation called a stereotype.
  • 61. Learning & Knowledge Education - India © 2007 IBM Corporation 61 Interface <<type>> DrawingContext setPoint(int x, int y) clearScreen() getVerticalSize():int getHorizontalSize():int Shape Window DrawingContext
  • 62. Learning & Knowledge Education - India © 2007 IBM Corporation 62 Multiplicity • The UML representation of an association is a line with an optional arrowhead indicating the role of the object (s) in the relationship, and an optional notation at each end indicating the multiplicity of instances of that entity (the number of objects that participate in the association). • Common multiplicities are: 0..1 No instances, or one instance (optional, may) 1 Exactly one instance 0..* or *Zero or more instances 1..* One or more instances (at least one)
  • 63. Learning & Knowledge Education - India © 2007 IBM Corporation 63 Object Diagrams • Although we design and define classes, in a live application classes are not directly used, but instances or objects of these classes are used for executing the business logic. • A pictorial representation of the relationships between these instantiated classes at any point of time (called objects) is called an "Object diagram." It looks very similar to a class diagram, and uses the similar notations to denote relationships.
  • 64. Learning & Knowledge Education - India © 2007 IBM Corporation 64 • Because an Object Diagram shows how specific instances of a class are linked to each other at runtime, at any moment in time it consists of the same elements as a class diagram; in other words, it contains classes and links showing the relationships. • However, there is one minor difference. The class diagram shows a class with attributes and methods declared. However, in an object diagram, these attributes and method parameters are allocated values Elements of an Object Diagram
  • 65. Learning & Knowledge Education - India © 2007 IBM Corporation 65 Class diagram Order date_received: price isprepaid dispatch() close Customer name address creditRating() n 1
  • 66. Learning & Knowledge Education - India © 2007 IBM Corporation 66 Object diagram order1:Order date_received:12-05-02 price:200 isprepaid:true dispatch() Customer1:Customer name: Nancy address: Mumbai creditRating() order2:Order date_received:12-05-02 price:340 isprepaid:false dispatch()
  • 67. Learning & Knowledge Education - India © 2007 IBM Corporation 67 Interaction Diagrams • Interaction diagrams model the behavior of use cases by describing the way groups of objects interact to complete the task. The two kinds of interaction diagrams are  sequence and collaboration diagrams. • Interaction diagrams are used when you want to model the behavior of several objects in a use case. • They demonstrate how the objects collaborate for the behavior. • Interaction diagrams do not give a in depth representation of the behavior.
  • 68. Learning & Knowledge Education - India © 2007 IBM Corporation 68 Sequence Diagrams • Sequence diagrams generally show the sequence of events that occur. • Sequence diagrams demonstrate the behavior of objects in a use case by describing the objects and the messages they pass. • The diagrams are read left to right and descending
  • 69. Learning & Knowledge Education - India © 2007 IBM Corporation 69 Sequence Diagram The example below shows an object of class 1 start the behavior by sending a message to an object of class 2. Messages pass between the different objects until the object of class 1 receives the final message.
  • 70. Learning & Knowledge Education - India © 2007 IBM Corporation 70 Sequence Diagram (Contd.) The diagram depicts the activation and the life cycle of an object.
  • 71. Learning & Knowledge Education - India © 2007 IBM Corporation 71 Sequence Diagram
  • 72. Learning & Knowledge Education - India © 2007 IBM Corporation 72 Collaboration Diagram • Collaboration diagrams show the relationship between objects and the order of messages passed between them. • The objects are listed as icons and arrows indicate the messages being passed between them. • The numbers next to the messages are called sequence numbers. • As the name suggests, they show the sequence of the messages as they are passed between the objects. • There are many acceptable sequence numbering schemes in UML. A simple 1, 2, 3... format can be used, as the example below shows, or for more detailed and complex diagrams a 1, 1.1 ,1.2, 1.2.1... scheme can be used.
  • 73. Learning & Knowledge Education - India © 2007 IBM Corporation 73 Collaboration Diagrams (Contd.)
  • 74. Learning & Knowledge Education - India © 2007 IBM Corporation 74 Collaboration Diagrams (Contd.)
  • 75. Learning & Knowledge Education - India © 2007 IBM Corporation 75 State Diagrams • State diagrams are used to describe the behavior of a Application. • State diagrams describe all of the possible states of an object as events occur. • Each diagram usually represents objects of a single class and track the different states of its objects through the Application.
  • 76. Learning & Knowledge Education - India © 2007 IBM Corporation 76 State Diagrams (contd.) • State diagrams have very few elements. The basic elements are rounded boxes representing the state of the object and arrows indicting the transition to the next state. • The activity section of the state symbol depicts what activities the object will be doing while it is in that state.
  • 77. Learning & Knowledge Education - India © 2007 IBM Corporation 77 State Diagrams (contd.) • All state diagrams being with an initial state of the object. This is the state of the object when it is created. • After the initial state the object begins changing states. • Conditions based on the activities can determine what the next state the object transitions to.
  • 78. Learning & Knowledge Education - India © 2007 IBM Corporation 78 Example of a State Diagram • Let us consider an example of a state diagram might look like for an Order object. When the object enters the Checking state it performs the activity "check items." After the activity is completed the object transitions to the next state based on the conditions [all items available] or [an item is not available].  If an item is not available the order is canceled. If all items are available then the order is dispatched.  When the object transitions to the Dispatching state the activity "initiate delivery" is performed. After this activity is complete the object transitions again to the Delivered state.
  • 79. Learning & Knowledge Education - India © 2007 IBM Corporation 79 Example of a State Diagram (Contd.)
  • 80. Learning & Knowledge Education - India © 2007 IBM Corporation 80 Example of a State Diagram (Contd.)
  • 81. Learning & Knowledge Education - India © 2007 IBM Corporation 81 •Class diagrams are widely used to describe the types of objects in a system and their relationships. •Class diagrams model class structure and contents using design elements such as classes, packages and objects. •Class diagrams also display relationships such as containment, inheritance, associations and others •The association relationship is the most common relationship in a class diagram. • The association shows the relationship between instances of classes. • Interaction diagrams model the behavior of use cases by describing the way groups of objects interact to complete the task. The two kinds of interaction diagrams are sequence and collaboration diagrams. Summary
  • 82. Learning & Knowledge Education - India © 2007 IBM Corporation 82 1. Class diagrams are widely used to describe the types of _______ in a system and their ___________________ • Objects and relationships • Objects and Classes • Objects and messages • Encapsulation and Classes 2. A generalization is used when two classes are similar • True • false Test Your Understanding
  • 83. Learning & Knowledge Education - India © 2007 IBM Corporation 83 Test your understanding 3. Example of a Dynamic diagram is: • Class diagram • State Diagram • Object Diagram • Component Diagram
  • 84. Learning & Knowledge Education - India © 2007 IBM Corporation 84 Test your understanding
  • 85. Learning & Knowledge Education - India © 2007 IBM Corporation 85 Test your understanding 4. The diagram represents a • Class Diagram • Object Diagram • Sequence Diagram • Use Case diagram
  • 86. Learning & Knowledge Education - India © 2007 IBM Corporation 86 End

Editor's Notes

  • #4: Users of software programs are isolated from the logic needed to accomplish a task. For example, when you print a page in your word processor, you initiate the action by clicking a print button. You are isolated from the internal processing that needs to occur; you just wait for a response telling you if it printed. Internally, the button object interacts with a printer object, which interacts with the printer to accomplish the task of printing the page. OOP concepts started surfacing in the mid-1960s with a programming language called Simula and further evolved in the 1970s with advent of Smalltalk. Although software developers did not overwhelmingly embrace these early advances in OOP languages, object-oriented methodologies continued to evolve. A resurgence of interest in object-oriented methodologies occurred in the mid-1980s. Specifically, OOP languages such as C++ and Eifle became popular with mainstream computer programmers. OOP continued to grow in popularity in the 1990s, most notably with the advent of Java and the huge following it attracted. And in 2002, in conjunction with the release of the .NET Framework, Microsoft introduced a new OOP language, C# (pronounced C-sharp) and revamped Visual Basic so that it is truly an OOP language.
  • #6: In addition to these shortcomings, some evolutions of computing systems caused further strain on the structural program approach: Nonprogrammers demanded and were given direct access to programs through the incorporation of graphical user interfaces and their desktop computers. Users demanded a more-intuitive, less-structured approach to interacting with programs. Computer systems evolved into a distributed model where the business logic, user interface, and backend database were loosely coupled and accessed over the Internet and intranets.
  • #8: Booch defines an object as
  • #46: In many diagrams, the bottom two compartments are omitted. Even when they are present, they typically do not show every attribute and operations. The goal is to show only those attributes and operations that are useful for the particular diagram. This ability to abbreviate an icon is one of the hallmarks In many diagrams, the bottom two compartments are omitted. Even when they are present, they typically do not show every attribute and operations. The goal is to show only those attributes and operations that are useful for the particular diagram. This ability to abbreviate an icon is one of the hallmarks
  • #48: Notice that each member variable is followed by a colon and by the type of the variable. If the type is redundant, or otherwise unnecessary, it can be omitted. Notice also that the return values follow the member functions in a similar fashion. Again, these can be omitted. Finally, notice that the member function arguments are just types. I could have named them too, and used colons to separate them from their types;
  • #51: In UML relationships are presumed to be bidirectional unless the arrowhead is present to restrict them.
  • #54: In this diagram we see that Circle and Square both derive from Shape . Note that the name of class Shape is shown in italics. This indicates that Shape is an abstract class. Note also that the operations, Draw() and Erase() are also shown in italics. This indicates that they are pure virtual.
  • #55: It takes a “single section” approach to classes, instead of the three section approach that we’ve seen in previous diagrams, because we’re exploring relationships between entity types but not their responsibilities. It uses UML 2.0’s generalization set concept, basically just an inheritance arrowhead with a label representing the name of the set.  In UML 1.x this label was called a discriminator.  There are three generalization sets for Person: Nationality, Role, and Gender.  These generalization sets overlap – a person can be classified via each of these roles (e.g. someone can be a male foreign student).  This is called multiple classification.  You can indicate “sub generalization” sets, for example Student within the Role generalization set.   Some generalization sets are mutually exclusive from others, not shown in the example, where an entity type may only be in one set.  This is referred to as single classification and would be modeled using an XOR (exclusive OR) constraint between the two (or more) discriminators.  
  • #59: Suppose that this function takes an argument of type DrawingContext.
  • #61: Note the «type» string at the top of the class. The two surrounding characters “«»” are called guillemets (pronounced Gee-may). A word or phrase surrounded by guillemets is called a “stereotype”. Stereotypes are one of the mechanisms that can be used to extend UML. When a stereotype is used above the name of a class it indicates that this class is a special kind of class that conforms to a rather rigid specification. The «type» stereotype indicates that the class is an interface. This means that it has no member variables, and that all of its member functions are pure virtual. UML supplies a shortcut for «type» classes. Figure 9 shows how the “lollypop” notation can be used to represent an interface. Notice that the dependency between Shape and DrawingContext is shown as usual. The class WindowsDC is derived from, or conforms to, the Drawingcontext interface.
  • #62: The association relationship indicates that (at least) one of the two related classes makes reference to the other. In contrast with the generalization relationship, this is most easily understood through the phrase 'A has a B' {a mother cat has kittens, kittens have a mother cat}.
  • #70: The light blue vertical rectangles the objects activation while the green vertical dashed lines represent the life of the object.  The green vertical rectangles represent when a particular object has control.  The represents when the object is destroyed.  This diagrams also shows conditions for messages to be sent to other object.  The condition is listed between brackets next to the message.  For example, a [condition] has to be met before the object of class 2 can send a message() to the object of class 3.  
  • #71: The object an Order Entry Window is created and sends a message to an Order object to prepare the order. Notice the the names of the objects are followed by a colon.  The names of the classes the objects belong to do not have to be listed.  However the colon is required to denote that it is the name of an object following the objectName:className naming system. Next the Order object checks to see if the item is in stock and if the [InStock] condition is met it sends a message to create an new Delivery Item object.
  • #74: .  This time the names of the objects appear after the colon, such as :Order Entry Window following the objectName:className naming convention. This time the class name is shown to demonstrate that all of objects of that class will behave the same way.
  • #80: The diagram below shows a super-state.  Both the Checking and Dispatching states can transition into the Canceled state, so a transition is shown  from a super-state named Active to the state Cancel.  By contrast, the state Dispatching can only transition to the Delivered state, so we show an arrow only from the Dispatching state to the Delivered state.