Ppt slides 05


Published on

1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Ppt slides 05

  1. 1. PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 5: Restaurant System: Analysis
  2. 2. Analysis <ul><li>What is to be analyzed? </li></ul><ul><ul><li>the system requirements </li></ul></ul><ul><li>Why? </li></ul><ul><ul><li>to demonstrate their implementability </li></ul></ul><ul><li>How? </li></ul><ul><ul><li>by drawing interaction diagrams realizing use cases </li></ul></ul>
  3. 3. Analysis v. Design <ul><li>Difficult to draw a boundary </li></ul><ul><li>Traditional informal distinction: </li></ul><ul><ul><li>analysis models the real-world system </li></ul></ul><ul><ul><li>design models the software </li></ul></ul><ul><li>Object-oriented methods use the same notation for both activities </li></ul><ul><ul><li>encourages ‘seamless development’ and iteration </li></ul></ul>
  4. 4. Object Design <ul><li>We need to define attributes and operations for each class in the model </li></ul><ul><li>Start from domain model, but: </li></ul><ul><ul><li>structure of real-world application is not always the optimal structure for a software system </li></ul></ul><ul><ul><li>domain model does not show operations </li></ul></ul><ul><li>Realization identifies operations and confirms that design supports functionality </li></ul>
  5. 5. Object Responsibilities <ul><li>Each class in a system should have well-defined responsibilities </li></ul><ul><ul><li>to manage a subset of the data in the system </li></ul></ul><ul><ul><li>to manage some of the processing </li></ul></ul><ul><li>The responsibilities of a class should be cohesive </li></ul><ul><ul><li>they should ‘belong together’ </li></ul></ul><ul><ul><li>they should form a sensible whole </li></ul></ul>
  6. 6. Software Architecture <ul><li>A software architecture a high level view of software, described as a number of of distinct components or subsystems together with their relationships and interaction . </li></ul><ul><li>Description of UML component/deployment may be used to document architectures </li></ul><ul><li>Architectures are the configurations of components that make up the systems. </li></ul><ul><li>Architectural pattern is a high level pattern describing a solution at architectural level. </li></ul><ul><li>Architectures are the configurations of components that make up the systems. </li></ul>
  7. 7. Software Architecture <ul><li>A software architecture describes a configurations of a number of distinct components or subsystems together with their relationships and interaction. Or more simply, architectures are the configurations of components that make up the systems. Different Architectural Styles, such as client/server or layered, data centric, address different design problems. </li></ul>
  8. 8. Software Architecture Types <ul><li>Data-flow: concentrates on the flow of data e.g. batch processing. </li></ul><ul><li>Data-centered: focuses on centralised persistent data e.g. data base. </li></ul><ul><li>Virtual-machine: layered software e.g. ISO OSI seven layer model. </li></ul><ul><li>Call-return: focuses on a sequence of instruction, single thread of control. </li></ul><ul><li>Independent-component: supports modifiability e.g. client server. </li></ul>
  9. 9. UML and Architecture <ul><li>To be useful, architecture must be described in a clear, explicit way to serve as the basis for understanding, implementation reuse, and evolution of the system. In the UML packages , profiles , component and deployment diagrams may be used to document architectures. </li></ul><ul><li>Designing the architecture of the system is part the RUP process (using packages and profiles etc). </li></ul><ul><li>RUP considers architecture as central and is included in the process. </li></ul><ul><li>The UML also provides an architectural view of how its own components fit together. </li></ul>
  10. 10. Business Object <ul><li>A car hire company with branches at major airports plans to develop a web-based system to support customer-based functions, such as car hiring, and company focused activities, such as maintaining the vehicle fleet. </li></ul>
  11. 11. Possible Business Object <ul><li>Customer : Someone who checks on the availability of cars, makes contractual arrangements for hiring cars, takes cars out, returns them, is billed for this service and who in turn makes payments. Without customers the business model would not make sense and could not function. </li></ul><ul><li>Car : Cars are reserved for use, taken out (and returned) by customers, maintained and repaired. The business is a car hire business; without cars the business model would not make sense. </li></ul><ul><li>Hire Contract : These are agreed between customers and the business. They are contractual arrangements for the provision of car rental services for a specified period of time. Hire contracts are fundamental to how the business operates and how operational data is recorded </li></ul>
  12. 12. Possible Architecture <ul><li>A possible architectural approach is to structure a system as a number of tiers including presentation, application, and storage tier. All of these are supported by a layer of software which is relatively independent of a given application (e.g. networks and operating systems). </li></ul>
  13. 13. Possible Architecture <ul><li>The use of a three tier architecture is the core of a distributed application. </li></ul><ul><li>Presentations tier: HCI can go on the client and does not require to be transmitted over network. Usually a browser that can talk HTTP. The presentation tier should provide the essential logic for user interaction. The presentation tier would contain facilities which allow the user to interact with the stored data in the other tiers. </li></ul><ul><li>Processing tier: Business objects reflect domain entities i.e. Customer, Car, and Hiring Business objects shield the implementation of data, they are not just reflections of database tables. The application tier provides the essential logic for the particular system. </li></ul><ul><li>Data or storage tier should handle persistence, usually requires files or a database. </li></ul><ul><li>Support layers software such as; middleware, operating systems, network software must be included. </li></ul>
  14. 14. Three tier architecture
  15. 15. Advantages of three-tier architecture <ul><li>A three-tier architecture is used mainly for maintenance reasons. Such an architecture allocates most of the code in the middle and data layer to the server, with the presentation layer residing on the client. This means that when a change occurs, for example a change to an object-to-database mapping, it only usually affects one copy of the software: the part residing on the server. It also means that when a change in functionality occurs the effect on the presentation layer is minimised. Other advantages tiers and layers– </li></ul><ul><ul><li>separation of function </li></ul></ul><ul><ul><li>modular development </li></ul></ul><ul><ul><li>building on work of others </li></ul></ul><ul><ul><li>reusable components </li></ul></ul><ul><ul><li>substitutable components </li></ul></ul><ul><ul><li>use of standard protocols </li></ul></ul>
  16. 16. Tiers mapped to system functions <ul><li>The presentation tier would enabled the customer to: </li></ul><ul><ul><li>create a car booking; </li></ul></ul><ul><ul><li>check car availability at a given airport ; </li></ul></ul><ul><li>The presentation tier would enabled the an employee to: </li></ul><ul><ul><li>retrieve the current status of a car </li></ul></ul><ul><ul><li>check the history of a car </li></ul></ul><ul><li>The middle tier would contain business objects which would correspond to entities in the application. Typical business objects would include: </li></ul><ul><ul><li>a cars details; </li></ul></ul><ul><ul><li>a booking details; </li></ul></ul><ul><ul><li>a maintenance history ; </li></ul></ul><ul><li>The database tier would usually contain relational tables which would store the business objects (need mapping between tables and objects). For example there would be a table which listed all the cars, customers, and a hiring related cars to cstomers. </li></ul><ul><li>The support layers are important, but are usually support and are more concerned with implementation rather than analysis. However, they still provide the architecture with the advantage of reuse in general purpose features. </li></ul>
  17. 17. Software Architecture <ul><li>The UP analysis workflow includes the production of an architectural description </li></ul><ul><li>This defines: </li></ul><ul><ul><li>the top-level structure of subsystems </li></ul></ul><ul><ul><li>the role and interaction of these subsystems </li></ul></ul><ul><li>Typical architectures are codified in patterns </li></ul><ul><ul><li>for example, layered architectures </li></ul></ul>
  18. 18. A Layered Architecture <ul><li>Subsystems are shown as UML packages linked by dependencies </li></ul><ul><li>A dependency without a stereotype means uses </li></ul>
  19. 19. Separation of Concerns <ul><li>Layers aim to insulate a system from the effects of change </li></ul><ul><li>For example, user interfaces often change </li></ul><ul><ul><li>but the application layer does not use the presentation layer </li></ul></ul><ul><ul><li>so changes to system should be restricted to presentation layer classes </li></ul></ul><ul><li>Similarly, details of persistent data storage are separated from application logic </li></ul>
  20. 20. Analysis Class Stereotypes <ul><li>Within this architecture objects can have various typical roles </li></ul><ul><ul><li>boundary objects interact with outside actors </li></ul></ul><ul><ul><li>control objects manage use case behaviour </li></ul></ul><ul><ul><li>e ntity objects maintain data </li></ul></ul><ul><li>These are represented explicitly in UML by using analysis class stereotypes </li></ul>
  21. 21. Class Stereotype Notation <ul><li>Stereotypes can be text or a graphic icon </li></ul><ul><li>The icon can replace the normal class box </li></ul>
  22. 22. Restaurant Domain Model(4.10)
  23. 23. Restaurant Use Case Diagram(4.7)
  24. 24. Use Case Realization <ul><li>Begin with functionality in application layer </li></ul><ul><li>‘ Display Bookings’: simple dialogue </li></ul><ul><ul><li>the user provides the required date </li></ul></ul><ul><ul><li>the system response is to update the display </li></ul></ul><ul><li>Initial realization consists of </li></ul><ul><ul><li>instance of the ‘Staff’ actor </li></ul></ul><ul><ul><li>an object representing the system </li></ul></ul><ul><ul><li>message(s) passed between them </li></ul></ul>
  25. 25. System Messages <ul><li>System messages are sent by an actor </li></ul><ul><li>Represent system by a controller </li></ul><ul><ul><li>initially analysing use case behaviour, not I/O </li></ul></ul><ul><ul><li>(Fig. 5.3) </li></ul></ul>
  26. 26. Sequence Diagrams <ul><li>Time passes from top to bottom </li></ul><ul><li>Instances of classes and actors at top </li></ul><ul><ul><li>only show those participating in this interaction </li></ul></ul><ul><ul><li>each instance has a lifeline </li></ul></ul><ul><li>Messages shown as arrows between lifelines </li></ul><ul><ul><li>labelled with operation name and parameters </li></ul></ul><ul><ul><li>return messages (dashed) show return of control </li></ul></ul><ul><ul><li>activations show when receiver has control </li></ul></ul>
  27. 27. Accessing Bookings <ul><li>How does the system retrieve the bookings to display? </li></ul><ul><li>Which object should have the responsibility to keep track of all bookings ? </li></ul><ul><ul><li>if this was an additional responsibility of the ‘BookingSystem’ object it would lose cohesion </li></ul></ul><ul><ul><li>so define a new ‘Restaurant’ object with the responsibility to manage booking data </li></ul></ul>
  28. 28. Retrieving Bookings <ul><li>Add a message to get relevant bookings </li></ul><ul><li>‘ updateDisplay’ is an internal message </li></ul><ul><li>(fig. 5.4) </li></ul>
  29. 29. Retrieving Booking Details <ul><li>Dates of individual bookings will need to be checked by the ‘Restaurant’ object (fig. 5.5) </li></ul>
  30. 30. Refining the Domain Model <ul><li>This realization has involved: </li></ul><ul><ul><li>new 'Restaurant' and 'BookingSystem' classes, with an association between them </li></ul></ul><ul><ul><li>an association from ‘Restaurant’ to ‘Booking’ </li></ul></ul><ul><ul><ul><li>‘ Restaurant’ maintains links to all bookings </li></ul></ul></ul><ul><ul><ul><li>messages sent from restaurant to bookings </li></ul></ul></ul><ul><ul><li>an association from ‘BookingSystem’ to ‘Booking’ </li></ul></ul><ul><ul><ul><li>‘ BookingSystem’ maintains links to currently displayed bookings </li></ul></ul></ul>
  31. 31. Updated Class Diagram <ul><li>Operations are derived from messages sent to the instances of a class (fig. 5.6) </li></ul>
  32. 32. Recording New Bookings <ul><li>Give ‘Restaurant’ responsibility for creation </li></ul><ul><ul><li>don’t model details of user input or data yet (fig. 5.7) </li></ul></ul>
  33. 33. Creating a New Booking <ul><li>Bookings must be linked to table and customer objects </li></ul><ul><ul><li>responsibility of ‘Restaurant’ to retrieve these, given identifying data in booking details </li></ul></ul><ul><li>New objects shown at point of creation </li></ul><ul><ul><li>lifeline starts from that point </li></ul></ul><ul><ul><li>objects created by a message arriving at the instance (a constructor ) </li></ul></ul>
  34. 34. Creating a New Booking <ul><li>This completes the previous diagram (fig. 5.8) </li></ul>
  35. 35. Cancelling a Booking <ul><li>A three-stage process: </li></ul><ul><ul><li>select on screen the booking to be cancelled </li></ul></ul><ul><ul><li>confirm cancellation with user </li></ul></ul><ul><ul><li>delete the corresponding booking object </li></ul></ul><ul><li>Object deletion represented by a message with a ‘destroy’ stereotype </li></ul><ul><ul><li>lifeline terminates with an ‘X’ </li></ul></ul><ul><li>Role names used to distinguish selected object from others displayed </li></ul>
  36. 36. Cancelling a Booking (fig 5.9)
  37. 37. Refining the Domain Model (2) <ul><li>‘ BookingSystem’ has the responsibility to remember which booking is selected </li></ul><ul><li>Add an association to record this (Fig. 5.10) </li></ul>
  38. 38. Recording Arrival (5.11) <ul><li>Selected booking must be a reservation </li></ul>
  39. 39. Class Interface Design <ul><li>Should ‘setArrivalTime’ be defined in Booking or Reservation class? </li></ul><ul><ul><li>on the one hand, it doesn't apply to walk-ins </li></ul></ul><ul><ul><li>but we want to preserve a common interface to all bookings if possible </li></ul></ul><ul><li>Define operation in ‘Booking’ class </li></ul><ul><ul><li>default implementation does nothing </li></ul></ul><ul><ul><li>override in ‘Reservation’ class </li></ul></ul>
  40. 40. Refined Class Hierarchy (5.12)
  41. 41. Summary <ul><li>Analysis has led to: </li></ul><ul><ul><li>a set of use case realizations </li></ul></ul><ul><ul><li>a refined class diagram </li></ul></ul><ul><li>We can see how the class design is going to support the functionality of the use cases </li></ul><ul><li>This gives confidence that the overall design will work </li></ul>
  42. 42. Summary <ul><li>Analysis can be defined as the activity of representing the application domain and the system’s requirement in terms of the object model </li></ul><ul><li>The basic analysis technique is the production of use case realizations , which demonstrate how the functionality specified in a use case could be delivered by a set of interacting objects. </li></ul>
  43. 43. Summary <ul><li>Realizations can be documented using one of the forms of interaction diagram defined in UML i.e. collaboration or sequence diagrams. </li></ul><ul><li>Producing use case realizations will suggest changes in the domain model, which will evolve into more detailed analysis class model . </li></ul><ul><li>A central metaphor of object design is to make objects responsible for a subset of the data and operations in the system. </li></ul>
  44. 44. Summary <ul><li>The Unified Process includes an architectural description as one of the product analysis. A widely used architectural approach is to structure a system as a number of layers, for example presentation, application, and storage layer. </li></ul><ul><li>The objects in a system can be assigned a number of roles, to clarify the organization of the system. UML defines class stereotypes boundary , control and entity objects </li></ul>
  45. 45. Summary <ul><li>User interaction can be shown on realizations by means of system messages received by control objects. There can be one control object per use case or one representing the system as a whole. </li></ul>
  46. 46. Complete Analysis Class Model (5.13)