Docstoc

Conceptual Modeling

Document Sample
Conceptual Modeling Powered By Docstoc
					Conceptual Modeling

        A Short Discussion
          Outline

   Conceptual modeling
       The goal of conceptual modeling
   The OO solution
   The object model (conceptual)
       Syntax and semantics
   Object modeling approach
       Home Heating System
             Conceptual Modeling

   Early modeling to understand the problem
   Conducted in cooperation with the customer
       Domain experts
            Domain engineers
   No real problem analysis if the customer is not involved
   Power of OO
       It is simple and people can quickly participate effectively
          The OO Solution

   The OO model closely resembles the problem
    domain
       Base your model on the objects in the problem domain
   Iteratively refine the high-level model until you
    have an implementation
       Attempt to avoid big conceptual jumps during the
        development process
Objects




 State of Michigan
 Drivers License
                     VISA
 J. Q. Public
 A-123456            J. Q. Public
 03-12-63            123 4567 887766 998
Attributes and Operations
                                                   Person class
Person objects                                Attributes
                                                       name
                                                       age
                               abstracts to
                                                       height
                                                       weight
                                              Operations
                                                       move
                                                       change-job

       Card objects                             Card class
State of Michigan                               Attributes
 Drivers License                                         height
                      VISA                               width
 J. Q. Public                                            id-number
 A-123456                                       Operations
 03-12-63             J. Q. Public
                                                         issue
                      123 4567 887766 998
                                                         change
         Characteristics of Objects

   Identity
        Discrete and distinguishable entities
   Classification
        Abstract entities with the same structure (attributes) and behavior
         (operations) into classes
   Polymorphism
        The same operation may behave differently on different classes
   Inheritance
        Sharing of attributes and operations based on a hierarchical
         relationship
The Class Diagrams
          Objects

   Something that makes sense in the application context
    (application domain)
       J.Q. Public
       Joe’s Homework Assignment 1
       J. Q. Public’s drivers license
   All objects have identity and are distinguishable
   NOT objects
       Person
       Drivers license
       Classes

   Describes a group of objects with similar properties (attributes),
    common behavior (operations), common relationships to other
    classes, and common semantics
   Person
              J. Q. Public
              Joe Smith
              D. Q. Public
   Card
              Credit card
              Drivers license
              Teller card
    Class Diagrams
Class diagram                      Instance diagram
      Person                 Person             Person
   name: String             D. Q. Public            J. Q. Public
   age: integer
                                32                       35

Class with attributes               Objects with values


               Person              Objects have an identity
       person ID: integer          Do not explicitly list
         name: String              object identifiers
          age: integer             SSN OK!
Examples

   Person

 name: String
 age: integer            Card
height: integer
weight: integer      height: integer
 SSN: integer        width: integer
                   thickness: integer
                  id-number: integer
          Operations and Methods

   Transformation that can be         May have arguments
    applied to or performed by an
    object



              Card                                 Shape
         height: integer                       height: integer
         width: integer                        width: integer
       thickness: integer
      id-number: integer                   rotate(angle: integer)
                                         move(x: integer, y: integer)
             issue()
            revoke()
Object Notation - Summary

               Class name
attribute-1 : data-type-1 = default-value-1
attribute-2 : data-type-2 = default-value-2
attribute-3 : data-type-3 = default-value-3

operation-1(argument-list-1) : result-type-1
operation-2(argument-list-2) : result-type-2
operation-3(argument-list-3) : result-type-3
             Associations

   Conceptual connection between classes
        A credit card is issued-by a bank
        A person works-for a company

                        Issued-by 8
          Credit Card                     Bank



                        Works-for 8
                                                            Class diagrams
            Person                     Company




          Person                         Company
                        Works-for8
        J.Q. Public                   Michigan State Univ
                                                             Instance diagram
            35
       Associations are Bi-directional

   There is no direction implied in an association
    (Rumbaugh - OMT)

            Country        Has-capital   City
            name                         name



           Person     Is-issued   Drivers-license
           name                   lic.-number: integer
        Associations Have Direction

   Unified adds a direction indicator
       Inconsistently used

               Country        Has-capital   City
               name                         name



             Person      Is-issued   Drivers-license
             name                    lic.-number: integer
        Multiplicity
                             Person            Holds 8               Credit-card
One person holds one
                           name: String                       card-number: integer
