You are on page 1of 23

Object-Oriented Modeling and Design with UML

Chapter 1. Introduction & Chapter 2. Modeling as a Design Technique

Michael Blaha James Rumbaugh


2005. 4. 26 HAN AH RIM

Contents
Introduction Object-oriented (OO) concept OO characteristics OO development OO themes Evidence for usefulness of OO Summary
2005-04-26 2 / 20

Introduction
Object-oriented (OO) approach to software development based on modeling objects from the real world Use the model to build languageindependent design organizing objects OO modeling and design promotes
Better understanding of requirements Cleaner design More maintainable systems
2005-04-26 3 / 20

Object-oriented concept
Object-oriented modeling and design
Using models organized around real-world concepts

Object incorporates data structure and behavior Object-oriented vs. Previous programming
Object-oriented
a collection of discrete object that incorporate both data structure and behavior
2005-04-26

Previous programming
data structure and behavior is loosely connected

4 / 20

OO characteristics (1/4)
Identity
Data is quantized into discrete, distinguishable entities called objects Each object has is own inherent identity
Two objects are distinct even if all their attribute values are identical

Each object has a unique handle by which it can be referenced


Handle in various ways such as an address, array index, or artificial number

2005-04-26

5 / 20

OO characteristics (2/4)
Classification
Objects with the same data structure (attributes) and behavior (operations) are grouped into a class Abstraction that describes properties important to an application and ignores the rest
Polygon objects abstract into Polygon class
Attributes vertices border color fill color 2005-04-26

Operations draw erase move


6 / 20

OO characteristics (3/4)
Inheritance
Sharing of attributes and operations (features) among classes based on a hierarchical relationship
Super class has general information that subclasses refine and elaborate Each subclass incorporates, or inherits, all the features that subclass and adds its own unique features

Greatly reduce repetition


Ability to factor out common features of several classes into a superclass

2005-04-26

7 / 20

OO characteristics (4/4)
Polymorphism
Same operation behaves differently for different classes
Ex) + operation
Integer summation Float summation String summation

OO operator is polymorphic
Have more than one method implementing it
Each for a different class of object

2005-04-26

8 / 20

OO development (1/6)
Essence of OO development
Identification and organization of application concepts

Modeling concepts, not implementation


Focus on analysis and design Encourages software developers to work and think
Should be identified, organized, and understood Premature focus on implementation restricts design choices Design flaws during implementation costs more and leads to inferior product

Conceptual process independent of a programming language


2005-04-26 9 / 20

OO development (2/6)
OO Methodology
Methodology= building a model + adding details during design Following stages
System conception Analysis System design Class design Implementation

2005-04-26

10 / 20

OO development (3/6)
Modeling
Abstraction for the purpose of understanding before building it Purpose
Testing a physical entity before building it Communication with customers Visualization Reduction of complexity

2005-04-26

11 / 20

OO development (4/6)
Three models
Class model
Function
Describes the static structure of objects in a system Provides context for state and interaction model

Goal
Capture important concepts to an application from the real world

Representation
Class diagrams Generalization, aggregation

2005-04-26

12 / 20

OO development (5/6)
Three models (Contd)
State model
Function
Describes objects time and sequencing of operation

Goal
Capture control of system aspect that describes the sequences of operations that occur

Representation
State diagrams

2005-04-26

13 / 20

OO development (6/6)
Three models (Contd)
Interaction model
Function
Describes interactions between objects Individual objects collaborate to achieve the behavior of the whole system

Goal
Exchanges between objects and provides a holistic overview of the operation of a system

Representation
Use cases, sequence diagrams, activity diagrams

2005-04-26

14 / 20

OO themes (1/4)
Abstraction
Definition
Selective examination of certain aspects of a problem

Goal
Isolate important aspects, suppress unimportant aspects

Focus on essential aspects of an application


What an object is and does before deciding how to implement

Preserves the freedom to make decision as long as possible


Avoiding premature commitments to details

2005-04-26

15 / 20

OO themes (2/4)
Encapsulation
Separates the external aspects of an object from internal implementation Data structure and behavior is encapsulated in a single entity Ensuring reliability and maintainability
Information exchange is done by public interface among objects Change internal data structure does not affect other objects

2005-04-26

16 / 20

OO themes (3/4)
Combining data and behavior
Data structure hierarchy matches the operation inheritance hierarchy

data structure hierarchy

Is replaced by

class hierarchy

procedure hierarchy

Old approach
2005-04-26

OO approach
17 / 20

OO themes (4/4)
Sharing
No redundancy Reusability

Emphasis on the essence of an object


Focus on what an object is
Rather than how it is used

Synergy
Identity, classification, polymorphism, inheritance
Be clearer, more general and robust

2005-04-26

18 / 20

Evidence for usefulness of OO


OO development began at GE R&D
Used techniques for developing compilers, graphics, user interfaces, databases, an OO language, CAD system, simulations, metamodels, control systems, and other application

Advantage
Reusability Effective maintenance

Disadvantage
Not applicable in performance critical rather than data
2005-04-26 19 / 20

Summary
Object-oriented development
Low cost in system maintenance Adequate delivery on users requests
Flexible and elastic in frequent system change

Reusability Reliability Make easier team working and communication

2005-04-26

20 / 20

Inheritance Example 1
class Shape{ int x; int y; void setOrigin(int x, int y){ this.x=x; this.y=y; } } class Rectangle{ int x; int y; int width, height; void setOrigin(int x, int y){ this.x=x; this.y=y; } void setSize(int w, int h){ width=w; height=h; } } class Circle{ int x; int y; int radius; void setOrigin(int x, int y){ this.x=x; this.y=y; } void setRadius(int r){ radius=r; } }

2005-04-26

21 / 20

Inheritance Example 1
class Rectangle extends Shape{ int width; int height; void setSize(int w, int h){ width=w; height=h; } } class Circle extends Shape{ int radius; void setRadius(int r); radius=r; } }

2005-04-26

22 / 20

Inheritance Example 2
class A { int x; void f() { x = x+1; } } class B extends A { int y; void g() { y = y*2; } }

Instance structure of class A and B

Method sharing between instances


2005-04-26 23 / 20

You might also like