object oriented analysis & design using uml (cs-512) m-tech cse (ist & 3rd sem) part time...

Post on 04-Jan-2016

220 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

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

Mr. Pawan LuthraAssistant 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.

Objects Oriented Fundamentals

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

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.

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.

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.

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

: 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

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 ()

Object Diagram with two instances

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.

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

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

Professor

Professor Clark

a + b = 10

Representing Classes

A class is represented using a compartmented rectangle

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)

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

Class Diagram with two classes

:CourseOffering

number = 101startTime = 900endTime = 1100

:CourseOffering

number = 104startTime = 1300endTime = 1500

CourseOffering

numberstartTime endTime

Class

Attribute

Object

Attribute Value

What is an Attribute?

CourseOffering

addStudent deleteStudentgetStartTimegetEndTime

Class

Operation

What is an Operation?

Manufacturer AManufacturer B

Manufacturer C

OO Principle:Encapsulation

What is Polymorphism?

The ability to hide many different implementations behind a single interface

Tube

Pyramid

Cube

Shape

DrawMoveScaleRotate

<<interface>>

Realization relationship

What is an Interface?

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

Tube

Pyramid

Cube

Shape

DrawMoveScaleRotate

<<interface>>

Tube

Pyramid

CubeShape

Elided/Iconic Representation

(“lollipop”)

Canonical (Class/Stereotype)

Representation

(stay tuned for realization

Interface Representations

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

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

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

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

Relationships

Association Aggregation Composition

Dependency Generalization Realization

Professor UniversityWorks for

Class

Association

Association Name

Professor UniversityEmployerEmployee

Role Names

Relationships: Association

Models a semantic connection among classes

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

Student Schedule

Whole

Aggregation

Part

Relationships: Composition

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

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

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

Student Schedule1 0..*

Multiplicity

Navigation

Example: Multiplicity and Navigation

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

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

Accountbalancenamenumber

Withdraw()CreateStatement()

Checking

Withdraw()

Savings

GetInterest()Withdraw()

Superclass (parent)

Subclasses

Generalization Relationship

Ancestor

Descendents

Example: Single Inheritance

One class inherits from another

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

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

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

Thank You

top related