dicegamecasestudy-11-30-6-090308095528-phpapp02

download dicegamecasestudy-11-30-6-090308095528-phpapp02

of 12

Transcript of dicegamecasestudy-11-30-6-090308095528-phpapp02

  • 8/13/2019 dicegamecasestudy-11-30-6-090308095528-phpapp02

    1/12

    265

    An Example of ObjectOriented Analysis and Design

    A Dice Game

    Play Rules / Business Rules:

    A dice game in which a player rolls two dice.

    If the total is seven, they win; otherwise, they lose.

    The dice game is very simple problem, presented in order tofocus on some of the steps and artifacts in object oriented

    analysis and design rather than on the problem domain.

  • 8/13/2019 dicegamecasestudy-11-30-6-090308095528-phpapp02

    2/12

    266

    Most essential and commonly used steps in OOAD

    Define usecases

    Define

    conceptual

    model

    Definecollaboration

    diagrams

    Define design

    class diagrams

    System Behaviordiagram

    Analysis Design

  • 8/13/2019 dicegamecasestudy-11-30-6-090308095528-phpapp02

    3/12

    267

    Understanding the requirements includes, in part, understanding the

    domain processes and the external environment external actors who

    participate in processes.

    These domain processes can be expressed in use cases

    narrative descriptions of domain processes in a structured text format

    For example, in the dice game, here is the Play Game High level

    usecase

    Use case: Play a Game

    Actors: PlayerDescription: This use case begins when then

    the player picks up and rolls the

    dice. If the dice total seven, they

    win; other wise, they lose

    Define use cases

  • 8/13/2019 dicegamecasestudy-11-30-6-090308095528-phpapp02

    4/12

    268Expanded Usecase:

    SI

    NoActors Action SI

    NoSystem Response

    1 This use case beginswhen the Playerstarts

    the game by picking

    up the diceand then

    playerrolls the the

    dice

    2

    2a

    Die Gamewill collect face

    value of each diceand then

    adds up to give the sum ofthe face value(total) for a

    particular roll.

    If the dice totalis 7 then

    system will indicate theplayerthat he wins, and

    request theplayerto

    continue the game.

    Alternate path to 2a: the total is 7 then the player looses the game

  • 8/13/2019 dicegamecasestudy-11-30-6-090308095528-phpapp02

    5/12

    269

    Usecase Diagram

  • 8/13/2019 dicegamecasestudy-11-30-6-090308095528-phpapp02

    6/12

    270

    A decomposition of the problem domain involves an identification of

    concepts

    attributes

    associations

    in the domain that are considered important.

    The result can be expressed in a conceptual model, which is

    illustrated in a set of diagrams that depict concepts (objects).

    Define conceptual model

  • 8/13/2019 dicegamecasestudy-11-30-6-090308095528-phpapp02

    7/12

    271

    Conceptual model of the Dice game

    The conceptual model is not a description

    of software components; it represents

    concepts in the real world

    problem domain.

  • 8/13/2019 dicegamecasestudy-11-30-6-090308095528-phpapp02

    8/12

    272

    Defining Collaboration Diagrams

    Collaboration diagrams show the flow of messages betweeninstances and the invocation of methods

    Object - oriented design is concerned with defining logical software

    specificationsthat fulfill the functional requirementsbased on

    decompositionby classes of objects.

    An essential step in this phase is the allocation of responsibilitiesto

    objects and illustration how they interact via messages, expressed in

    collaboration diagrams.

  • 8/13/2019 dicegamecasestudy-11-30-6-090308095528-phpapp02

    9/12

    273

    Defining Collaboration Diagrams Illustrating messages

    between software objects

    For example, assume that a simulation in software of the dice game

    is desired. This collaboration diagram in Figure illustrates the

    essential step of playing by sending messages to instances of the

    Player and die classes.

  • 8/13/2019 dicegamecasestudy-11-30-6-090308095528-phpapp02

    10/12

    274

    Defining Design Class DiagramsThese illustrate class definitions that are to be implemented

    in software

    In order to define a class, several questions must be answered How do objects connect to other objects?

    What are the methods of a class?

    To answer these questions, inspect the collaboration diagrams,

    which suggests the necessary connections between objects,and the methods that each software class must define

  • 8/13/2019 dicegamecasestudy-11-30-6-090308095528-phpapp02

    11/12

    275

    Design class diagram of software components.

    For example, in the dice game, an inspection of the collaboration

    diagram leads to the following design class diagram.

    In contrast to the conceptual model, this diagram does not

    illustrate real world concepts; it describes software components

    276

  • 8/13/2019 dicegamecasestudy-11-30-6-090308095528-phpapp02

    12/12

    276

    Design class diagram of software components........

    Since a play message is sent to a Player instance, Playerrequires a play method, while Die requires a roll method.

    To illustrate how objects connect to each other via

    attributes, a line with an arrow at the end may suggest anattribute.

    For example, Dice Game has an attribute that points to aninstance of a Player.(visibility issues)