credit card

   One object can be related to many objects
    through the same association


One person can hold zero           Person         Holds 8   0..*
                                                                       Credit-card

                                name: String                       card-number: integer
or more credit cards
(* stands for many)
       Multiplicity (Cont.)

One person can hold zero or more credit cards (0..*)
Each card has zero or one holder (0..1)
                      Person                                  Credit-card
                                     0..1 Holds8   0..*
                    name: String                          card-number: integer



                                   Credit-Card


        Person         Holds8      123 456 789

     J. Q. Public
          35
                                                     Credit-Card                 Person
                       Holds8                                               D.Q. Public
                                   Credit-Card       111 222 333
                                                                                  32

                                   111 222 333
                   Multiplicity (Cont.)
*
•One person can hold zero or more credit cards (0..*)
•Each card has one holder (no indication or 1)
•Each card has one or more authorized users (1..*)                 Explicit enumeration is also
•One person can be authorized to use zero or more cards            possible (2, 3, 2..5, etc.)
•Driver’s License is optional (0..1)


                                                                                                       Credit-Card
               1        Holds8       0..*
    Person                                      Credit-card                         3Authorized
                                                                                                       123 456 789
                       3Authorized                                     Person
                                                                                            Holds8
name: String                                card-number: integer
                                                                    J. Q. Public
                1..*                 0..*                                35
                                                                                              Holds8
                                                                                    3Authorized
                                                                                                       Credit-Card

             Holds 8 0..1         Driver’s License                                                     111 222 333
                                                                                    3Authorized
                                                                       Person
                              License-number: integer
                                                                     D. Q. Public
                                                                                               Holds8
                                                                         32                           Credit-Card
                                                                                      3Authorized

                                                                                                       111 222 333
              Higher order associations

   Ternary association
        Project, language, person                      1..*                     1..*
                                            Language                                    Project
   Seldom needed (and should be avoided)
                                                                          1..*


                                                                     Person




                                            Language                              Project
                                              C++                                Compiler

                                                                Person
                                                               J. Q. Public
                                                                   35

                                             Language                             Project
                                               LISP                              TicTacToe
          Link Attributes

   Associations can have properties the same way objects have properties


         Person
                                                     Company         How to represent
       name: String     0..*   Works-for8
       age: integer                                 name: String     salary and job title?
       SSN: integer                                address: String
      address: String




         Person                                       Company
       name: String     0..*    Works-for8
       age: integer                                 name: String
       SSN: integer                                address: String
      address: String                                                 Use a link attribute!

                               salary: integer
                               job-title: String
         Folding Link Attributes

    Person                                                              Why not this?
 name: String                                           Company
  age: integer      0..*    Works-for 8                                 Salary and job title are
 SSN: integer                                          name: String
address: String                                       address: String   properties of the job not
salary: integer                                                         the person
job-title: String




    Person                                              Company
 name: String       0..*    Works-for8         0..*
 age: integer                                          name: String
 SSN: integer                                         address: String    In this case, a link
address: String
                                                                         attribute is the only
                           salary: integer                               solution
                           job-title: String
        Another Approach

    Person

 name: String                            Company
 age: integer
 SSN: integer                           name: String
address: String                        address: String




                    Position       *



                  Salary:integer
                  Grade:integer
                   Title:string
         Role Names

   Attach names to the ends of an association to
    clarify its meaning


             Person                                                     Company
           name: String     0..*         Works-for8            0..*
   boss    age: integer                                                name: String
     0..1                   employee                       employer
           SSN: integer                                               address: String
          address: String
             0..*
Manages8     worker
                                       salary: integer
                                       job-title: String
              Aggregation
*

       A special association, the is-part-of association
           A sentence is part of a paragraph (a paragraph consists
            of sentences)
           A paragraph is part of a document (a document
            consists of paragraphs)


                            1..*                 1..*
              Document             Paragraph            Sentence



                         Aggregation symbol
            Aggregation (Cont.)

   Often used in parts explosion

                      Car



      4
    Wheel      Body         Gearbox     Engine



     1..*                             1..*       1..*
       Door    Hood         Trunk     Piston       Valve   Crankshaft
               Generalization and Inheritance

   The is-a association                                       Card

        Cards have many                                   height: integer
                                                           width: integer
         properties in common                            thickness: integer
        Generalize the common                          id-number: integer

         properties to a separate                             issue()
                                                             revoke()
         class, the base-card
        Let all cards inherit from
         this class, all cards is-a
         base-card (plus possibly
         something more)
                                      Drivers License       ID Card               Credit Card

                                       class: vehicle    issued: date         credit-limit: integer
                                        issued: date     expires: date           issued: date
                                       expires: date
                                                            expire()               validate()
                                          expire()
         Example
                                                                        Owns


                                                     Works-for              Pilot
  City                          Airline
             Based-In 0..*
 name                           name                             0..*       name
                                                                           license

