I. adding attributes (Larman Ch. 12) A. Attributes What is an attribute? How is that different from an association? B. UML Notation for Attributes (12.2) ------------------------------------------ UML ATTRIBUTE NOTATION |-----------------| | Sale | |-----------------| | date | | startTime: Time | |-----------------| ------------------------------------------ C. Valid Attribute Types (12.3) 1. attributes have simple (atomic) types ------------------------------------------ VALID ATTRIBUTE TYPES (12.3) Types of attribute should be - simple or atomic: - object identity shouldn't matter (values, "data types") Common examples: 1. Boolean, Date, Number, String (Text), Time. 2. Address, Color, geometrics, phone number, Social Security number, universal productivity, ZIP Code. ------------------------------------------ ------------------------------------------ DON'T RELATE CONCEPTUAL CLASSES Use assocations if object identity matters: Good: 1 2 SynchPartnership ---- Computer, vs. Bad: SynchPartnership's computer1 computer2 attributes ------------------------------------------ How would you implement an attribute? D. on primitive data type classes (12.4) ------------------------------------------ WHEN TO USE A NON-PRIMITIVE CLASS (I.E., WHEN NOT TO USE AN ATTRIBUTE) Use a non-primitive class if the "value": - has separate sections (parts) - has operations associated with it, such as parsing - only a subset of its values are legal - has other attributes - is a quantity with a unit - is an abstraction of such a type ------------------------------------------ Can you give examples from StickSync? What about price in the POS system? amount? address? item ID? E. design creep: no attributes as foreign keys (12.5) F. modeling attribute quantities and units (12.6) Does an amount of money need units? Temperature? G. example (12.7) 1. StickSync What attributes are needed in the StickSync example to support Propogate File Change? ------------------------------------------ STICKSYNC PARTIAL DOMAIN MODEL |-----------| |---------| | Synch |* Stored-on 1| PMSD | |Partnership|-----------------|---------| |-----------| | name | | 1 |/freeSpace | |---------| | Consists-of | | 2 |--------------| | Computer | |--------------| | name | | OS | |--------------| | 1 | | Contains | | * |--------------|1 | Directory |---\ |--------------| | Contains | name |---/ |--------------|* | 1 | | Contains | | * |-------------| |--------------| | File | Contains | FileContents | |-------------|----------|--------------| | name |1 1| bytes | | modTime | |--------------| |-------------| ------------------------------------------ 2. POS System Process Sale What attributes are needed in the POS example to support Process Sale? ------------------------------------------ PARTIAL DOMAIN MODEL (Fig 10.1) |-----------| |---------| | Sales | Records-sale-of | Item | | LineItem |-----------------|---------| |-----------|0..1 1| | | quantity | |---------| |-----------| |* |1..* Stocked-in| | | |Contained-in |1 | |---------| |1 | Store | |-----------| |---------| | Sale | | address | |-----------| | name | | date |----| |---------| | time |1 | |1 |-----------| | | 1| | Houses| | | | Paid- | | | by | | |---------| | | Captured-on| Register| 1| |------------|---------| |-----------| 1| | | Payment | |---------| |-----------| | amount | |-----------| ------------------------------------------ H. derived attributes (12.8) I. conclusion (12.9) What makes a domain model good?