Docsity

Object-Oriented Analysis and Design: Understanding Use Cases - Prof. shah, Study notes of Object Oriented Analysis and Design

Toggle sidebar
bg1
Chapter 1
Introduction to Object Oriented Analysis and Design
1. Analysis and Design
Analysis emphasizes an investigation of the problem and requirements, rather than a solution.
For example, if a new online trading system is desired, how will it be used? What are its
functions? "Analysis" is a broad term, best qualified, as in requirements analysis (an
investigation of the requirements) or object-oriented analysis (an investigation of the domain
objects).
Design emphasizes a conceptual solution (in software and hardware) that fulfills the
requirements, rather than its implementation. For example, a description of a database schema
and software objects. Design ideas often exclude low-level or "obvious" details obvious to the
intended consumers. Ultimately, designs can be implemented, and the implementation (such as
code) expresses the true and complete realized design.
As with analysis, the term is best qualified, as in object-oriented design or database design.
Useful analysis and design have been summarized in the phrase do the right thing (analysis), and
do the thing right (design).
2. Object-Oriented Analysis and Design
In dealing with object-oriented technology, Object-Oriented Analysis and Design is the method of choice for
the software development life-cycle. It can be applied in the analysis and design phase and provides general
instructions as for what has to be accomplished. In discussing Object-Oriented Analysis and Design the
distinction between these two phases has to be clarified first.
In the phase of OOA the typical question starts with What...? like “What will my program need to do?”,
“What will the classes in my program be?” and “What will each class be responsible for?” . Hence, OOA cares
about the real world and how to model this real world without getting into much detail. Larman describes in
[Lar02] the OOA phase as an investigation of the problem and requirements, rather than finding a solution to
the problem.
In contrast, in the OOD phase, the question typically starts with How...? like “How will this class handle it’s
responsibilities?”, “How to ensure that this class knows all the information it needs?” and “How will classes in
the design communicate?” . The OOD phase deals with finding a conceptual solution to the problem – it is
about fulfilling the requirements, but not about implementing the solution
During object-oriented analysis(OOA) there is an emphasis on finding and describing the
objects or concepts in the problem domain. For example, in the case of the flight information
system, some of the concepts include Book, Library, and Patron
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33

Partial preview of the text

Download Object-Oriented Analysis and Design: Understanding Use Cases - Prof. shah and more Study notes Object Oriented Analysis and Design in PDF only on Docsity!

Chapter 1

Introduction to Object Oriented Analysis and Design

1. Analysis and Design

Analysis e mphasizes an investigation of the problem and requirements, rather than a solution.

For example, if a new online trading system is desired, how will it be used? What are its

functions? "Analysis" is a broad term, best qualified, as in requirements analysis (an

investigation of the requirements) or object-oriented analysis (an investigation of the domain objects).

Design emphasizes a conceptual solution (in software and hardware) that fulfills the

requirements, rather than its implementation. For example, a description of a database schema

and software objects. Design ideas often exclude low-level or "obvious" details obvious to the

intended consumers. Ultimately, designs can be implemented, and the implementation (such as

code) expresses the true and complete realized design.

As with analysis, the term is best qualified, as in object-oriented design or database design. Useful analysis and design have been summarized in the phrase do the right thing (analysis), and

do the thing right (design).

2. Object-Oriented Analysis and Design

In dealing with object-oriented technology, Object-Oriented Analysis and Design is the method of choice for

the software development life-cycle. It can be applied in the analysis and design phase and provides general

instructions as for what has to be accomplished. In discussing Object-Oriented Analysis and Design the

distinction between these two phases has to be clarified first.

In the phase of OOA the typical question starts with What...? like “What will my program need to do?”,

“What will the classes in my program be?” and “What will each class be responsible for?”. Hence, OOA cares

about the real world and how to model this real world without getting into much detail. Larman describes in

[Lar02] the OOA phase as an investigation of the problem and requirements, rather than finding a solution to

the problem.

In contrast, in the OOD phase, the question typically starts with How...? like “How will this class handle it’s

responsibilities?”, “How to ensure that this class knows all the information it needs?” and “How will classes in

the design communicate?”. The OOD phase deals with finding a conceptual solution to the problem – it is

about fulfilling the requirements, but not about implementing the solution

During object-oriented analysis(OOA) there is an emphasis on finding and describing the objects or concepts in the problem domain. For example, in the case of the flight information system, some of the concepts include Book, Library, and Patron

