180 likes | 346 Views
Week 10. State diagrams Activity Diagrams Summary and Conclusion / The Future Critique discussion Lab 4 is marked. Remaining UML Diagrams. State diagram Activity diagram. States of an Object. Objects do not always react the same way to the same message (method call)
E N D
Week 10 • State diagrams • Activity Diagrams • Summary and Conclusion / The Future • Critique discussion • Lab 4 is marked Kate Gregory
Remaining UML Diagrams • State diagram • Activity diagram Kate Gregory
States of an Object • Objects do not always react the same way to the same message (method call) • Withdraw $100: will it succeed? Always? • It depends what state it is in: overdrawn, on hold, normal, … • Some objects have states worth studying Kate Gregory
State Diagram • Bank Account: Kate Gregory
When to draw a State Diagram • Not always and not for every object • If you have rules that depend on the state • Shipping fees can’t be calculated until order is approved • Accounts can’t be closed if there are outstanding service charges • If you have “side effects” of state transitions • Eg email alerts • Can be a compact and powerful way to direct a programmer • One of the few diagrams I update throughout the life of a project
How do you do it? • Identify a class that has interesting states • Give the states names • Usually adjectives • Pending/approved/archived/completed • Look at the existing methods to see which ones change the state • Look at the existing methods to see which ones depend on the state Kate Gregory
Notes become diagram • In what state is the object created? • In that state, what methods can be called? • And do they change the state or keep it the same? • Does it depend on some other value? • Are there side effects (eg send email?) • Continue until all the states are drawn • From what states can the object be destroyed?
Lab 5 • Should you add a state diagram? • What class or classes have interesting states? • What rules can you convey efficiently using a state diagram? • Re read the use cases Kate Gregory
Activity Diagram • Describes a sequence of activities (often a use case) • Illustrates the business process • Helpful when there are a lot of diversions and a lot of way to reach the same final situation • Clarifies order (as a sequence diagram does) but is not concerned with what objects and methods get the job done Kate Gregory
Morning Activity Diagram Kate Gregory
Lab 5 • Should you add an activity diagram? • Re read the use cases – are there parallel activities? • Is it necessary to co-ordinate activities at all? Kate Gregory
Requirements Use cases Use case diagrams Finding objects and their insides Candidate class lists CRC cards Collaboration diagrams Encapsulation, good and bad Where have we been? Kate Gregory
Class diagram Classes Attributes Object is not attribute Objects have identity Methods Parameters and types Relationships Association Aggregation Composition Inheritance polymorphism Where have we been? Kate Gregory
Where have we been? • Sequence / Interaction diagrams • Design patterns • Metrics • SOLID principles, RAII • Modules and packages • Deployment and component diagrams • State diagrams • Activity diagrams Kate Gregory
Next Week • Make sure you are signed up for a slot • Critiques start at 9 am – please be here! • No written submissions accepted after first presentation starts • Enter QUIETLY and respectfully • Come at start of class no matter when your presentation is, and stay for the whole thing Kate Gregory