10
Identifying Object Relationships, Attributes and Methods .

Identifying O bject R elationships, Attributes and Methods

Embed Size (px)

DESCRIPTION

Identifying O bject R elationships, Attributes and Methods. Guidelines for Identifying Association. Class A and B are associated if An object of class A sends a message to an object of class B An object of class A creates an object of class B - PowerPoint PPT Presentation

Citation preview

Page 1: Identifying  O bject  R elationships, Attributes and Methods

Identifying Object Relationships, Attributes and Methods

.

Page 2: Identifying  O bject  R elationships, Attributes and Methods

2

Guidelines for Identifying Association

Class A and B are associated if• An object of class A sends a message to an

object of class B• An object of class A creates an object of class B• An object of class A has an attribute whose

values are objects of class B• An object of class A receives a message with an

object of class B as an argument

Page 3: Identifying  O bject  R elationships, Attributes and Methods

Guidelines for Identifying a Super-sub Relationship

• Top-down Look for noun phrases composed of adjectives in a

class name.

• Bottom upLook for classes with similar attributes or methods

Page 4: Identifying  O bject  R elationships, Attributes and Methods

Identifying the Composition & Aggregation/a-part-of Relationship

• Composition - a physical whole is constructed from physical parts (Assembly)

Eg1: Building constructed by bricks, stones Eg2: ATM with Card Reader, Console, Printer, Key Pad

• Aggregation - a physical whole encompasses but is not constructed from physical parts (Container)

Eg1: Building with Furniture, Appliances Eg2: Car with AC and Radio

• Collection-member – a conceptual whole encompasses parts that may be physical or conceptual

Eg: Employer and employees

Page 5: Identifying  O bject  R elationships, Attributes and Methods

Case Study – ATM Identifying the Class & Relationship

Page 6: Identifying  O bject  R elationships, Attributes and Methods

Case Study – ATM Identifying the Class, Relationship & Attribute

Page 7: Identifying  O bject  R elationships, Attributes and Methods

Case Study – ATM Identifying the Class, Relationship, Attribute & Method

Page 8: Identifying  O bject  R elationships, Attributes and Methods

Example on Identifying Object Relationships

.

Page 9: Identifying  O bject  R elationships, Attributes and Methods

Object Relationship in Code• Association public class A {

public void doSomething(B b) { }}

• Aggregationpublic class A {

private B b1;public void setB(B b) { b1 = b; } }

• Compositionpublic class A {

private B b1;public A() {

b1 = new B();} }

Page 10: Identifying  O bject  R elationships, Attributes and Methods

Object Relationship in Code• Generalizationpublic class A {

...} // class A

public class B extends A {....} // class B

• Realizationpublic interface A {

...} // interface A

public class B implements A {...} // class B