During software requirement phase, requirement analysis and object analysis, it is a method of

analysis that examines requirements from the perspective of classes and objects as related to problem domain. Object oriented analysis emphasizes the building of real-world model using the

object oriented view of the world.

During object-oriented design (OOD) (or simply, object design) there is an emphasis on

defining software objects and how they collaborate to fulfill the requirements. During user

requirement phase, OOD involves understanding of the application domain and build an object

model. Identify objects; it is methods of design showing process of object oriented

decomposition. Object oriented design is a method of design encompassing the process of

objects oriented decomposition and a notation for depicting logical and physical as well as static

and dynamic models of the system under design. For example, in the library system, a Book software object may have a title attribute and a getChapter method.

Fig: Object-orientation emphasizes representation of objects. Finally, during implementation or object-oriented programming, design objects are implemented, such as a Book class in Java.

3. OOP (Object oriented programming)

During system implementation phase, t is a method of implementation in which programs are organized as cooperative collection of objects, each of which represents an instance of some class and whose classes are all members of a hierarchy of classes united in inheritance relationships. Object oriented programming satisfies the following requirements:It supports objects that are data abstractions with an interface of named operations and a hidden local state.Objects have associated type (class).Classes may inherit attributes from supertype to subtype.

4. Analysis Vs Design

What are physical objects in system?

  • Individuals, organizations, machines, units of information, pictures, whatever makes up application/ make sense in context of real world
  • Objects can be: o External Entity (e.g., other systems, devices, people) that produce or consume information to be used by system o Things (e.g., reports, displays, letters, signals) that are part of information domain for the problem o Places (e.g., book’s room) that establish the context of the problem and the overall function of the system. o Organizational units (e.g., division, group, team, department) that are relevant to an application, o Transaction (e.g., loan, take course, buy, order).

Objects help establish workable system so work iteratively between use-case & object models

Example of candidate objects Just a Line management wishes to increase security, both in their building and on site, without antagonizing their employees. They would also like to prevent people who are not part of the company from using the Just a Line car park. It has been decide to issue identity cards to all employees, which they are expected to wear while on the Just a Line site. The cards records the name, department and number of the member of staff, and permit access to the Just a Line car park. A barrier and a card reader are placed at the entrance to the car park. The driver of an approaching car insert his or her numbered card in the card reader, which then checks that the card number is known to the Just a Line system. If the card is recognized, the reader sends a signal to raise the barrier and the car is able to enter the car park. At the exit, there is also a barrier, which is raised when a car wishes to leave the car park. When there are no spaces in the car park a sign at the entrance display “Full” and is only switched off when a car leaves. Special visitor’s cards, which record a number and the current date, also permit access to the car park. Visitor’s cards may be sent out in advance, or collected from reception. All visitor’s cards must be returned to reception when the visitor leaves Just a Line.

Candidate objects in given case are:

Candidate objects’ rejection rule

  • Duplicates : if two or more objects are simply different names for the same thing.
  • Irrelevant : objects which exists in the problem domain, but which are not intended.
  • Vague : when considering words carefully it sometimes becomes clear that they do not have a price meaning and cannot be the basis of a useful in the system.
  • General : the meaning is too broad.
  • Attributes : as the attribute of objects.p
  • Associations : actually represents the relationships between objects.
  • Roles : sometimes objects referred to by the role they play in a particular part of the system.

Rejected Candidate objects

Final Objects

D. Define class Attributes and Operations

6. Object Oriented Analysis Approaches (Complementary Analysis Approaches)

A number of additional activities can be used which are complimentary to object-oriented analysis and design methodologies. A. Domain Analysis.

  • Identify classes which are common to all applications in this domain.
  • Domain analysis seeks to identify the classes and objects that are common to all applications of a given domain. o For example: all accounting systems have certain classes in common.
  • Domain analysis works well, because there are very few truly unique kinds of software systems.
  • Try to compare the system you are developing to a generalized class of systems. When starting to design a system.
  • Survey the architecture of existing systems in that domain.
  • Define key abstractions and mechanisms.
  • Evaluate which can be used in the new system.
  • A domain expert may be required to assist in this effort.

