Kate Gregory Week 10 State diagrams Activity Diagrams Summary and Conclusion / The Future Critique discussion Lab 4 is marked
DateWeekTopicHand OutDue BackTest 6-Sep-131Administrivia / Overview / Motivation, benefits of OO 13-Sep-132Use CasesLab 1: Use cases 20-Sep-133CRC Cards, collab graphsLab 2: CRC cardslab 1 5% 27-Sep-13 4start class diaglab 2 5% 4-Oct-135Finish class diag, AssociationsLab 3: Class Diag 11-Oct-136Inh & Polymorphism / midterm reviewlab 3 5% 18-Oct-137midtermMidterm 25% 25-Oct-13Reading Break 1-Nov-138Interaction diag / Design PatternsLab 4: Interaction Diag 8-Nov-139Good Design / Modules & Packages / Deployment and component diagrams /Metrics / SOLID Lab 5: Critiqueslab 4 5% 15-Nov-1310State diagrams / Activity diagrams / Summary and Conclusion / The Future 22-Nov-1311Critiquescritique lab (before class) 15% 29-Nov-1312Critiques 11-Dec-13 Final Exam, 9am - noon, AB 108 GYMFinal 40%
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:
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 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 ?) 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
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
Where have we been? Requirements –Use cases –Use case diagrams Finding objects and their insides –Candidate class lists –CRC cards –Collaboration diagrams –Encapsulation, good and bad
Kate Gregory Where have we been? Class diagram –Classes –Attributes Object is not attribute Objects have identity –Methods Parameters and types –Relationships Association Aggregation Composition Inheritance –polymorphism
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