1 / 57

CHAPTER 6

CHAPTER 6. OBJECT ORIENTED ANALYSIS. Learning Objectives. Understand object oriented concepts Be able to understand and/or draw object oriented analysis modeling: Use case diagram Activity diagram Class diagram Sequence diagram Collaboration diagram State diagram.

harry
Download Presentation

CHAPTER 6

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CHAPTER 6 OBJECT ORIENTED ANALYSIS Object-Oriented Analysis

  2. Learning Objectives • Understand object oriented concepts • Be able to understand and/or draw object oriented analysis modeling: • Use case diagram • Activity diagram • Class diagram • Sequence diagram • Collaboration diagram • State diagram Object-Oriented Analysis

  3. Object-Oriented Concepts • Must be understood to apply class-based elements of the analysis model • Key concepts: • Classes and objects • Attributes and operations • Encapsulation and instantiation • Inheritance Object-Oriented Analysis

  4. Classes • object-oriented thinking begins with the definition of a class, often defined as: • template • generalized description • “blueprint” ... describing a collection of similar items • a superclass establishes a hierarchy of classes • once a class of items is defined, a specific instance of the class can be identified Object-Oriented Analysis

  5. Building a Class Class name Attributes Operations Object-Oriented Analysis

  6. Encapsulation/Hiding Class encapsulates both data and the logical procedures required to manipulate the data Reduces the propagation of side effects when changes occur method # 2 method # 1 data method # 3 method # 6 method # 4 method # 5 Achieves“information hiding” Object-Oriented Analysis

  7. Class Hierarchy PieceOfFurniture (superclass) Table Chair Desk ”Chable" Subclass inherit both attributes and operations from a superclass subclasses of the Subclasses of the furniture superclass Instances of chair instances of Chair Object-Oriented Analysis

  8. Methods(a.k.a. Operations, Services) An executable procedure that is encapsulated in a class and is designed to operate on one or more data attributes that are defined as part of the class. A method is invoked via message passing. Object-Oriented Analysis

  9. Attributes A collection of data values that describe a class Object-Oriented Analysis

  10. Instances of a specific class • Inherit a class attributes and operations Class : STUDENT Object instance (object): Ali attributes : name, date of birth, etc. operations :calc_age, calc_cgpa, etc. Objects Object-Oriented Analysis

  11. Example STUDENT Name DOB Address Phone Calculate_age Calculate_gpa Register_course Object-Oriented Analysis

  12. Object Oriented Analysis (OOA) • Based on objects rather than data or processes • The intent of OOA is to define all classes (and the relationships and behavior with them) that are relevant to the problem to be solved • There are various OOA methods. Booch Method, Jacobson Method and Rumbaugh Method have collaborated into. Unified Approach – Unified Modeling Language (UML) Object-Oriented Analysis

  13. THE OOA PROCESS Use Case Modeling – shows functions Class-based Modeling – Class diagram, CRC Behavioral Model – State Diagram, Sequence Diagram Object-Oriented Analysis

  14. USE CASE MODELING • Illustrates the manner in which an actor interacts with the system • Actor= “ Anything that communicates with the system and that is external to the system” • Can be people or devices • Represent the roles that people/devices play as the system operates • Use Case • Depiction of a system’s behavior or functionality under various conditions as the system responds to requests from users • Full functioning for a specific business purpose Represent actor Represent a use case Object-Oriented Analysis

  15. Use-Cases • A collection of user scenarios that describe the thread of usage of a system • Each scenario is described from the point-of-view of an “actor” • Each scenario answers the following questions: (eg: refer handout “Use Case Template for Surveillance”) • Who is the primary actor, the secondary actor (s)? • What are the actor’s goals? • What preconditions should exist before the story begins? • What main tasks or functions are performed by the actor? • What extensions might be considered as the story is described? • What variations in the actor’s interaction are possible? • What system information will the actor acquire, produce, or change? • Will the actor have to inform the system about changes in the external environment? • What information does the actor desire from the system? • Does the actor wish to be informed about unexpected changes? Object-Oriented Analysis

  16. A c c e s s c a m e r a s u r v e i l l a n c e v i a t h e I n t e r n e t h o m e o w n e r Use-Case Diagram S a f e H o m e c a m e r a s C o n f i g u r e S a f e H o m e s y s t e m p a r a m e t e r s S e t a l a r m Object-Oriented Analysis

  17. Eg: consider the interactions between a Bank Customer and an ATM Bank ATM Machine Withdraw Cash Check Balance Bank Customer Create Online Transaction Object-Oriented Analysis

  18. Writing Use-Cases (Scenario) • Use case:Access camera surveillance-display camera views (ACS-DCV) • Actor:homeowner If I’m at remote location, I can use any PC with appropriate browser software to log on to the SafeHome Products Web site. I enter my user ID and two levels of passwords and, once I’m validated, I have access to all functionality for my installed SafeHome system. To access specific camera view, I select “surveillance” from the major function buttons displayed, I then select “pick camera”, and the floor plan of the house is displayed. I then select the camera that I’m interested in. Alternatively, I can look at thumbnail snapshots from all cameras simultaneously by selecting “all cameras” as my viewing choice. Once I choose a camera, I select “view” and a one-frame-per-second view appears in a viewing window that is identified by the camera ID. If I want to switch cameras, I select “pick a camera” and the original viewing window disappears and the floor plan of the house is displayed again. I then select the camera that I’m interested in. A new viewing window appears. • A variation of this narrative use case is an ordered sequence of user actions – refer handout “Use Case Template for Surveillance “(Pressman, R. (2005). Software Engineering : A Practitioner's Approach, 6th edition. New York : McGraw-Hill) • . Object-Oriented Analysis

  19. Use-Case Modeling • Relationships Between Use Cases • Use cases may participate in relationships with other use-cases • Two types • Extends • Adds new behaviors or actions to a use case • Include • One use case references another use case 20.19 Object-Oriented Analysis

  20. Example: Use-case diagram for a university registration system (Correction: arrow direction should be in opposite direction) 20.20 Object-Oriented Analysis

  21. Object-Oriented Analysis

  22. Activity Diagram • Supplements the use-case by providing a diagrammatic representation of procedural flow • May adds additional detail not directly mentioned by the use case Activity/Function Flow/Transition Decision Object-Oriented Analysis

  23. An activity diagram for Access Camera surveillance Object-Oriented Analysis

  24. ATM Authorization Baca kad Masuk kad Minta PIN Masuk PIN [Tidak] Sahkan PIN Adakah sah? [Ya] Pilih servis Object-Oriented Analysis

  25. Class-Based Modeling • Identify analysis classes by examining the problem statement • Use a “grammatical parse” to isolate potential classes • Identify the attributes of each class • Identify operations that manipulate the attributes Object-Oriented Analysis

  26. Analysis Classes • External entities (e.g., other systems, devices, people) that produce or consume information to be used by a computer-based system. • Things(e.g, reports, displays, letters, signals) that are part of the information domain for the problem. • Occurrences or events (e.g., a property transfer or the completion of a series of robot movements) that occur within the context of system operation. • Roles (e.g., manager, engineer, salesperson) played by people who interact with the system. • Organizational units (e.g., division, group, team) that are relevant to an application. • Places (e.g., manufacturing floor or loading dock) that establish the context of the problem and the overall function of the system. • Structures(e.g., sensors, four-wheeled vehicles, or computers) that define a class of objects or related classes of objects. Object-Oriented Analysis

  27. Selecting Classes—Criteria • Retained Information • Needed services – have a set of identifiable operations • Multiple attributes • Common attributes • Common operations • Essential requirements Object-Oriented Analysis

  28. CRC Modeling • Analysis classes have “responsibilities” • Responsibilities are the attributes and operations encapsulated by the class • Analysis classes collaborate with one another • Collaborators are those classes that are required to provide a class with the information needed to complete a responsibility. • In general, a collaboration implies either a request for information or a request for some action. Object-Oriented Analysis

  29. Class: Class: Class: Description: Class: FloorPlan Description: Description: Responsibility: Collaborator: Description: Responsibility: Collaborator: Responsibility: Collaborator: Responsibility: Collaborator: defines floor plan name/type manages floor plan positioning scales floor plan for display Wall incorporates walls, doors and windows shows position of video cameras Camera CRC Modeling Object-Oriented Analysis

  30. Class Types • Entity classes, also called model or business classes, are extracted directly from the statement of the problem (e.g., FloorPlan and Sensor). • Boundary classesare used to create the interface (e.g., interactive screen or printed reports) that the user sees and interacts with as the software is used. • Controller classesmanage a “unit of work” [UML03] from start to finish. That is, controller classes can be designed to manage • the creation or update of entity objects; • the instantiation of boundary objects as they obtain information from entity objects; • complex communication between sets of objects; • validation of data communicated between objects or between the user and the application. Object-Oriented Analysis

  31. Responsibilities • System intelligence should be distributed across classes to best address the needs of the problem • Each responsibility should be stated as generally as possible • Information and the behavior related to it should reside within the same class • Information about one thing should be localized with a single class, not distributed across multiple classes. • Responsibilities should be shared among related classes, when appropriate. Object-Oriented Analysis

  32. Collaborations • Classes fulfill their responsibilities in one of two ways: • A class can use its own operations to manipulate its own attributes, thereby fulfilling a particular responsibility, or • a class can collaborate with other classes. • Collaborations identify relationships between classes • Collaborations are identified by determining whether a class can fulfill each responsibility itself • three different generic relationships between classes [WIR90]: • the is-part-ofrelationship • the has-knowledge-of relationship • the depends-uponrelationship Object-Oriented Analysis

  33. Composite Aggregate Class Object-Oriented Analysis

  34. Associations • Two analysis classes are often related to one another in some fashion • In UML these relationships are called associations • Associations can be refined by indicatingmultiplicity(the term cardinalityis used in data modeling Object-Oriented Analysis

  35. Multiplicity Object-Oriented Analysis

  36. Behavioral Modeling • The behavioral model indicates how software will respond to external events or stimuli. To create the model, the analyst must perform the following steps: • Evaluate all use-cases to fully understand the sequence of interaction within the system. • Identify events that drive the interaction sequence and understand how these events relate to specific objects. • Create a sequence for each use-case. • Build a state diagram for the system. • Review the behavioral model to verify accuracy and consistency. Object-Oriented Analysis

  37. State Representations • In the context of behavioral modeling, two different characterizations of states must be considered: • the state of each class as the system performs its function and • the state of the system as observed from the outside as the system performs its function Object-Oriented Analysis

  38. The States of a System • state—a set of observable circum-stances that characterizes the behavior of a system at a given time • state transition—the movement from one state to another • event—an occurrence that causes the system to exhibit some predictable form of behavior • action—process that occurs as a consequence of making a transition Object-Oriented Analysis

  39. Behavioral Modeling • make a list of the different states of a system (How does the system behave?) • indicate how the system makes a transition from one state to another (How does the system change state?) • indicate event • indicate action • draw a state diagram or a interaction diagram (sequence diagram or collaboration diagram) Object-Oriented Analysis

  40. objects message/event lifeline (time) Sequence diagram • A representation of how events cause flow from one object to another as a function of time. • Events are identified by examining a use case • Is a shorthand version of a use case • Sequence diagram consists of: • Objects • Lifeline • Messages/Event Object-Oriented Analysis

  41. Sequence Diagram anOrder Object Object and Class anOrder: Order Message/event prepare() needsToReorder() Self Delegation Object-Oriented Analysis

  42. : Actor object Object A: Class A Object B: Class B messageA( ) message messageB(string) messageC( ) activation (optional) lifeline Object-Oriented Analysis

  43. Identifying events with the Use-Case • Use case for a small portion of the SafeHome security function The homeowner uses the keypad to key in a four-digit password. The password is compared with the valid password stored in the system. If the password is incorrect, the control panel will beep once and reset itself for additional input. If the password is correct, the control panel awaits further action. Object-Oriented Analysis

  44. Sequence Diagram Object-Oriented Analysis

  45. Class diagram Sequence diagram Bob: ClockStaff Ali : User printRecord( ) STAFF printRecord calculateSalary CLOCKSTAFF printRecord calculateSalary COMISSIONSTAFF printRecord calculateSalary Bob: ClockStaff Ali : User calculateSalary( ) Object-Oriented Analysis

  46. Order OrderLine orderNumberdateetc… itemnumberquantityetc… prepare() prepare() DeliveryItem itemnumberquantityetc… new() is_for ReOrderItem StockItem itemnumberquantityetc… orderNumberminQuantitydateetc… OrderEntryWindow new() choose() check():boolean remove() needsToReorder(): boolean Object-Oriented Analysis

  47. anOrder Entry window anOrder anOrder Line aStock Item prepare() choose() * prepare() check() [check=“true”]remove() needsToReorder() [needsToReorder=“true”] AReorder Item aDelivery Item new [check=“true”]new Object-Oriented Analysis

  48. Computer PrintServer Printer status(): integer print(file) uses print(filename) print(file) Managed by Queue store(file) Object-Oriented Analysis

  49. print (filename) [printer busy]store(file) aComputer: Computer aPrintServer: PrintServer aPrinter: Printer aQueue: Queue aUser: User print(file) [printer free]print(file) Object-Oriented Analysis

  50. Collaboration Diagram • Shows the relationships among objects • Consists of: • Objects • Lines connecting the objects • Messages Object A 2. Message2 3. Message3 Object C 1. message1 Object B Object-Oriented Analysis

More Related