COM 244 Object Oriented Programming Some parts of
COM 244 Object Oriented Programming Some parts of those slides are adapted on course materials by Stuart Reges http: //www. cs. washington. edu/331/
Object Oriented Analysis and Design • A development methodology is a set of practices employed develop software to • E. g. Extreme Programming or Rational Unified Process • UML is not a software development methodology, it is a representation that is intended to offer a standard way to envisage the design of a system. • All methodologies includes given • Plan: analysis && design parts • Build : code &&unit test • Release : integration, functional testing, maintainance • Previously these steps were commonly considered as a sequence, namely waterfall development • Today, it is often taken as subsequent iterations of these steps namely, agile development 2
Planning • Planning includes analysis and design parts respectively: • In OO, planning aims to discover • The objects required by the system • Attributes and responsibilities of each object • Interaction between objects • Analysis is understanding the problem, whereas Design is figuring out how to organize the solution once. Therefore, a good Analysis results in good Design. • The size of the project directly regulates how diverse planning, building, and release stages… 3
UML – Use Cases • The purpose of a use case diagram in UML is to establish the different ways that a user might interact with a system. • Made up of scenarios, which are a(m example) sequence of steps defining an interaction • Users are called actors • Stick figures for actors • Ovals for use cases Each actor interacts with one or ‘n’ use cases depending on the problem. 4
UML – Use Cases 1. 2. A Librarian staff lends the Book to the Reader This staff gets back the book from the Reader 5
UML – Use Cases (ATM) • The system is started up as to "on". the operator turns the operator switch • The system is shut down as operator switch to the "off" position. • A session is started when a customer inserts the card into the slot • A transaction use case is started within a session when the customer chooses a transaction 6
UML – Use Cases (ATM) (2) • A withdrawal transaction asks the customer to choose a type of account to withdraw from. . . • A transfer transaction asks the customer to choose a type of account to transfer from … • An inquiry transaction asks the customer to choose a type of account to inquire about from a menu of possible accounts. 7
UML – Use Cases 8
The Principle of OOA • Customer knows the problem domain, what the system requires to do • Development team knows how to use software resources to design a system according to problems’ requirements • There can be different techniques employed for OOA depending on the specific methodology used 9
Object Discovery • The aim is to find objects that can become part of the system • Inspect system specifications • Even the smallest project should have some kind of written specification • Use Cases and CRC Cards (will be detailed detection shortly) can help in • Initially, try to find as many candidate objects as possible • Specification may be inaccurate or imperfect • It is common to find mistakes in customer’s specification, so it is crucial to work carefully with the customer 10
CRC Cards Class Responsibility Collaborator (CRC) model, as shown in the following table. A class signifies a collection of related objects, a responsibility is something that a class does, and a collaborator is another class which has an interaction with to accomplish its responsibilities. Class Name Responsibilities Collaborators 11
CRC Cards Customer Place Orders Names Adresses ……… Order Placement Date Delivery Date Order ID ……… Order. Item 12
CRC Cards Customer Place Orders Names Adresses ……… Order Placement Date Delivery Date Order ID ……… Order. Item 13
UML Sequence Diagrams • A sequence diagram simply represents interaction between objects in a successive order. • Sequence diagram is a widespread dynamic modeling solution in UML since they explicitly focus on lifelines, or the processes and objects that live concurrently. • Denote the details of a UML use case and model the logic of a refined procedure, function, or operation. • Example object instances are revealed horizontally with lifetimes that stretch vertically • Time drives from top to bottom 14
UML Sequence Diagrams ATM Startup Sequence Diagram 15
UML Sequence Diagrams ATM Shutdown Sequence Diagram 16
Some Design Guidelines • Designing Classes • A class needs a determination • Classes vs. attributes • Associations vs. inheritance • E. g. Square – Shape – Drawing • A class can’t do everything • Inheritance • Is-A Test: All classes in an inheritance must pass the is-a test • Move attributes and methods as high as possible • But do not overstate this • Determine superclasses 2012 17 17
Other Diagrams • Collaboration Diagrams A collaboration diagram is a communication diagram or interaction diagram which is an illustration of interactions among real life objects. 18
Other Diagrams • State Diagrams • Used if an object has well-defined states • UML state machine diagrams show the various states that an object may be in and the transitions between those states. • Airport traveler processing scenario is illustrated below: 19
Other Diagrams Activity diagram is essentially a flowchart to represent the flow from one activity to another activity. The activity can be described as an operation of the system. An activity diagram is a special case of a state chart diagram in which states are activities (“functions”). For instance an elevator ride. State diagram may contain following states entering, waiting, exit, arrived. These state transitions are caused by activity diagram events. Related events in an activity diagram may be: Move in to the elevator, press button for the correct floor, leave the elevator. An ordinary user’s login to the system is displayed on a activity diagram shown at the following slide: 20
Activity Diagram 21
Other Diagrams • Package diagram is UML structure diagram, illustrating structure of the designed system at the level of packages 22
- Slides: 22