Top Banner
Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur
40

Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Jan 04, 2016

Download

Documents

Marcus Thomas
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Object Oriented Analysis & Design Using UML(CS-512)

M-Tech CSE (Ist & 3rd Sem) Part Time

Mr. Pawan LuthraAssistant Professor (CSE Deptt.)SBSSTC, Ferozepur

Page 2: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Object Oriented Design and Modelling

Object Oriented Fundamentals. Objects and object classes. Object oriented design process. Importance of modelling. Principles of modelling. Object oriented modelling.

Page 3: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Objects Oriented Fundamentals

Object Class Attribute Operation Interface (Polymorphism) Component Package Subsystem Relationships

Page 4: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Object

An object is an entity that has a state and a defined set of operations which operate on that state.

The state is represented as a set of object attributes. Informally, an object represents an entity, either physical,

conceptual, or software. An object has an identity, a state, and a behavior. An object is a concept, abstraction, or thing with sharp

boundaries and meaning for an application. Objects are entities in a software system which represent

instances of real-world and system entities. Object is a particular instance of a class. Objects are created according to some object class definition.

Page 5: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Properties of Objects

Object refers to an individual object. Each of object has a unique identity. even if all of its

attribute values are the same The state of an object is composed of a set of fields

(data fields), or attributes types or values. Each field has a name, a type, and a value. Behaviors means how an object acts an reacts. They

are defined by methods. Each method has a name, a type, and a value. Each method may or may not return a value.

Page 6: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Properties of Objects Contd…

Two objects are equal if their states are equal. Two objects are identical if they are the same objects. The values of the fields are mutable. Methods that do not modify the state of the object are

called accessors. Methods that modify the state of the object are called

mutators. Objects can be mutable or immutable.

Page 7: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Truck

Chemical Process

Linked List

What is an Object?

Informally, an object represents an entity, either physical, conceptual, or software Physical entity

Conceptual entity

Software entity

Page 8: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

: Professor

Professor Clark

a + b = 10

ProfessorClark : Professor

ProfessorClark

Class Name Only

Object Name Only

Class and Object Name (stay tuned for classes)

Representing Objects

An object is represented as rectangles with underlined names

Class name Only Object name Only

Class and Object name

Page 9: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Interacting objects

state o3

o3:C3

state o4

o4: C4

state o1

o1: C1

state o6

o6: C1

state o5

o5:C5

state o2

o2: C3

ops1() ops3 () ops4 ()

ops3 () ops1 () ops5 ()

Page 10: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Object Diagram with two instances

Page 11: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Object Classes

Class (or object class) refers to a set of objects that share a common structure and a common behavior.

A class is a description of a group of objects with common properties (attributes), behavior (operations), relationships, and semantics.

Object classes are serve as templates for objects. They may be used to create objects.

Object classes may inherit attributes and services from other object classes.

Page 12: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Properties of Object Classes

A class defines -- the names and types of all fields the names, types, implementations of all methods

The values of the fields are not defined or fixed in the class definition.

The values of the fields are mutable. Each instance of the class has its own state. Different instances of the class may have different

states. The implementations of methods are defined in the

class definition and fixed for a given object. Values of methods are immutable

Page 13: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

a + b = 10

ClassCourse

PropertiesName

LocationDays offeredCredit hours

Start timeEnd time

BehaviorAdd a student

Delete a studentGet course roster

Determine if it is full

Sample Class

Page 14: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Professor

Professor Clark

a + b = 10

Representing Classes

A class is represented using a compartmented rectangle

Page 15: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Professor

nameempID

create( )save( )delete( )change( )

Class Name

Attributes

Operations

Class Compartments

A class is comprised of three sections The first section contains the class name The second section shows the structure (attributes) The third section shows the behavior (operations)

Page 16: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Objects Class

Professor Smith

Professor Jones

Professor Mellon

Professor

The Relationship Between Classes and Objects

A class is an abstract definition of an object It defines the structure and behavior of each object

in the class It serves as a template for creating objects

Objects are grouped into classes

Page 17: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Class Diagram with two classes

Page 18: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

:CourseOffering

number = 101startTime = 900endTime = 1100

:CourseOffering

number = 104startTime = 1300endTime = 1500

CourseOffering

numberstartTime endTime

Class

Attribute

Object

Attribute Value

What is an Attribute?

Page 19: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

CourseOffering

addStudent deleteStudentgetStartTimegetEndTime

Class

Operation

What is an Operation?

Page 20: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Manufacturer AManufacturer B

