Object oriented analysis


Published on

Published in: Education
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
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • <number>
  • Object oriented analysis

    1. 1. CHAPTER 6 OBJECT ORIENTED ANALYSIS SIM3301 Object-Oriented Analysis 1
    2. 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 SIM3301 Object-Oriented Analysis 2
    3. 3. Object-Oriented Concepts • Must be understood to apply classbased elements of the analysis model • Key concepts: – Classes and objects – Attributes and operations – Encapsulation and instantiation – Inheritance SIM3301 Object-Oriented Analysis 3
    4. 4. • Class object-oriented es 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 SIM3301 Object-Oriented Analysis 4
    5. 5. cla ss na m e Building a Class Class name a ttribute s: ope ra tions Attributes a ttribute s: Operations ope ra tions: SIM3301 Object-Oriented Analysis 5
    6. 6. Encapsulation/Hidin Class encapsulates g Reduces the propagation of side effects when both data and the logical changes occur procedures required to manipulate the data method method #2 #1 data method #3 method #6 method #5 method #4 Achieves “information hiding” SIM3301 Object-Oriented Analysis 6
    7. 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 SIM3301 Object-Oriented Analysis 7
    8. 8. Methods (a.k.a. Operations, An executable procedure that is Services) 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. SIM3301 Object-Oriented Analysis 8
    9. 9. Attribute s A collection of data values that describe a class SIM3301 Object-Oriented Analysis 9
    10. 10. Objects • 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. SIM3301 Object-Oriented Analysis 10
    11. 11. Example STUDENT Name DOB Address Phone Calculate_age Calculate_gpa Register_course SIM3301 Object-Oriented Analysis 11
    12. 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) SIM3301 Object-Oriented Analysis 12
    13. 13. THE OOA PROCESS Use Case Modeling – shows functions Class-based Modeling – Class diagram, CRC Behavioral Model – State Diagram, Sequence Diagram SIM3301 Object-Oriented Analysis 13
    14. 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” Represent actor •Can be people or devices •Represent the roles that people/devices play as the system operates Represent a use case •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 SIM3301 Object-Oriented Analysis 14
    15. 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? SIM3301 Object-Oriented Analysis 15
    16. 16. Use-Case Diagram SafeHome Access camera surveillance via the Internet cameras Configure SafeHome system parameters homeowner Set alarm SIM3301 Object-Oriented Analysis 16
    17. 17. Eg: consider the interactions between a Bank Customer and an ATM Bank ATM Machine Withdraw Cash Bank Customer Check Balance Create Online Transaction SIM3301 Object-Oriented Analysis 17
    18. 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-persecond 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) • . SIM3301 Object-Oriented Analysis 18
    19. 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 SIM3301 Object-Oriented Analysis 19
    20. 20. Example: Use-case diagram for a university registration system (Correction: arrow direction should be in opposite direction) 20.20 SIM3301 Object-Oriented Analysis 20
    21. 21. SIM3301 Object-Oriented Analysis 21
    22. 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 SIM3301 Flow/Transition Object-Oriented Analysis Decision 22
    23. 23. ent er passw ord and user ID valid passwor ds/ ID invalid passwor ds/ ID selec t major f unc t ion prompt f or reent ry ot her f unct ions m ay also be select ed input t r ies r em ain selec t surv eillanc e t hum bnail views no input t r ies r em ain select a specif ic cam er a selec t spec if ic c amera - t humbnails selec t c amera ic on v iew c amera out put in labelled window An activity diagram for Access Camera surveillance prompt f or anot her v iew exit t his f unct ion SIM3301 see anot her cam er a Object-Oriented Analysis 23
    24. 24. ATM Authorization Masuk kad Masuk PIN Baca kad Minta PIN [Tidak] Sahkan PIN Adakah sah? [Ya] Pilih servis SIM3301 Object-Oriented Analysis 24
    25. 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 SIM3301 Object-Oriented Analysis 25
    26. 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. SIM3301 Object-Oriented Analysis 26
    27. 27. Selecting Classes—Criteria • Retained Information • Needed services – have a set of identifiable operations • Multiple attributes • Common attributes • Common operations • Essential requirements SIM3301 Object-Oriented Analysis 27
    28. 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. SIM3301 Object-Oriented Analysis 28
    29. 29. CRC Modeling Class: Class: Description: Class: Description: FloorPlan Class: Description: Responsibility: Description: Responsibility: Responsibility: Responsibility: Collaborator: Collaborator: Collaborator: Collaborator: defines floor plan name/type manages floor plan positioning scales floor plan for display incorporates walls, doors and windows shows position of video cameras SIM3301 Wall Camera Object-Oriented Analysis 29
    30. 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 classes are 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 classes manage 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. SIM3301 Object-Oriented Analysis 30
    31. 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. SIM3301 Object-Oriented Analysis 31
    32. 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-of relationship – the has-knowledge-of relationship – the depends-upon relationship SIM3301 Object-Oriented Analysis 32
    33. 33. Composite Aggregate Class Player PlayerHead SIM3301 PlayerBody PlayerArms Object-Oriented Analysis PlayerLegs 33
    34. 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 indicating multiplicity (the term cardinality is used in data modeling SIM3301 Object-Oriented Analysis 34
    35. 35. Multiplicity Wall 1 is used to build SIM3301 1 is used to build 0..* is used to build 1..* WallSegm ent 1 Window 0..* Door Object-Oriented Analysis 35
    36. 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. SIM3301 Object-Oriented Analysis 36
    37. 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 SIM3301 Object-Oriented Analysis 37
    38. 38. The States of a System SIM3301 • state—a set of observable circumstances 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 38
    39. 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) SIM3301 Object-Oriented Analysis 39
    40. 40. 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 lifeline objects message/even t (time) SIM3301 Object-Oriented Analysis 40
    41. 41. Sequence Diagram anOrder Object anOrder: Order Object and Class Message/event prepare() needsToReorder() SIM3301 Self Delegation Object-Oriented Analysis 41
    42. 42. object Object A: Class A : Actor Object B: Class B messageA( ) message messageB(string) messageC( ) activation (optional) lifeline SIM3301 Object-Oriented Analysis 42
    43. 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. SIM3301 Object-Oriented Analysis 43
    44. 44. Sequence Diagram co n t ro l p an el h o meo wn er syst em read y sen so rs sen so rs syst em read in g A passw o rd en t ered co mp arin g req u est lo o ku p resu lt pas s word = c orrec t req u est act ivat io n num berOf Tries > m ax Tries lo cked A t imer > lo cked Time select in g act ivat io n su ccessful Figure 8 .2 7 Sequence diagram (part ial) f or SIM3301 act ivat io n su ccessfu l Saf eHome secur it y f unct ion Object-Oriented Analysis 44
    45. 45. Class diagram Sequence diagram Bob: ClockStaff Ali : User printRecord( ) STAFF printRecord calculateSalary CLOCKSTAFF COMISSIONSTAFF printRecord calculateSalary printRecord calculateSalary SIM3301 Bob: ClockStaff Ali : User Object-Oriented Analysis calculateSalary( 45 )
    46. 46. Order OrderLine DeliveryItem orderNumber date etc… itemnumber quantity etc… itemnumber quantity etc… prepare() prepare() new() is_for StockItem OrderEntryWindow choose() SIM3301 orderNumber minQuantity date etc… ReOrderItem itemnumber quantity etc… new() check():boolean remove() needsToReorder(): boolean Object-Oriented Analysis 46
    47. 47. anOrder Entry window choose() anOrder prepare() anOrder Line aStock Item AReorder Item aDelivery Item * prepare() check() [check=“true”] remove() needsToReorder() [needsToReorder=“true”] new [check=“true”] new SIM3301 Object-Oriented Analysis 47
    48. 48. Computer PrintServer Printer status(): integer uses print(filename) print(file) print(file) Managed by Queue store(file) SIM3301 Object-Oriented Analysis 48
    49. 49. aComputer: Computer aPrintServer: PrintServer aPrinter: Printer aQueue: Queue aUser: User print (filename) print(file) [printer free] print(file) [printer busy] store(file) SIM3301 Object-Oriented Analysis 49
    50. 50. Collaboration Diagram  Shows the relationships among objects  Consists of:  Objects  Lines connecting the objects  Messages Object A 1. message1 SIM3301 2. Message2 3. Message3 Object C Object B Object-Oriented Analysis 50
    51. 51. 1. keyInCourseInfo Course Form Interaction diagrams Student 2. addCourse Academic Staff : Student 3. newCourse Course Form Student Schedule keyInCourseInfo Student Schedule SIM3301 Academic Staff Object-Oriented Analysis addCourse newCourse 51
    52. 52. State Diagram  Indicates how an individual class changes state based on external events  Represents states for each class and the events (triggers) that cause changes between these states  One state diagram for each class.  Event – causes the transition, the labels for each arrow  Action – occurs concurrently with the state transition or as a consequence of it. Generally involves one or more operations (responsibilities)  Transition – represented by an arrow  Guard condition– a boolean condition that must be satisfied in order for the transition to occur  Activity - represents a long-running task during that state.  Actions vs activity  Actions cannot be interrupted, activity can be interrupted by an incoming event.   Both represent an operation on the object being studied.   For example, an operation that sets an attribute would be considered an action, while a long calculation might be an activity.  SIM3301 Object-Oriented Analysis 52
    53. 53. State-Diagram Notation Event which causes the transition State 1 do/activity 1 Initial state SIM3301 Condition that must be satisfied in order for the transition to occur Occurs concurrently with the state transition event [condition] /action An operation that is perform when an object is in a certain state Object-Oriented Analysis State 2 ... End state 53
    54. 54. Example : State Diagram Invoice created Unpaid SIM3301 Paying Object-Oriented Analysis Invoice destroyed Paid 54
    55. 55. Class: CourseSchedule bina jadual kursus Initialization Initialization dibuka pd pelajar add student/numStudent=0ditutup – kuota penuh add student [numStudent<50] Open Open addstudent [numStudent=50] Closed Closed cancel cancel Cancelled Dibatalkan atau tidak ditawarkan lagi SIM3301 do:Send cancellation notices delete Object-Oriented Analysis 55
    56. 56. State Diagram for the ControlPanel Class t imer < lockedTime t imer > lockedTime locked password = incorrect & numberOfTries < maxTries key hit comparing reading password ent ered numberOfTries > maxTries do: validat ePassw ord password = correct select ing act iv at ion successful SIM3301 Object-Oriented Analysis 56
    57. 57. State Diagram Reading commands Init ializat ion t urn copier “on“ syst em st at us=“not ready” display msg = “please wait ” display st at us = blinking subsyst ems ready ent ry/ swit ch machine on do: run diagnost ics do: init iat e all subsyst ems not jammed syst em st at us=“Ready” display msg = “ent er cmd” display st at us = st eady paper f ull ent ry/ subsyst ems ready do: poll user input panel do: read user input do: int erpret user input t urn copier “of f ” st art copies Making copies syst em st at us=“Copying” display msg= “copy count =” display message=#copies display st at us= st eady ent ry/ st art copies do: manage copying do: monit or paper t ray do: monit or paper f low copies complet e paper t ray empt y paper jammed problem diagnosis load paper syst em st at us=“load paper” display msg= “load paper” display st at us= blinking ent ry/ paper empt y do: lower paper t ray do: monit or f ill swit ch do: raise paper t ray syst em st at us=“Jammed” display msg = “paper jam” display message=locat ion display st at us= blinking not jammed ent ry/ paper jammed do: det ermine locat ion do: provide correct ivemsg. do: int errupt making copies Figure 7.6 Preliminary UML st at e diagram for a phot ocopier SIM3301 Object-Oriented Analysis 57
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.