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: Cashier -- Register, vs. Bad: Cashier's currentRegister attribute ------------------------------------------ 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 - 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 ------------------------------------------ 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) What attributes are needed in the POS example to support Process Sale? H. derived attributes (12.8) I. conclusion (12.9) What makes a domain model good?