CH06: Considering Objects TECH Computer Science Set, Class, Type …of… Objects, Actors, Agents...

Post on 13-Jan-2016

217 views 0 download

Transcript of CH06: Considering Objects TECH Computer Science Set, Class, Type …of… Objects, Actors, Agents...

CH06: Considering Objects

TECH Computer Science

Set, Class, Type…of…

Objects, Actors, AgentsData and Actions

• Object-Oriented Design and Development• Intro to UML (Unified modeling Language)

Diagrams

CH01

Class vs. Object

• A class is a collection, a group, a set, or a type of …e.g.PeopleStudent

• An object is an instance or an individual of a classe.g.People TomStudent Marry

Class and its UML Box

• DataState, attributes

• BehaviorAction, transformation, operation

Triggered by receipt of particular message, or entrance into a particular state

Relations between Classes

• Subclasse.g.People

Student

• Hierarchy• Inheritance (is-a)

Association relation between classes• Public Class Employee

• {

• public String lastName;

• …

• public Address homeAddress;

• …

• }

• Public class Address

{

}

Employee

-lastName : String

Address

-homeAddress

Association relation between classes (bidirectional)• Public Class Team

• {• LinkedList members = new LisnkedList();

• …

• }

• Public class member

{

Team memberOf;

}

Team

Member

Composition and Aggregation

Dependency

• A dependency exists between the two if a class uses another class in some fashion

Using Class Diagram to show a design

More UML diagrams

Use case diagram

Activity Diagram

State Diagram

Sequence Diagram

Collaboration Diagram

Package Diagram

OO Design

• Identify classesA set of objects sharing a common structure and

common behaviorsLooking for Things (nouns)

StructuresExternal systemsDevicesRolesOperating proceduresPlacesOrganizationsThings that are manipulated by the system to be builds

BehaviorsVerbs

OO Measurement: MetricTable 6.7: Where to capture OO metrics.

Phase

Metric

Use cases Classdiagrams

Inter-actiondiagrams

Class descrip-tions

Statediagrams

Packagediagrams

Number of scenario scripts XNumber of key classes XNumber of support classes XAverage number ofsupport classes per keyclass

X

Number of subsystems XClass size X XNumber of operationsoverridden by a subclass

X

Number of operationsadded by a subclass

X

Specialization index XWeighted methods in class XDepth of inheritance XNumber of children XCoupling between objects XResponse for a class XLack of cohesion inmethods

X

Average operation size XAverage number ofparameters per operation

X

Operation complexity XPercent public andprotected

X

Public access to datamembers

X

Number of root classes XFan-in/fan-out X