3.Identifying Relation

download 3.Identifying Relation

of 17

Transcript of 3.Identifying Relation

  • 8/8/2019 3.Identifying Relation

    1/17

    Identifying Object Relationships,

    Attributes and Methods

  • 8/8/2019 3.Identifying Relation

    2/17

    Identifying Relationships

    There are three types of relationships that may exists in

    between any two objects

    Association

    Super-Sub Structure

    Aggregation (A special case of association)

  • 8/8/2019 3.Identifying Relation

    3/17

    Association

    Represents a physical or conceptual connection betweentwo objects

    Identifying Associations

    Analyzing the interactions between classes The following questions are answered for identification of

    associations

    Is the class capable of fulfilling the required task by itself?

    If not, what does it need?

    From what other class can it acquire what it needs?

  • 8/8/2019 3.Identifying Relation

    4/17

    Guidelines for identifying association

    A dependency between two or more classes may be anassociation. Association often corresponds to a verb or

    prepositional phrase such as part-of, next-to, works-for,

    etc.,

    A reference from one class to another is an association.

    Some associations are implicit or taken from general

    knowledge

    Choose the association names carefully. Add role

    name where appropriate.

  • 8/8/2019 3.Identifying Relation

    5/17

    Common association Patterns

    Location Association -

    next-to, part-of, contained-in, etc.,

    Communication Association -

    talk-to, order-to, etc.,

    Cheese Soup

    Part of

    Customer Operator Order-to

  • 8/8/2019 3.Identifying Relation

    6/17

  • 8/8/2019 3.Identifying Relation

    7/17

    Super-Sub relationships

    Represents the inheritance relationship between related

    classes

    This is also called as generalization hierarchy.

    The top level class more general called as base, superclass or ancestor

    The bottom level class more specific called as derived,

    sub class or successor

  • 8/8/2019 3.Identifying Relation

    8/17

    Guidelines for identifying super-sub relation

    Top-down

    Look for the noun phrases composed of various adjectives in a class

    name. E.g.., A tall man and a short man

    Bottom-up

    Look for the classes with similar attributes or methods. The commons

    are grouped into super class

    Reusability

    Move the attributes and behaviors to the top-level of the hierarchy.

    Dont create specialized class in the top-level.

  • 8/8/2019 3.Identifying Relation

    9/17

    Multiple Inheritance

    Avoid using multiple inheritance. Since they are very

    complicated in implementation point of view. Use only the

    class that is more appropriate as super class and define the

    other classs attributes here also.

  • 8/8/2019 3.Identifying Relation

    10/17

    Aggregation

    Represents the situation where a class consists of several

    component classes

    Properties of Aggregation

    Transitivity

    If A is a part-of B and B is a part-of C. Then A is a

    part-of C.

    Antisymmetry

    If A is a part-of B. Then B is Not a part-of A.

  • 8/8/2019 3.Identifying Relation

    11/17

    Identifying Aggregation

    The following questions are answered for identification of

    aggregation

    Does the part class belong to the problem domain?

    Is the part class within the systems responsibilities?

    Does the part class capture more than a single value? If single

    value then set it as an attribute.

    Does it provide a useful abstraction in dealing with problem

    domain?

  • 8/8/2019 3.Identifying Relation

    12/17

    Aggregation Relationship Patterns

    Assembly -

    An assembly is constructed from its parts.

    E.g.., Coffee is assembly of Coffee powder, water

    Container -

    The container contains, not constructed from the parts.

    E.g.., House contains furniture and other appliances.

    Collection member -

    Collection of conceptual or physical parts.

    E.g.., Cricket team is a collection of players

  • 8/8/2019 3.Identifying Relation

    13/17

    Identifying Attributes

    The attributes are identified from scenario testing.

    Hence by analyzing the use-cases, sequence, collaboration,state chart, activity diagrams, the classes responsibilities

    are identified.

  • 8/8/2019 3.Identifying Relation

    14/17

    Guidelines for identifying attributes

    Attributes are usually corresponds to nouns, phrases,

    adjectives and adverbs.

    Keep the class simple. State only enough attributes.

    Attributes are less defined in the problem statement. It is

    obtained by general knowledge.

    Omit derived attributes

    Dont waste much time in finding attributes. This can bedone in successive iterations.

  • 8/8/2019 3.Identifying Relation

    15/17

    Identifying Methods and Messages

    Methods are the services provided by the objects

    They are responsible to manage the value of the attributes.

  • 8/8/2019 3.Identifying Relation

    16/17

    Identifying methods by analyzing UML diagrams

    The sequence diagram says about the events that occur

    between two objects.

    This event is considered to be an action that transmits

    information between two objects

    These actions are the methods that the object should

    perform.

    For each class the methods are defined by analyzing the

    sequence diagram of all the related use-cases

  • 8/8/2019 3.Identifying Relation

    17/17

    For E.g.., for account class, the methods are identified

    by analyzing the sequence diagrams of the following use-cases.

    Deposit Checking

    Deposit Savings

    Withdraw Checking

    Withdraw more from Checking

    Withdraw Savings

    Withdraw Savings denied

    Checking Transaction History

    Savings Transaction History