Located-In                           Offers                                    1..*   Certified-On
                                                                  Pilots
     0..*                                                                                               0..*
Airport                                     0..*                                                          Plane
               Departs                                                                        0..*
 name                                0..*           Flight                                               model
                                                      date                                              serial #
heat()                Arrives                                               Used-For
                                                    flight #                                          hours flown
clean()                              0..*
                                                   cancel()                                               heat()
                                                    delay()                                              refuel()
                                                                                                         clean()

                                                                                            30..*
                                                         0..*                                  Seat
                  Passenger                                                                  location
                    name                      Confirmed-for                                  reserve()
          Aggregation Versus
          Association

   Can you use the phrase is-part-of or is-made-of
   Are operations automatically applied to the parts (for
    example, move) - aggregation
   Not clear what it should be……

                          0..*                 0..*
           Company               Division             Department



          3Works-for
                0..*

            Person
            Aggregation Versus
            Inheritance
   Do not confuse the is-a
    relation (inheritance) with the                               4   Wheel
    is-part-of relation
    (aggregation)                                                      Body
   Use inheritance for special
                                                 Car
    cases of a general concept                                        Gearbox
   Use aggregation for parts
    explosion                                                         Engine

                                 Minivan   Compact      Jeep


                                                       Roll Bar
          Recursive Aggregates

   A recursive aggregate contains (directly or indirectly) an instance of
    the same kind of aggregate
                                               Program




                                        0..*
                                                Block




                                   Compound               Simple
                                   Statement             Statement
           Object Modeling Summary

   Classes                  Aggregation
       Name                 Inheritance
       Attributes
       Operations
   Associations
       Roles
       Link attributes
Object Modeling Approach
          Object Modeling Approach

   Start with a problem statement
       High-level requirements
   Define object model
       Identify objects and classes
       Prepare data dictionary
       Identify associations and aggregations
       Identify attributes of objects and links
       Organize and simplify using inheritance
       Iterate and refine the model
       Group classes into modules
                    The Home Heating System

                                                Water Valve
                    Water Pump


         Hot Water                                             Home
                                   Controller
                    Burner

                              90
Fuel Valve
                              80   Off

                              70
                                   On
                              60
             Fuel
                              50



                             Control Panel
                                                 Temp Sensor
              Home Heating Requirements

       The purpose of the software for the Home Heating System is to control the heating system that
       heats the rooms of a house. The software shall maintain the temperature of each room within a
       specified range by controlling the heat flow to individual rooms.

                                                                When the furnace is not running and a room needs
   The software shall control the heat in each room
                                                                 heat, the software shall turn the furnace on
   The room shall be heated when the temperature is 2F
                                                                To turn the furnace on the software shall follow
    below desired temp
                                                                 these steps
   The room shall no longer be heated when the
                                                                       open the fuel valve
    temperature is 2F above desired temp
                                                                       turn the burner on
   The flow of heat to each room shall be individually
    controlled by opening and closing its water valve           The software shall turn the furnace off when heat is
                                                                 no longer needed in any room
   The valve shall be open when the room needs heat
    and closed otherwise                                        To turn the furnace off the software shall follow
                                                                 these steps
   The user shall set the desired temperature on the
    thermostat                                                         close fuel valve
   The operator shall be able to turn the heating system              turn burner off
    on and off
   The furnace must not run when the system is off
        Identify Object Classes