B. Scenario Planning or Use-Case Analysis.

  • Identify operations patterns by users initiating some sequence of interrelated events.
  • A use case is a scenario that begins with some user of the system initiating some transaction or sequence of interrelated events.
  • Scenario planning of this type is employed by many other OO methodologies, including Coad/Yourdon, Jacobson, and Wirfs-Brock.
  • A basic scenario planning approach is introduced under human interaction in the section on design.
  • Basic goal is to group the primary function points of the system by related behavior or hierarchy
  • This technique is similar to storyboarding. Use-Case Analysis Activities

For each interesting set of function points, storyboard a scenario to identify the following.

  • Actors that participate.
  • Actors are classes or categories of users, with a specific role.
  • Their responsibilities.
  • How they collaborate with each other. Modify the scenarios as necessary.
  • Expand the initial scenarios to identify secondary scenarios.
  • Create a generalized scenario from several related scenarios. Update the list of classes, responsibilities, and behaviors that result for this effort.

C. CRC Cards.

  • Class-Responsibility-Collaboration cards.
  • CRC stands for Class - Responsibility - Collaboration.
  • They are simple 3x5 index cards with the class name along the top and two columns below for responsibilities and collaborations.
  • They provide a simple tool for team development tasks, such as storyboarding.
  • They can be used during storyboarding sessions to keep track of the classes for each scenario.
  • They can be easily grouped and organized.

D. Informal English.

  • Identify key concepts from textual description of the problem.
  • An alternative is to write an English language description of the problem, or part of the problem.
  • Take the natural language description and underline the nouns and verbs to identify candidate classes and operations, respectively.
  • This is by no means a rigorous approach.
  • Natural language is to imprecise and ambiguous.
  • Any noun can be verbed, and any verb can be nouned. However, since natural language is often used for system descriptions and requirements documents, it may provide some useful insight. E. Structured Analysis F. classical categorization

G. Behavior Analysis

7. Object-oriented Design

 OOD transforms the analysis model created using OOA into a design model that serves as a blueprint for software construction.  OOD results in a design that achieves a number of different levels of modularity.  Subsystems: Major system components.  Objects: Data and the operations.  Four important software design concepts: o Abstraction o Information Hiding o Functional Independence o Modularity

 As stated earlier, analysis is the practice of studying a problem domain, leading to a specification of externally observable behavior.

  • Problem domain component—the subsystems that are responsible for implementing customer requirements directly;
  • Human interaction component —the subsystems that implement the user interface (this included reusable GUI subsystems);
  • Task Management Component—the subsystems that are responsible for controlling and coordinating concurrent tasks that may be packaged within a subsystem or among different subsystems;
  • Data management component—the subsystem that is responsible for the storage and retrieval of objects.

OOA to OOD

Object- relationship model

Object-Behavior Model

CRC Index Cards

Attributes, operations, collaborators

THE ANALYSIS MODEL

responsibilities design

message design

Class and object design

subsystem design

THE DESIGN MODEL

Use cases

8. 0 The models of Object Oriented Development

The models of object oriented analysis and design reflect the importance of explicitly capturing

both the class and object hierarchies of the system under design. These models also over the

spectrum of the important design decisions that we must consider in developing a complex

system and so encourage us to craft implementations that embody the five attributes of well formed complex systems.

Fig: Different types of model of OO Development

Booch presents a model of object- oriented development that identifies several relevant perspectives

The classes and objects that form the system are identified in a logical model. For this logical model, again two different perspectives have to be considered  A static perspective identifies the structure of classes and objects, their properties and the relationships classes and objects participate in.  A dynamic model identifies the dynamic behavior of classes and objects, the different valid states they can be in and the transitions between these states. Besides the logical model, also a physical model needs to be identified. This is usually done later in the system's lifecycle. The module architecture identifies how classes are kept in separately compliable modules and the process architecture identifies how objects are distributed at run-time over different operating system processes and identifies the relationships between those. Again for this physical model a static perspective is defined that considers the structure of module and process architecture and a dynamic perspective identifies process and object activation strategies and inter-process communication. Object-orientation has not, however, emerged fully formed. In fact it has developed over a long period, and continues to change.  Descriptive models written in English are often ambiguousMathematical models often frightens developers though it is good for safety critical system.Graphical models can be seen by the user and other developers, e.g. UML

The Importance of Model Building

 The buildings of models have a broad acceptance among all engineering disciplines largely because model building appeals to the principles of decomposition, abstraction and hierarchy.  Each model within a design describes a specific aspect/ perspective of the system under consideration, when put together will provide an overall view of the system.  Models give us the opportunity to fail under controlled conditions.