Manufacturer C

OO Principle:Encapsulation

What is Polymorphism?

The ability to hide many different implementations behind a single interface

Page 21: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Tube

Pyramid

Cube

Shape

DrawMoveScaleRotate

<<interface>>

Realization relationship

What is an Interface?

Interfaces formalize polymorphism Interfaces support “plug-and-play” architectures

Page 22: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Tube

Pyramid

Cube

Shape

DrawMoveScaleRotate

<<interface>>

Tube

Pyramid

CubeShape

Elided/Iconic Representation

(“lollipop”)

Canonical (Class/Stereotype)

Representation

(stay tuned for realization

Interface Representations

Page 23: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Source FileName

<<EXE>>Executable

Name

OO Principle:Encapsulation

What is a Component?

A non-trivial, nearly independent, and replaceable part of a system that fulfills a clear function in the context of a well-defined architecture

A component may be A source code component A run time components or An executable component

<<DLL>>Component

NameComponent Interface

Page 24: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Package NameOO Principle:

Modularity

What is a Package?

A package is a general purpose mechanism for organizing elements into groups

A model element which can contain other model elements

Uses Organize the model under development A unit of configuration management

Page 25: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

OO Principles: Encapsulation and Modularity

<<subsystem>>Subsystem Name

InterfaceInterface

RealizationSubsystem

What is a Subsystem?

A combination of a package (can contain other model elements) and a class (has behavior)

Realizes one or more interfaces which define its behavior

Page 26: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

ComponentName

Design Model Implementation Model

<<subsystem>>Component Name

Component Interface

Component Interface

OO Principles: Encapsulation and Modularity

Subsystems and Components

Components are the physical realization of an abstraction in the design

Subsystems can be used to represent the component in the design

Page 27: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Relationships

Association Aggregation Composition

Dependency Generalization Realization

Page 28: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Professor UniversityWorks for

Class

Association

Association Name

Professor UniversityEmployerEmployee

Role Names

Relationships: Association

Models a semantic connection among classes

Page 29: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Student Schedule

Whole

Aggregation

Part

Relationships: Aggregation

A special form of association that models a whole-part relationship between an aggregate (the whole) and its parts

Page 30: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Student Schedule

Whole

Aggregation

Part

Relationships: Composition

A form of aggregation with strong ownership and coincident lifetimes The parts cannot survive the whole/aggregate

Page 31: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Association: Multiplicity and Navigation

Multiplicity defines how many objects participate in a relationships The number of instances of one class related to one instance

of the other class Specified for each end of the association

Associations and aggregations are bi-directional by default, but it is often desirable to restrict navigation to one direction If navigation is restricted, an arrowhead is added to indicate

the direction of the navigation

Page 32: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Association: Multiplicity

2..4

0..1

1..*

0..*

1

*

Unspecified Exactly one Zero or more (many, unlimited)

One or more Zero or one Specified range Multiple, disjoint ranges

2, 4..6

Page 33: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Student Schedule1 0..*

Multiplicity

Navigation

Example: Multiplicity and Navigation

Page 34: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Client Supplier

Package

ClientPackage SupplierPackage

Client Supplier

Class

Dependency relationship

Dependency relationship

Component

Relationships: Dependency

A relationship between two model elements where a change in one may cause a change in the other

Non-structural, “using” relationship

Page 35: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Relationships: Generalization

A relationship among classes where one class shares the structure and/or behavior of one or more classes

Defines a hierarchy of abstractions in which a subclass inherits from one or more superclasses Single inheritance Multiple inheritance

Generalization is an “is-a-kind of” relationship

Page 36: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Accountbalancenamenumber

Withdraw()CreateStatement()

Checking

Withdraw()

Savings

GetInterest()Withdraw()

Superclass (parent)

Subclasses

Generalization Relationship

Ancestor

Descendents

Example: Single Inheritance

One class inherits from another

Page 37: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Airplane Helicopter Wolf Horse

FlyingThing Animal

Bird

multipleinheritance

Use multiple inheritance only when needed, and always with caution !

Example: Multiple Inheritance

A class can inherit from several other classes

Page 38: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Component

Interface

Use Case Use-Case Realization

Elided form

Class

InterfaceSubsystem

Interface

Canonical form

Relationships: Realization

One classifier serves as the contract that the other classifier agrees to carry out

Found between: Interfaces and the classifiers that realize them Use cases and the collaborations that realize them

Page 39: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Any Queries?????........

Page 40: Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.

Thank You