1 / 21

classes

This article explains how to identify classes in use cases by looking for nouns and noun phrases that describe the nature or structure of information in the application. It also provides examples of attribute and operation declarations.

maryjames
Télécharger la présentation

classes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. classes • a class describes a group of objects with: • similar properties (attributes) • common behavior • common relationships to other objects • common meaning class diagramsshow classes with their attributes and operations, together with the associations between classes

  2. what might be a class? inventory system replenishment sale supplier stock clerk loading dock item for sale purchase order storage pattern physical count scanner stale dating airline reservation system reservation arrival travel agency customer travel office aircraft reservation flight timetable reservation transaction index reservation cancellation concept event organization person place physical item business concept logical entity application computer behavior

  3. finding classes in use cases • look for nouns and noun phrases in the description • of the use cases • include them in the model if they explain the nature • or structure of information in the application • but don’t create concepts which: • are beyond the scope of the system • refer to the system as a whole • duplicate other classes • are too vague or specific (few instances)

  4. describing a class unique simple name or path name (if it’s in a package) named property describing the range of values instances may hold optional behaviors the class can exhibit contract or obligation the class may have

  5. class name name of object simple name e.g. order, customer, campaign path name e.g. business rules::FraudAgent, java::awt::Rectangle client order +OrderForm +TrackingForm -Order A package is a general purpose mechanism for organizing elements (in this case classes) into groups

  6. attributes Wall + material : string + height : Float + width : Float attributes + thinkness : Float + isLoadBearing : Boolean = false - density : Float + dateBuilt : Date + public = can access from other classes - private = cannot access from other classes # protected = can access from subclasses

  7. attribute declaration [visibility] name [multiplicity] [: type] [= initial-value] [{property-string}] visibility name multiplicity type initial-value property-string + (public), # (protected), - (private) e.g. CustomerName, DiscountRate e.g. [0..1], [2..*] e.g. Point, String, Date, etc. e.g. =(0,0), = null changeable (default), addOnly, frozen 6 examples of legal attribute declarations origin origin : Point = (0,0) + origin id : integer {frozen} origin : Point name : [0..1] : String Booch, jacobson, Rumbaugh. The Unified Modeling Language User Guide. Addison Wesley. 1999. pg 127-128.

  8. operations operations Patient + makeAppointment ( ) + calculateLastVisit ( ) • examples of operations • change the value of attributes • change state • change links • invoke other objects + changeStatus ( ) + provideMedicalHistory ( ) + public # protected - private ( ) operation parameter

  9. operation signatures [visibility] name [(parameter-list)] [ : return-type] visibility name parameter-list return-type + (public), # (protected), - (private) e.g. restart, addStudent see below e.g. Integer, String, etc each parameter looks like this [direction] name : type [= default-value] direction name type default-value in, out, inout e.g. getId, calculateBonus Boolean, Money, etc. e.g. 42, John

  10. an example Campaign title : String campaignStartDate : Date campaignFinishDate : Date estimatedCost : Money actualCost : Money completionDate : Date datePaid : Date completed (completionDate : Date, actualCost: Money) parameters in signatures setFinishDate ( FinishDate : Date) recordPayment ( datePaid : Date ) returned value costDifference ( ) : Money

  11. classes and instances

  12. classes and subclasses

  13. types of classes

  14. salesStaff client sales staff liaises with 0..* 1 staffPosition staffMember is allocated to 0..* 1..* memberPosition

  15. links FoodCo is the client in the World Tradition campaign and associations staff members are assigned client(s) each client has one staff assigned to it

  16. class diagram

  17. class diagram

  18. class diagram

  19. CLASS NAME RESPONSIBILITIES COLLABORATING CLASSES operation 1 operation 2 operation 3 etc. class A none class B, class C CRC cards Class-Responsibility-Collaboration cards

  20. actor action 1.0 enter customerNumber 2.0 enter itemCode 3.0 enter itemQuantity 4.0 indicate order is complete E1.0 enter customerNumber E1.1 select addCustomer system response display customerName display itemDescription display itemPrice display orderAmount and orderNumber display “not found” message offer selection of exit or add customer invoke addCustomer exceptions basic flow

More Related