are considered noteworthy. The result can be expressed in a domain model that shows the noteworthy domain concepts or objects.

Note that a domain model is not a description of software objects; it is a visualization of the concepts or mental models of a real-world domain. Thus, it has also been called a conceptual

object model. For example, a partial domain model is shown in

Fig: Partial domain model of the dice game

This model illustrates the noteworthy concepts Player, Die, and DiceGame , with their associations and attributes.

Define Interaction Diagrams

Object-oriented design is concerned with defining software objects their responsibilities and collaborations. A common notation to illustrate these collaborations is the sequence diagram (a kind of UML interaction diagram). It shows the flow of messages between software objects, and thus the invocation of methods. For example, the sequence diagram in Figure illustrates an OO software design, by sending messages to instances of the DiceGame and Die classes. Note this illustrates a common real- world way the UML is applied: by sketching on a whiteboard.

Fig: Interaction diagram illustrating messages between software objects.

Notice that although in the real world a player rolls the dice, in the software design the DiceGame object "rolls" the dice (that is, sends messages to Die objects). Software object designs and programs do take some inspiration from real- world domains, but they are not direct models or simulations of the real world.

Define Design Class Diagrams

In addition to a dynamic view of collaborating objects shown in interaction diagrams, a static view of the class definitions is usefully shown with a design class diagram. This illustrates the attributes and methods of the classes. For example, in the dice game, an inspection of the sequence diagram leads to the partial design class diagram shown in fig below. Since a play message is sent to a DiceGame object, the DiceGame class requires a play method, while class Die requires a roll and getFaceValue method.

Fig: design class diagram.

In contrast to the domain model showing real-world classes, this diagram shows software classes. Notice that although this design class diagram is not the same as the domain model, some class names and content are similar.

In this way, OO designs and languages can support a lower representational gap between the

software components and our mental models of a domain. That improves comprehension.

9. Case Studies:

In this section we will present two different types of case study, one is business transaction type problem and other is computer simulation game.

A. Case One: The NextGen POS System

A POS system is a computerized application used (in part) to record sales and handle payments; it is typically used in a retail store. It includes hardware components such as a computer and bar code scanner, and software to run the system. It interfaces to various service applications, such as a third- party tax calculator and inventory control. These systems must be relatively fault-tolerant; that is, even if remote services are temporarily unavailable (such as the inventory system), they must still be capable of capturing sales and handling at least cash payments (so that the business is not crippled). A POS system increasingly must support multiple and varied client-side terminals and interfaces. These include a thin-client Web browser terminal, a regular personal computer with something like a Java Swing graphical user interface, touch screen input, wireless PDAs, and so forth. Furthermore, we are creating a commercial POS system that we will sell to different clients with disparate needs in terms of business rule processing. Each client will desire a unique set of logic to execute at certain predictable points in scenarios of using the system, such as when a new sale is initiated or when a new line item is added. Therefore, we will need a mechanism to provide this flexibility and customization. Using an iterative development strategy, we are going to proceed through requirements, object-oriented

collaboration. Several scenarios (usual & unusual behavior, exceptions) needed to understand all aspects of collaboration & all potential actions.

Use case modeling: expressing high level processes & interactions with customers in a scenario & analyzing it .It gives system uses, system responsibilities

Developing use case is iterative process, when use case model better understood & developed,

start identifying classes & create their relationship

Use case modeling:

 Helps in capturing requirements  Helps in planning iterations of development  Helps in validating systems  expressing high level processes & interactions with customers in a scenario & analyzing it  It gives system uses, system responsibilities

Scenarios vs Usecase:

  • Great way to establish communication with client
  • Different types of scenarios: As-Is, visionary, evaluation and training Use cases
  • Abstractions of scenarios
  • Use cases bridge the transition between functional requirements and objects.

How to write a use case

  • Name of Use Case
  • Actors
    • Description of Actors involved in use case
  • Entry condition
    • “This use case starts when…”
  • Flow of Events
    • Free form, informal natural language
  • Exit condition
    • “This use cases terminates when…”
  • Exceptions
    • Describe what happens if things go wrong
  • Special Requirements
    • Nonfunctional Requirements, Constraints

