Docsity

Object Oriented Analysis & Design - Lecture # 3, Study Guides, Projects, Research of Designs and Groups

Partial preview of the text

Download Object Oriented Analysis & Design - Lecture # 3 and more Study Guides, Projects, Research Designs and Groups in PDF only on Docsity!

Object Oriented Analysis & Design

Lecture # 3

Department of Computer Science and Technology

University of Bedfordshire

Written by David Goodwin, based on the book Applying UML and Patterns (3rd^ ed.) by C. Larman (2005).

Modelling and Simulation, 2012

Oriented Analysis & Design

Introduction to Object Orientation

Objects

Class Attributes Operations Associations Aggregation Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

Package

Outline

Introduction to Object Orientation

Objects

Class

Attributes

Operations

Associations

Aggregation

Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

Oriented Analysis & Design

Introduction to Object Orientation

Objects

Class Attributes Operations Associations Aggregation Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

Object Orientation

I Knowing and object-oriented language (such as Java) is

a necessary but insufficient step to create object

systems.

I UML is just a diagramming tool; it’s full use isn’t

realised without object oriented design.

Oriented Analysis & Design

Introduction to Object Orientation

Objects

Class Attributes Operations Associations Aggregation Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

OOA/D

I Object-oriented analysis (OOA):

I (^) process of analysing a task (also known as a problem

domain)

I (^) finding and describing objects

I (^) typical:

I (^) set of use cases

I (^) one or more class diagrams

I (^) a number of interaction diagrams

I Object-oriented design (OOD):

I (^) defining software objects and how they collaborate to

fulfill the requirements. I (^) constraints to conceptual model produced in

object-oriented analysis I (^) Concepts in the analysis model are mapped onto

implementation classes and interfaces resulting in a

model of the solution domain.

Oriented Analysis & Design

Introduction to Object Orientation

Objects

Class Attributes Operations Associations Aggregation Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

Definition of an object

I Object:

I (^) Objects directly relate to real-world ‘entities’. I (^) An object has identity, state & behaviour.

I (^) Identity: the property of an object that distinguishes it

from other objects I (^) State: describes the data stored in the object

I (^) Behaviour: describes the methods in the object’s

interface by which the object can be used

I (^) The state of an object is one of the possible conditions

in which an object may exist. I (^) The state of an object is represented by the values of its

properties (attributes).

Oriented Analysis & Design

Introduction to Object Orientation

Objects

Class Attributes Operations Associations Aggregation Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

Definition of an object

I Real-world objects share three characteristics:

I (^) Identity:

I (^) Dog

I (^) Bicycle

I (^) State:

I (^) Dogs have state (name, color, breed, hungry)

I (^) Bicycles also have state (current gear, current pedal

cadence, current speed)

I (^) Behaviour:

I (^) Dogs have behaviour (barking, fetching, wagging tail)

I (^) Bicycles also have behaviour (changing gear, changing

pedal cadence, applying brakes)

Oriented Analysis & Design

Introduction to Object Orientation

Objects

Class Attributes Operations Associations Aggregation Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

Advantages of using objects

I Bundling code into individual software objects provides

a number of benefits, including:

I (^) Modularity:

I (^) The source code for an object can be written and

maintained independently of the source code for other

objects.

I (^) Information-hiding:

I (^) By interacting only with an object’s methods, the

details of its internal implementation remain hidden

from the outside world.

I (^) Code re-use:

I (^) If an object already exists, you can use that object in

your program.

I (^) Pluggability and debugging ease:

I (^) If a particular object turns out to be problematic, you

can simply remove it from your application and plug in

a different object as its replacement.

Oriented Analysis & Design

Introduction to Object Orientation

Objects

Class Attributes Operations Associations Aggregation Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

Class

Oriented Analysis & Design

Introduction to Object Orientation

Objects

Class Attributes Operations Associations Aggregation Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

Class example in Java

I (^) The fields cadence, speed,

and gear represent the

object’s state, and the

methods (changeCadence,

changeGear, speedUp etc.)

define its interaction.

Oriented Analysis & Design

Introduction to Object Orientation

Objects

Class Attributes Operations Associations Aggregation Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

Class example in Java

I (^) Not a complete

application; it’s just

the blueprint for

bicycles that might be

used in an application.

The responsibility of

creating and using new

Bicycle objects belongs

to some other class in

your application.

Oriented Analysis & Design

Introduction to Object Orientation

Objects

Class Attributes Operations Associations Aggregation Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

What is an attribute?

I An element of data that helps to describe an object.

I Attribute types may be restricted by a programming

language.

I A class that includes many attributes may be

decomposed into other classes.

I Complex attribute lists in a class may be defined

elsewhere.

Oriented Analysis & Design

Introduction to Object Orientation

Objects

Class Attributes Operations Associations Aggregation Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

What is an operation?

I It helps to specify the behaviour of a class (object).

I Can use the syntax of a programming language.

I Specify the visibility of each operation:

I (^) public (+);

I (^) private (-);

I (^) protected (#).

I Consider the responsibilities of each class:

I (^) Responsibilities often imply more than one operation.

I (^) A method is the implementation of an operation.

Oriented Analysis & Design

Introduction to Object Orientation

Objects

Class Attributes Operations Associations Aggregation Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

Package

Class Associations

I An association represents a family of links.

I Binary associations (with two ends) are normally

represented as a line.

I An association can be named, and the ends of an

association can be adorned with role names, ownership

indicators, multiplicity, visibility, and other properties.

I There are four different types of association:

I (^) bi-directional, uni-directional, Aggregation (includes

Composition aggregation) and Reflexive.

I Bi-directional and uni-directional associations are the

most common ones.

I (^) For instance, a flight class is associated with a plane

class bi-directionally. Association represents the static

relationship shared among the objects of two classes.

Example: “department offers courses”, is an association

relation

Oriented Analysis & Design

Introduction to Object Orientation

Objects

Class Attributes Operations Associations Aggregation Composition

Inheritance

Dependency

Multiplicity

Polymorphism

Encapsulation

Interface

Aggregation

I Whole/Part relationship.

I ‘Smaller’ classes are parts of ‘larger’ classes.

I Objects belonging to an aggregate can belong to more

than one class.

I Each class that makes up an aggregation relationship is

a class in its own right.