Requirements           Extract                Tentative                 Eliminate              Object
 Statements            Nouns                Object Classes           Spurious Classes          Classes



                                   Candidate Classes
  Water Pump                                                                Controller

    Hot Water                        operator
                                                                     Home Heating System
                                                           house
                  furnace          thermostat
     Burner                                                        room       Water Valve       range
                                   heating system
          Fuel Valve                                          temperature
                                                    heat                            software
                         desired temp                                  Home
                Fuel                             Temp Sensor
                            on-off switch                           Control Panel
            Eliminate Bad Classes

   Redundant classes                             Operations
        Classes that represent the same               Sequences of actions are often
         thing with different words                     mistaken for classes
   Irrelevant classes                            Roles
        Classes we simply do not care                 The name of a class should reflect
         about                                          what it is, not the role it plays
   Vague classes                                 Implementation details
        Classes with ill defined boundaries           Save that for implementation
   Attributes
        Things that describe individual
         objects
         Eliminate Classes

Redundant              Irrelevant                 Vague                     Attributes
heating system                                  heat      house             desired temp
                      Fuel    software
  user                                           heat flow        home             temperature
                        Hot Water
                                                          range
      Operations                    Roles                 Implementation
          None                        None                           None



                 Fuel Valve                   Burner
    Water Pump                    furnace                    Home Heating System
                                                room
                              operator                       Temp Sensor        Water Valve
                 thermostat
                                             Controller
                  on-off switch                               Control Panel
   Classes After Elimination


                                               Burner
                    Fuel Valve
                                                     Home Heating System
Water Pump
                                 Room

                      Furnace                                      Water Valve
Thermostat
                                               Temp Sensor

                           on-off switch
         Operator                                        Control Panel

                                        Controller
          Prepare Data Dictionary

   Water Tank
       The storage tank containing the water that circulates in
        the system.
   Pump-1
       The pump pumping water from the Water Tank to the
        radiators in the rooms
          Possible Associations
                                       A room consists of a thermometer and a radiator
                                       A radiator consists of a valve and a radiator element
   Not much information from the      The home heating system consists of a furnace, rooms, a
    prose requirements                  water pump, a control panel, and a controller
                                       The furnace consists of a fuel pump and a burner
   A lot of information from the      The control panel consists of an on-off switch and a
    system design                       thermostat
                                       The controller controls the fuel pump
                                       The controller controls the burner
                                       The controller controls the water pump
                                       The controller monitors the temperature in each room
                                       The controller opens and closes the valves in the rooms
                                       The operator sets the desired temperature
                                       The operator turns the system on and off
                                       The controller gets notified of the new desired temperature
            Object Model
                                           Home Heating
                                             System




              Control Panel                                               Furnace              Water Pump 3Runs




                                                                         Burner            Fuel Valve
            On-Off Switch        Thermostat

                                                  1..*
               3Pushes        Adjusts8
                                                   Room

                    Operator                                                                   3Opens/Closes
                                                                                          3Ignites
Notifies8




                                         Water Valve                 Temp Sensor




                                                                                    3Monitor
                                                         3Actuates




                                                                                                         Controller
              Object Model - Modified
                                          Home Heating
                                            System




              Control Panel                                      Furnace      Water Pump       Runs




                                                                Burner     Fuel Valve
           On-Off Switch         Thermostat

                                                 1..*                             Opens/Closes
                Pushes        Adjusts                                       Ignites
                                                  Room   1..*
Notifies




                    Operator                             1..*




                                                                                    Monitor
                                                                            Heats
                                        Water Valve       Temp Sensor

                                                                                              Controller
Attributes

                Thermostat
                desired-temp




On-Off switch                  Temp Sensor
setting                        temperature
              Final Object Model
                                          Home Heating
                                            System




              Control Panel                                      Furnace      Water Pump       Runs




                                                                Burner     Fuel Valve
           On-Off Switch         Thermostat
                                desired-temp
              setting                                                             Opens/Closes
                                                 1..*
                Pushes        Adjusts                                       Ignites
                                                  Room   1..*
Notifies




                    Operator                             1..*




                                                                                    Monitor
                                                                            Heats
                                        Water Valve       Temp Sensor
                                                          temperature                         Controller
         Iterate the Model

   Keep on doing this until
    you, your customer, and
    your engineers are happy
    with the model


                               Iterate
         Operation vs Method

   Operation: specifies object behavior
   Service: represented by set of operations.
   Message: object requests execution of an opern. from
    another object by sending it mesg.
   Method: mesg is matched up with method defined by the
    class to which the receiving object belongs (or any of its
    superclasses)
   Operations of class are public services offered by class.
   Methods of its classes are the implementations of these
    operations.

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:7
posted:12/11/2011
language:
pages:49