Format of Use case Black-box versus white-box visibility type, use cases are written in varying degrees of formality:

  • Brief —terse one-paragraph summary, usually of the main success scenario. The prior Process Sale example was brief.
  • Casual —informal paragraph format. Multiple paragraphs that cover various scenarios. The prior Handle Returns example was casual.
  • Fully dressed —the most elaborate. All steps and variations are written in detail, and there are supporting sections, such as preconditions and success guarantees.

Fully Dressed use case format Various format templates re available for fully dressed use cases. However, perhaps the most

widely used and shared format is the template available at www.usecases.org. The following

example illustrates this style.

Use Case ID: Use Case Name: Primary Actor: Stakeholders and Interests:: Preconditions: Success Guarantee(Postconditions): Main Success Scenario (or Basic Flow):: Extensions (or Alternative Flows):: Special Requirements: Technology and Data Variations List:: Frequency of Occurrence:: Open Issues

Based on a real POS system’s requirements (example of use case text story) Use case ID UC Use case Name Process Sale Primary Actor Cashier Stakeholders and Interests

  • Cashier: Wants accurate, fast entry, and no payment errors, as cash drawer short ages are deducted from his/her salary.
  • Salesperson: Wants sales commissions updated.
  • Customer: Wants purchase and fast service with minimal effort. Wants proof of purchase to support returns.
  • Company: Wants to accurately record transactions and satisfy customer interests. Wants to ensure that Payment Authorization Service payment receivables are recorded. Wants some fault tolerance to allow sales capture even if server components (e.g., remote credit validation) are unavailable. Wants automatic and fast update of accounting and inventory.
  • Government Tax Agencies: Want to collect tax from every sale. May be multiple agencies, such as national, state, and county.
  • Payment Authorization Service: Wants to receive digital authorization requests in the correct format and protocol. Wants to accurately account for their payables to the store. Preconditions Cashier is identified and authenticated Success Guarantee (Postconditions)

Sale is saved. Tax is correctly calculated. Accounting and Inventory are updated. Commissions recorded. Receipt is generated. Payment authorization approvals are recorded. Main Success Scenario (or Basic Flow)

  1. Customer arrives at POS checkout with goods and/or services to purchase.
  2. Cashier starts a new sale.
  3. Cashier enters item identifier.
  4. System records sale line item and presents item description, price, and running total. Price calculated from a set of price rules. Cashier repeats steps 3-4 until indicates done.
  5. System presents total with taxes calculated.
  6. Cashier tells Customer the total, and asks for payment.
  7. Customer pays and System handles payment.
  8. System logs completed sale and sends sale and payment information to the external

7d. Paying by debit... 7e. Customer presents coupons:

  1. Before handling payment, Cashier records each coupon and System reduces price as appropriate. System records the used coupons for accounting reasons. 1a. Coupon entered is not for any purchased item:
  2. System signals error to Cashier. 9a. There are product rebates:
  3. System presents the rebate forms and rebate receipts for each item with a rebate. 9b. Customer requests gift receipt (no prices visible): 1. Cashier requests gift receipt and System presents it.

Special Requirements:

  • Touch screen Ul on a large flat panel monitor. Text must be visible from 1 meter.
  • Credit authorization response within 30 seconds 90% of the time.
  • Somehow, we want robust recovery when access to remote services such the inventory system is failing.
  • Language internationalization on the text displayed.
  • Pluggable business rules to be insertable at steps 3 and 7. Technology and Data Variations List:

3a. Item identifier entered by bar code laser scanner (if bar code is present) or keyboard. 3b. Item identifier may be any UPC, EAN, JAN, or SKU coding scheme. 7a. Credit account information entered by card reader or keyboard. 7b. Credit payment signature captured on paper receipt. But within two years, we predict many customers will want digital signature capture. Frequency of Occurrence:

Could be nearly continuous

Open Issues - What are the tax law variations?

  • Explore the remote service recovery issue.
  • What customization is needed for different businesses?
  • Must a cashier take their cash drawer when they log out?
  • Can the customer directly use the card reader, or does the cashier have to do it?

Example 2

A use case describes three things:

  • An actor (user) that initiates an event
  • An event that triggers a use case
  • The use case that performs the actions triggered by the event

There are two kinds of use cases:

  • Primary, the standard flow of events within a system that describe a standard system behavior
  • Use case scenarios that describe variations of the primary use case

Steps for Creating a Use Case Model The steps required to create a use case model are

  • Review the business specifications and identify the actors within the problem domain