Managment Information System
Managment Information System
UNIT I (9)
Introduction to OOAD – What is OOAD? – What is UML? What are the United
process(UP) phases - Case study – the NextGen POS system, Inception -Use case
Modeling - Relating Use cases – include, extend and generalization.
UNIT II (9)
Elaboration - Domain Models - Finding conceptual classes and description classes –
Associations – Attributes – Domain model refinement – Finding conceptual class
hierarchies- Aggregation and Composition- UML activity diagrams and modeling
SVCE Page 1
Object Oriented Analysis and Design CS6502
UNIT I
Introduction to OOAD – Unified Process - UML diagrams – Use Case – Class Diagrams–
Interaction diagrams – State Diagrams – Activity Diagrams – Package, component and
Deployment Diagrams
1.INTRODUCTION TO OOAD:
Analysis emphasizes an investigation of the problem and requirements, rather than a solution.
For example, if a new computerized library information system is desired, how will it be
used?
"Analysis" is a broad term, best qualified, as in requirements analysis.
Design emphasizes a conceptual solution that fulfills the requirements, rather than its
implementation. For example, a description of a database schema and software objects.
Ultimately, designs can be implemented.
object-oriented design, there is an emphasis on defining software objects and how they
collaborate to fulfil the requirements. For example, in the library system, a Book software
object may have a title attribute and a get Chapter method.
SVCE Page 2
Object Oriented Analysis and Design CS6502
UML as sketch: Informal and incomplete diagrams created to explore the difficult
parts of the problem/solution space.
UML as blueprint: Relatively detailed design diagram used for either reverse
engineering or forward engineering (code generation).
UML as programming language: Complete executable specification of a software
system in UML. Executable code will be automatically generated, but it is not
normally seen or modified by developers.
Classification:
Broadly classified as
Structural
Behavioral
Diagram Types:
Use case Diagram
Activity diagram
Class Diagram
Sequence Diagram
Communication diagram
Component Diagram
Deployment diagram
Package Diagram
State Machine diagram
Timing diagram
SVCE Page 3
Object Oriented Analysis and Design CS6502
Profile Diagram
Composite Structure
Object diagram
Interaction Overview
Unified Process has emerged as a popular software development process for building object-
oriented systems.
Iterative Development:
Development is organized into a series of short, fixed-length (for example, four week)
mini-projects called iterations.
The outcome of each is a tested, integrated, and executable system. Each iteration
includes its own requirements analysis, design, implementation, and testing activities.
SVCE Page 4
Object Oriented Analysis and Design CS6502
The UP (and experienced iterative developers) recommends an iteration length between two
and six weeks. Small steps, rapid feedback, and adaptation are central ideas in iterative
development iterations are timeboxed, or fixed in length.
For example, if the next iteration is chosen to be four weeks long, then the partial system
should be integrated, tested, and stabilized by the scheduled date—date slippage is
discouraged.
SVCE Page 5
Object Oriented Analysis and Design CS6502
It will be difficult to meet the deadline, the recommended response is to remove tasks or
requirements from the iteration, and include them in a future iteration.
UP Phases:
Iterations
Each phase has iterations, each having the purpose of producing a demonstrable piece of
software. The duration of iteration may vary from two weeks or less up to six months.
Inception
• The life-cycle objectives of the project are stated, so that the needs of every stakeholder are
considered. Scope and boundary conditions, acceptance criteria and some requirements are
established.
Inception – Activities
Define risk mitigation strategy, develop an initial project plan and identify known cost,
schedule, and profitability trade-offs.
SVCE Page 6
Object Oriented Analysis and Design CS6502
Elaboration
An analysis is done to determine the risks, stability of vision of what the product is to
become, stability of architecture and expenditure of resources
Elaboration – Activities
Project plan is defined. The process, infrastructure and development environment are
described.
To provide a stable basis for the bulk of the design and implementation effort in the
construction phase.
plan, a staffing plan, a phase plan showing the number and contents of the iteration , an
iteration plan, and a test plan
e
‘complete’.
Construction
SVCE Page 7
Object Oriented Analysis and Design CS6502
Construction – Activities
Components required satisfying the use cases, scenarios, and other functionality for the
iteration are built. Unit and integration tests are done on Components.
process.
Objective measurable evaluation criteria for assessing the results of the next iteration(s).
Transition
The transition phase is the phase where the product is put in the hands of its end users. It
involves issues of marketing, packaging, installing, configuring, supporting the user-
community, making corrections, etc.
Transition – Activities
SVCE Page 8
Object Oriented Analysis and Design CS6502
“postmortem” analysis of the performance of the project relative to its original and revised
success criteria;
UP Disciplines:
Discipline is a set of activities (and related artifacts) in one subject area, such as the
activities within requirements analysis. Artifact is the general term for any work product:
code, Web graphics, database schema, text documents, diagrams, models, and so on.
SVCE Page 9
Object Oriented Analysis and Design CS6502
Agile UP
Agile process implies a light and adaptive process, nimble in response to changing
needs.
point-of-sale(POS)
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.
SVCE Page 10
Object Oriented Analysis and Design CS6502
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.
A POS system increasingly must support multiple and varied client-side terminals and
interfaces.
Inception:
The purpose of the inception step is not to define all the requirements, or generate a
believable estimate or project plan.
Inception phase should be relatively short for most projects, such as one or a few
weeks long.
The intent of inception is to establish some initial common vision for the objectives of
the project, determine if it is feasible, and decide if it is worth some serious
investigation in elaboration.
SVCE Page 11
Object Oriented Analysis and Design CS6502
Requirements:
Requirements are capabilities and conditions to which the system and more broadly,
the project must conform.
Types of Requirements:
Functional—features, capabilities, security.
Usability—human factors, help, documentation.
Reliability—frequency of failure, recoverability, predictability.
Performance—response times, throughput, accuracy, availability, resource usage.
Supportability—adaptability, maintainability, internationalization, configurability.
Implementation—resource limitations, languages and tools, hardware.
SVCE Page 12
Object Oriented Analysis and Design CS6502
3.USE-CASE MODEL
Notations:
An actor is something with behavior, such as a person (identified by role), computer system,
or organization; for example, a cashier.
Informally then, a use case is a collection of related success and failure scenarios that
describe actors using a system to support a goal. For example, here is a casual format use
case that includes some alternate scenarios:
Handle Returns
Main Success Scenario: A customer arrives at a checkout with items to return. The cashier
uses the POS system to record each returned item ...
Alternate Scenarios:
If the credit authorization is reject, inform the customer and ask for an alternate payment
method.
If the item identifier is not found in the system, notify the Cashier and suggest manual entry
of the identifier code (perhaps it is corrupted).
If the system detects failure to communicate with the external tax calculator system, ...
Use cases are text documents, not diagrams, and use-case modeling is primarily an act
of writing text, not drawing. However, the UML defines a use case diagram to
illustrate the names of use cases and actors, and their relationships.
SVCE Page 13
Object Oriented Analysis and Design CS6502
Black-box use cases are the most common and recommended kind; they do not describe the
internal workings of the system, its components, or design. Rather, the system is described as
having responsibilities, which is a common unifying metaphorical theme in object-oriented
thinking—software elements have responsibilities and collaborate with other elements that
have responsibilities it is possible to specify what the system must do (the functional
requirements) without deciding how it will do it (the design).
Formality Types
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.
SVCE Page 14
Object Oriented Analysis and Design CS6502
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.
SVCE Page 15
Object Oriented Analysis and Design CS6502
Preconditions state what must always be true before beginning a scenario in the use case.
Preconditions are not tested within the use case; rather, they are conditions that are assumed
to be true. Typically, a precondition implies a scenario of another use case that has
successfully completed, such as logging in, or the more general "cashier is identified and
authenticated."
Success guarantees (or postconditions) state what must be true on successful completion of
the use case.either the main success scenario or some alternate path. The guarantee should
meet the needs of all stakeholders.
SVCE Page 16
Object Oriented Analysis and Design CS6502
Use cases can be related to each other. For example, a subfunction use case such as Handle
Credit Payment may be part of several regular use cases, such as Process Sale and Process
Rental. Organizing use cases into relationships has no impact on the behavior or requirements of
the system. Rather, it is simply an organization mechanism to (ideally) improve communication
and comprehension of the use cases, reduce duplication of text, and improve management of the
use case documents.
3 types:
The include Relationship
The extend Relationship
The generalize Relationship
SVCE Page 17
Object Oriented Analysis and Design CS6502
Use include when you are repeating yourself in two or more separate use cases and you want
to avoid repetition. Another motivation is simply to decompose an overwhelmingly long use
case into subunits to improve comprehension.
A concrete use case is initiated by an actor and performs the entire behaviour desired by the
actor . These are the elementary business process use cases. For example, Process Sale is a
concrete use case.
Abstract use case is never instantiated by itself; it is a subfunction use case that is part of
another use case. Handle Credit Payment is abstract; it doesn't stand on its own, but is always
part of another story, such as Process Sale.
A use case that includes another use case, or that is extended or specialized by
another use case is called a base use case. Process Sale is a base use case with
respect to the included Handle Credit Payment subfunction use case.
On the other hand, the use case that is an inclusion, extension, or specialization is
called an addition use case. Handle Credit Payment is the addition use case in
the include relationship to Process Sale.
– a dotted line labeled <<extend>> with an arrow toward the base case.
– The extending use case may add behavior to the base use case. The base class
declares “extension points”.
<<extend>>
SVCE Page 18
Object Oriented Analysis and Design CS6502
• Considered in terms of
– Symbol
– Intension
– Extension
ASSOCIATIONS
ASSOCIATIONS
DEFINITION
• In UML, associations are defined as semantic relation between two or more classifiers
that involve connections among their instances
ASSOCIATION
UML NOTATION
ASSOCIATION
EXAMPLE
SVCE Page 20
Object Oriented Analysis and Design CS6502
ASSOCIATION
• Multiplicity
– How many instances of class A can be associated with one instance of class B
– Context dependent
ASSOCIATION
MULTIPLICITY
SVCE Page 21
Object Oriented Analysis and Design CS6502
ASSOCIATION
MULTIPLE ASSOCIATION
ATTRIBUTES
ATTRIBUTES
EXAMPLE
SVCE Page 22
Object Oriented Analysis and Design CS6502
ATTRIBUTE
DERIVED ATTRIBUTE
• Derived attribute denoted using / symbol before attribute name
Payment
CheckPaym
CashPaymen CreditPay ent
t ment
SVCE Page 23
Object Oriented Analysis and Design CS6502
Payment
Pays-for Sale
amount : Money 1 1
GENERALIZATION
GUIDELINE
• 100% rule – definition conformance
– 100% of the conceptual Superclass’s definition should be applicable to the
subclass.
– The subclass must conform to 100% of the Superclass’s:
• attributes
• associations
GENERALIZATION
GUIDELINE
SVCE Page 24
Object Oriented Analysis and Design CS6502
CONCEPTUALCLASSHIERARCHY
ABSTRACT CLASS
• Composition
– Whole-part aggregation
– Strongly coupled
– Also known as composite aggregation
• Aggregation
– Whole-part relationship
– Loosely coupled
5.INTERACTION DIAGRAMS
Interaction Diagrams are models that describe how a group of objects collaborate in
some behaviour
Interaction Diagram model the behaviour of use cases by describing the way,groups
of objects interact to complete the task
SVCE Page 25
Object Oriented Analysis and Design CS6502
1. Sequence Diagram
Communication Diagram
SVCE Page 26
Object Oriented Analysis and Design CS6502
1. Lifeline Box
2. Message Expression
3. Singleton Objects
SVCE Page 27
Object Oriented Analysis and Design CS6502
8. Iteration or Looping
9. Iteration over a collection
10. Messages to a classes to invoke static(class) methods
11. Polymorphic messages and cases
12. Asynchronous and synchronous calls
INTRODUCTION
Events - start game (to reach Initialised state),move (to reach Moving state)
State - Initialized,Moving
Transition - When the event moves occurs,transition takes place from the Initialized
to Moving state
STATE DIAGRAM
OBJECT TYPES
SVCE Page 29
Object Oriented Analysis and Design CS6502
1. Communication protocols
2. UI page/window flow of navigation
3. UI flow controllers or sessions
4. Use case system operations
5. Individual UI window event handling
NESTED STATES
SVCE Page 30
Object Oriented Analysis and Design CS6502
It used to provide a view of flows and what is going on inside a use-case or among
several classes
Shows parallel and sequential activities in a process
Used in business processes, work flows, data flows, complex algorithm
UML activity diagrams are the object oriented equivalent of flow charts and data flow
diagrams from structured development
Join
Object node
Types of flow/edge
1)Object flow -> flow between the partitions
2)Control flow ->flow in the same partition
SVCE Page 32
Object Oriented Analysis and Design CS6502
SVCE Page 33
Object Oriented Analysis and Design CS6502
8.PACKAGE DIAGRAM
SVCE Page 34
Object Oriented Analysis and Design CS6502
GUIDELINES
Design with layers
Model view separation principle
Collaboration and coupling from higher to lower layers
High cohesion
SVCE Page 35
Object Oriented Analysis and Design CS6502
Layer
A Layer is a coarse grained of classes,packages or subsystems
Higher Layers(UI Layer) call upon services of Lower Layers
Layers in Object Oriented System
Component Diagram shows how the physical components of a system are organized.It helps
to model the physical aspect of an object oriented software system
It illustrates the architectures of the software components and the dependencies between
them.
COMPONENTDIAGRAMNOTATION
Components are shown as rectangles with two tabs at the upper left
Dashed arrows indicate dependencies
Circle and solid line indicates an interface to the component
SVCE Page 36
Object Oriented Analysis and Design CS6502
COMPONENT ELEMENTS
A component can have
Interfaces
Usage dependencies
Ports
Connectors
Component
A Component is a physical building block of a system that encapsulates its contents
and whose manifestation is replaceable within its enviornment
A component defines its behaviour in terms of provided and required interfaces
INTERFACE
An interface
It describes a group of operations used or created by components
Provides only the operations but not the implementation
Implementation is normally provided by a class/ component
In complex systems, the physical implementation is provided by a group of
classes rather than a single class
May be shown using a rectangle symbol with a keyword <<interface>> preceding the
name
For displaying the full signature, the interface rectangle can be expanded to show
details
Can be
Provided
Required
INTERFACE
PROVIDED INTERFACE
SVCE Page 37
Object Oriented Analysis and Design CS6502
INTERFACE
REQUIRED INTERFACE
Characterize services that the component expects from its environment
Is modeled using a socket, labelled with the name, attached by a solid line to the
component
DEPENDENCIES
Components can be connected by usage dependencies
Usage Dependency
A relationship which one element requires another element for its full
implementation
A dependency in which the client requires the presence of the supplier
Is shown as dashed arrow with a <<use>> keyword
The arrowhead point from the dependent component to the one of which it is
dependent
PORT
Specifies a distinct interaction point
Between that component and its environment
Between that component and its internal parts
SVCE Page 38
Object Oriented Analysis and Design CS6502
multiple interfaces associated with a port, listed with the interface icon, separated by a
commas
EXTERNAL VIEW
INTERNAL VIEW
SVCE Page 39
Object Oriented Analysis and Design CS6502
SVCE Page 40
Object Oriented Analysis and Design CS6502
• Deployment diagrams show the hardware of the system, the software that is installed
on that hardware, and the middleware used to connect the disparate machines to one
another.
• Deployment diagram
• Shows assignment of concrete software architects(executable files) to
computational nodes
• It shows,
• Deployment of software elements to the physical architecture
• Communication between the physical elements
• Basic element – node
1.Node
element that provides the execution environment for the components of a system
ii. Execution Environment Node (EEN) - This is a software computing resource that runs
within an outer node(such as computer)and which itself provides a service to host and
execute other executable software elements Eg., OS,VM,DB Engine,Web Browser,workflow
engine,servlet container or EJB container
2. Connection
Symbol:
Solid Line
Dashed Arrow
SVCE Page 41
Object Oriented Analysis and Design CS6502
SVCE Page 42
Object Oriented Analysis and Design CS6502
Sale objects have been given a responsibility to create Payments , which is invoked
with a makePayment message and handled with a corresponding makePayment
method.
SVCE Page 43
Object Oriented Analysis and Design CS6502
9 GRASP patterns
– Information Expert
– Creator
– Controller
– Low Coupling
– High Cohesion
– Polymorphism
SVCE Page 44
Object Oriented Analysis and Design CS6502
– Pure Fabrication.
– Indirection
Name: Creator
Problem: Who creates an A?
Solution: Assign class B the responsibility to create an instance of class A if one of
these is true
Example Problem
Sale
time
Contains
1..*
Product
Sales Description
LineItem * Described-by 1
description
quantity price
itemID
SVCE Page 45
Object Oriented Analysis and Design CS6502
So Sale class aggregates SalesLineItem objects so Sale class creates the SalesLineItem
objects.
Example
Who should be responsible for knowing/getting the grand total of a sale?
Sale
time
Contains
1..*
Product
Sales Description
LineItem * Described-by 1
description
quantity price
itemID
SVCE Page 46
Object Oriented Analysis and Design CS6502
Sale
time
...
t = getTotal 1 *: st = getSubtotal lineItems[ i ] :
: Sale getTotal()
SalesLineItem
quantity
:Product getSubtotal()
Description
Product
Description
description
price
itemID
New method getPrice()
Name: Controller
Problem: What first object beyond the UI layer receives and coordinates("controls")
a system operation?
Solution: Assign the responsibility to an object representing one of these choices
Represents the overall "system," a "root object," a device that the software is running within,
or a major subsystem.
ex: ATM machine,Phone
Represents a use case scenario within which the system operation occurs(a use case or
session controller )
SVCE Page 47
Object Oriented Analysis and Design CS6502
presses button
: Cashier
actionPerformed( actionEvent )
UI Layer :SaleJFrame
presses button
Cashier
actionPerformed( actionEvent )
1: makeLineItem(itemID, qty)
Domain Layer :Sale
SVCE Page 48
Object Oriented Analysis and Design CS6502
CONTROLLER: BENEFITS
Increased potential for reuse
Plug & Play interfaces
Allows us to verify that the system operations occur in a logical sequence. For
example: makePayment() is not called before endSale()
: Register : Sale
makePayment()
create()
p : Payment
addPayment( p )
: Register : Sale
SVCE Page 49
makePayment()
makePayment()
create() : Payment
Object Oriented Analysis and Design CS6502
Coupling is a measure of how strongly one element is connected to, has knowledge
of, or depends on other elements.
If there is coupling or dependency, then when the depended-upon element changes,
the dependant may be affected.
Common form of coupling from Class A to Class B are:
makePayment() 1: create()
: Register p : Payment
2: addPayment(p)
:Sale
makePayment() 1: makePayment()
SVCE : Register :Sale Page 50
1.1. create()
:Payment
Object Oriented Analysis and Design CS6502
2.Design Patterns
Purpose of patterns
• Behavioral patterns characterize the ways in which classes or objects interact and
distribute responsibility.
• Creational Patterns
• They help make a system independent of how its objects are created, composed, and
represented.
• A class creational pattern uses inheritance to vary the class that's instantiated, whereas
an object creational pattern will delegate instantiation to another object.
Recurring themes
• First, they all encapsulate knowledge about which concrete classes the system uses.
• Second, they hide how instances of these classes are created and put together.
Configuration
• Creational patterns gives a lot of flexibility in what gets created, who creates it, how it
gets created, and when.
SVCE Page 51
Object Oriented Analysis and Design CS6502
• They let you configure a system with "product" objects that vary widely in structure
and functionality.
Configuration can be static (that is, specified at compile-time) or dynamic (at run-time)
Example
• The maze and the game will vary slightly from pattern to pattern.
• Sometimes the game will be to find your way out of a maze; in that case the player
will probably only have a local view of the maze.
• Sometimes mazes contain problems to solve and dangers to overcome, and these
games may provide a map of the part of the maze that has been explored.
Ignored Details
Ignore many details of what can be in a maze and whether a maze game has a single or
multiple players.
Focused details
• The classes Room, Door, and Wall define the components of the maze used.
• We define only the parts of these classes that are important for creating a maze.
• We'll ignore players, operations for displaying and wandering around in a maze, and
other important functionality that isn't relevant to building the maze.
SVCE Page 52
Object Oriented Analysis and Design CS6502
Room class
Class MapSite
• The class MapSite is the common abstract class for all the components of a maze.
• MapSite defines only one operation, Enter. Its meaning depends on what you're
entering.
• If you enter a room, then your location changes. If you try to enter a door, and If the
door is open, you go into the next room.
class MapSite {
public:
};
• Room is the concrete subclass of MapSite that defines the key relationships between
components in the maze.
SVCE Page 53
Object Oriented Analysis and Design CS6502
• It maintains references to other MapSite objects and stores a room number. The
number will identify rooms in the maze.
public:
Room(int roomNo);
private:
MapSite* _sides[4];
int _roomNumber;
};
The following classes represent the wall or door that occurs on each side of a room.
public:
Wall();
};
public:
Room * OtherSideFrom(Room*);
private:
Room* _room1;
SVCE Page 54
Object Oriented Analysis and Design CS6502
Room* _room2;
bool _isOpen;
};
A Maze class represents a collection of rooms. Maze can also find a particular room given a
room number using its RoomNo operation.
class Maze {
public:
Maze();
void AddRoom(Room*);
private:
// ...
};
RoomNo could do a look-up using a linear search, a hash table, or even a simple array.
• One way to create a maze is with a series of operations that add components to a
maze and then interconnect them.
• For eg, the following member function will create a maze consisting of two rooms
with a door between them
Maze* MazeGame::CreateMaze () {
aMaze->AddRoom(r1);
aMaze->AddRoom(r2);
SVCE Page 55
Object Oriented Analysis and Design CS6502
r1->SetSide(East, theDoor);
r2->SetSide(West, theDoor);
return aMaze;
Layout
• Changing the layout means changing this member function, either by overriding it—
which means reimplementing the whole thing—or by changing parts of it—which is
error-prone and doesn't promote reuse.
• Inflexible.
Use of creational
• The creational patterns show how to make this design more flexible, not necessarily
smaller.
• They will make it easy to change the classes that define the components of a maze.
Creational pattern
• Suppose you wanted to reuse an existing maze layout for a new game containing (of
all things) enchanted mazes.
• The enchanted maze game has new kinds of components, like DoorNeedingSpell, a
door that can be locked and opened subsequently only with a spell; and
EnchantedRoom, a room that can have unconventional items in it, like magic keys or
spells.
How to change CreateMaze easily so that it creates mazes with these new classes of objects
SVCE Page 56
Object Oriented Analysis and Design CS6502
Barrier
• The biggest barrier to change lies in hard-coding the classes that get instantiated.
Patterns
• If CreateMaze calls virtual functions instead of constructor calls to create the rooms,
walls, and doors it requires, then you can change the classes that get instantiated by
making a subclass of MazeGame and redefining those virtual functions. This
approach is an example of the Factory Method pattern.
Patterns
• If CreateMaze is passed an object that can create a new maze in its entirety using
operations for adding rooms, doors, and walls to the maze it builds, then you can use
inheritance to change parts of the maze or the way the maze is built. This is an
example of the Builder pattern.
Pattern
• The remaining creational pattern, Singleton, can ensure there's only one maze per
game and that all game objects have ready access to it—without resorting to global
variables or functions.
• Singleton also makes it easy to extend or replace the maze without touching existing
code.
Factory Method
SVCE Page 57
Object Oriented Analysis and Design CS6502
• Define an interface for creating an object, but let subclasses decide which class to
instantiate.
Motivation
• Frameworks use abstract classes to define and maintain relationships between objects.
• Consider a framework for applications that can present multiple documents to the
user.
• Two key abstractions in this framework are the classes Application and Document.
• Both classes are abstract, and clients have to subclass them to realize their
application-specific implementations.
• The Application class is responsible for managing Documents and will create them as
required—when the user selects Open or New from a menu, for example.
This creates a dilemma: The framework must instantiate classes, but it only knows about
abstract classes, which it cannot instantiate
Solution
• It encapsulates the knowledge of which Document subclass to create and moves this
knowledge out of the framework.
Factory Method
SVCE Page 58
Object Oriented Analysis and Design CS6502
Applicability
classes delegate responsibility to one of several helper subclasses, and you want to localize
the knowledge of which helper subclass is the delegate
Structure
SVCE Page 59
Object Oriented Analysis and Design CS6502
Participants
• Product (Document)
• ConcreteProduct (MyDocument)
• Creator (Application)
• ConcreteCreator (MyApplication)
Collaborations
Consequences
• Factory methods eliminate the need to bind application-specific classes into your
code.
SVCE Page 60
Object Oriented Analysis and Design CS6502
• The code only deals with the Product interface; therefore it can work with any user-
defined ConcreteProduct classes.
• Subclassing is fine when the client has to subclass the Creator class.
Summary
• Factory method defines the connection between the two class hierarchies.
Implementation
• Two major varieties: The two main variations of the Factory Method pattern are
(1) the case when the Creator class is an abstract class and does not provide an
implementation for the factory method it declares,
(2) the case when the Creator is a concrete class and provides a default implementation for
the factory method.
Issues
SVCE Page 61
Object Oriented Analysis and Design CS6502
• The factory method takes a parameter that identifies the kind of object to create.
• All objects the factory method creates will share the Product interface
class Creator {
public:
};
return 0;
SVCE Page 62
Object Oriented Analysis and Design CS6502
• Hence MyCreator extends the kinds of products created, and it defers responsibility
for creating all but a few products to its parent.
• The documentClass method returns the proper Document class for instantiating
documents.
clientMethod
documentClass
documentClass
^ MyDocument
• An even more flexible approach akin to parameterized factory methods is to store the
class to be created as a class variable of Application.
• That way you don't have to subclass Application to vary the product.
• Factory methods in C++ are always virtual functions and are often pure virtual.
• Do not call factory methods in the Creator's Constructor —the factory method in the
ConcreteCreator won't be available yet.
• You can avoid this by being careful to access products solely through accessor
operations that create the product on demand.
SVCE Page 63
Object Oriented Analysis and Design CS6502
• Instead of creating the concrete product in the constructor, the constructor merely
initializes it to 0.
• The accessor returns the product. But first it checks to make sure the product exists,
and if it doesn't, the accessor creates it.
class Creator {
public:
Product* GetProduct();
protected:
private:
Product* _product;
};
Product* Creator::GetProduct () {
if (_product == 0) {
_product = CreateProduct();
return _product;
• Another way to get around this in C++ is to provide a template subclass of Creator
that's parameterized by the Product class
class Creator {
public:
};
SVCE Page 64
Object Oriented Analysis and Design CS6502
public:
};
Product* StandardCreator<TheProduct>::CreateProduct () {
With this template, the client supplies just the product class—no subclassing of Creator is
required.
public:
MyProduct();
// ...
};
StandardCreator<MyProduct> myCreator;
Naming conventions
For example, the MacApp Macintosh application framework always declares the abstract
operation that defines the factory method as Class* DoMakeClass(), where Class is the
Product class.
Sample Code
First we'll define factory methods in MazeGame for creating the maze, room, wall, and
door objects:
class MazeGame {
public:
SVCE Page 65
Object Oriented Analysis and Design CS6502
Maze* CreateMaze();
// factory methods:
};
Maze* MazeGame::CreateMaze () {
Room* r1 = MakeRoom(1);
Room* r2 = MakeRoom(2);
aMaze->AddRoom(r1);
aMaze->AddRoom(r2);
r1->SetSide(North, MakeWall());
r1->SetSide(East, theDoor);
r1->SetSide(South, MakeWall());
r1->SetSide(West, MakeWall());
r2->SetSide(North, MakeWall());
r2->SetSide(East, MakeWall());
r2->SetSide(South, MakeWall());
SVCE Page 66
Object Oriented Analysis and Design CS6502
r2->SetSide(West, theDoor);
return aMaze;
public:
BombedMazeGame();
};
public:
EnchantedMazeGame();
protected:
};
STRUCTURAL PATTERNS
• are concerned with how classes and objects are composed to form larger structures.
SVCE Page 67
Object Oriented Analysis and Design CS6502
• As a simple example, consider how multiple inheritance mixes two or more classes
into one. The result is a class that combines the properties of its parent classes.
• This pattern is useful for making independently developed class libraries work
together.
• The added flexibility of object composition comes from the ability to change the
composition at run-time, which is impossible with static class composition.
Composite
• describes how to build a class hierarchy made up of classes for two kinds of objects:
– primitive and
– composite.
The composite objects let you compose primitive and other composite objects into arbitrarily
complex structures
Proxy
Flyweight
SVCE Page 68
Object Oriented Analysis and Design CS6502
• Applications that use lots of objects must pay careful attention to the cost of each
object.
Flyweight
• But objects can be shared only if they don't define context –dependent state.
• Flyweight objects have no such state. Any additional information they need to
perform their task is passed to them when needed.
Façade
• The facade carries out its responsibilities by forwarding messages to the objects it
represents.
Bridge
The Bridge pattern separates an object's abstraction from its implementation so that you can
vary them independently.
Decorator
• For example, a Decorator object containing a user interface component can add a
decoration like a border or shadow to the component, or it can add functionality like
scrolling and zooming.
• We can add two decorations simply by nesting one Decorator object within another,
and so on for additional decorations.
SVCE Page 69
Object Oriented Analysis and Design CS6502
• To accomplish this, each Decorator object must conform to the interface of its
component and must forward messages to it.
• The Decorator can do its job (such as drawing a border around the component) either
before or after forwarding a message.
Adapter
• Adapter lets classes work together that couldn't otherwise because of incompatible
interfaces.
• AKA Wrapper
Motivation
Applicability
SVCE Page 70
Object Oriented Analysis and Design CS6502
• you want to use an existing class, and its interface does not match the one you need.
• you want to create a reusable class that cooperates with unrelated or unforeseen
classes, that is, classes that don't necessarily have compatible interfaces.
• (object adapter only) you need to use several existing subclasses, but it's impractical
to adapt their interface by subclassing every one. An object adapter can adapt the
interface of its parent class.
Participants
• Target (Shape)
SVCE Page 71
Object Oriented Analysis and Design CS6502
• Client (DrawingEditor)
• Adaptee (TextView)
• Adapter (TextShape)
Collaborations
Clients call operations on an Adapter instance. In turn, the adapter calls Adaptee operations
that carry out the request
Consequences
• introduces only one object, and no additional pointer indirection is needed to get to
the adapter
TextShape::TextShape (TextView* t) {
_text = t;
void TextShape::BoundingBox (
) const {
SVCE Page 72
Object Oriented Analysis and Design CS6502
return _text->IsEmpty();
Strategy
Intent
• Strategy lets the algorithm vary independently from clients that use it.
Motivation
• Many algorithms exist for breaking a stream of text into lines. Hard-
wiring all such algorithms into the classes that require them isn't desirable
for several reasons:
• Clients that need linebreaking get more complex if they include the
linebreaking code. That makes clients bigger and harder to maintain,
especially if they support multiple linebreaking algorithms.
• It's difficult to add new algorithms and vary existing ones when
linebreaking is an integral part of a client.
in a text viewer.
• It's useful for breaking a collection of icons into rows, for example.
SVCE Page 74
Object Oriented Analysis and Design CS6502
Applicability
• An algorithm uses data that clients shouldn't know about. Use the
Strategy pattern to avoid exposing complex, algorithm-specific data
structures.
Structure
SVCE Page 75
Object Oriented Analysis and Design CS6502
Participants
Strategy (Compositor)
Context (Composition)
Collaborations
SVCE Page 76
Object Oriented Analysis and Design CS6502
• A context may pass all data required by the algorithm to the strategy
when the algorithm is called.
Consequences
• Encapsulating the algorithm in separate Strategy classes lets you vary the
algorithm independently of its context, making it easier to switch,
understand, and extend.
SVCE Page 77
Object Oriented Analysis and Design CS6502
For example, without strategies, the code for breaking text into lines could
look like
void Composition::Repair () {
switch (_breakingStrategy) {
case SimpleStrategy:
ComposeWithSimpleCompositor();
break;
case TeXStrategy:
ComposeWithTeXCompositor();
break;
// ...
void Composition::Repair () {
_compositor->Compose();
SVCE Page 78
Object Oriented Analysis and Design CS6502
• The client can choose among strategies with different time and space
trade-offs.
must understand how Strategies differ before it can select the appropriate one.
• times when the context creates and initializes parameters that never get
used.
Implementation
implementation issues:
SVCE Page 79
Object Oriented Analysis and Design CS6502
• On the other hand,Context might pass data the Strategy doesn't need.
• Context must define a more elaborate interface to its data, which couples
Strategy and Context more closely.
class Context {
// ...
private:
AStrategy theStrategy;
SVCE Page 80
Object Oriented Analysis and Design CS6502
};
• The class is then configured with a Strategy class when it's instantiated:
class MyStrategy {
public:
void DoAlgorithm();
};
Context<MyStrategy> aContext;
Context checks to see if it has a Strategy object before accessing it. If there is
one, Context uses it normally.
Sample Code
• The stretchability defines how much the component can grow beyond its
natural size; shrinkability is how much it can shrink.
SVCE Page 81
Object Oriented Analysis and Design CS6502
class Composition {
public:
Composition(Compositor*);
void Repair();
private:
Compositor* _compositor;
// in components
};
• The composition passes the compositor three arrays that define natural
sizes, stretchabilities,and shrinkabilities of the components.
• It also passes the number of components, how wide the line is, and an
array that the compositor fills with the position of each linebreak.
class Compositor {
public:
SVCE Page 82
Object Oriented Analysis and Design CS6502
) = 0;
protected:
Compositor();
};
void Composition::Repair () {
Coord* natural;
Coord* stretchability;
Coord* shrinkability;
int componentCount;
int* breaks;
// ...
int breakCount;
breakCount = _compositor->Compose(
);
Known Uses
Observer
Intent
Observer
SVCE Page 84
Object Oriented Analysis and Design CS6502
• In response, each observer will query the subject to synchronize its state
with the subject's state.
• It sends out these notifications without having to know who its observers
are.
Applicability
SVCE Page 85
Object Oriented Analysis and Design CS6502
• When a change to one object requires changing others, and don't know
how many objects need to be
changed.
are.
Structure
Subject
Observer
SVCE Page 86
Object Oriented Analysis and Design CS6502
ConcreteSubject
ConcreteObserver
Consequences
SVCE Page 87
Object Oriented Analysis and Design CS6502
• The subject doesn't care how many interested objects exist; its only
responsibility is to notify its observers.
• This gives the freedom to add and remove observers at any time.
Unexpected updates.
• Observers have no knowledge of each other's presence, they can be blind
to the ultimate cost of changing the subject.
Issues
SVCE Page 88
Object Oriented Analysis and Design CS6502
the observers.
• For example, a spreadsheet may depend on more than one data source.
• Necessary to extend the Update interface in such cases to let the observer
know which subject is sending the notification.
• The subject can simply pass itself as a parameter in the Update operation,
thereby letting the observer know
• The subject and its observers rely on the notification mechanism to stay
consistent.
a. Have state-setting operations on Subject call Notify after they change the
subject's state.
Advantage
Disadvantage
be inefficient.
Advantage
• client can wait to trigger the update until after a series of state changes
has been made, thereby avoiding needless intermediate updates.
Disadvantage
• Makes errors more likely, since clients might forget to call Notify.
• For ex, the notification in the following code sequence is trigged when
the subject is in an inconsistent state:
BaseClassSubject::Operation(newValue);
// trigger notification
_myInstVar += newValue;
SVCE Page 90
Object Oriented Analysis and Design CS6502
Notify();
• The push model, the subject sends observers detailed information about
the change, whether they want it or not.
• The pull model; the subject sends nothing but the most minimal
notification, and observers ask for details explicitly thereafter.
• The push model assumes subjects know something about their observers'
needs.
• The push model might make observers less reusable, because Subject
classes make assumptions about Observer classes that might not always
be true.
SVCE Page 91
Object Oriented Analysis and Design CS6502
the Subject.
• When such an event occurs, the subject informs only those observers that
have registered interest in that event.
• A ChangeManager:
SVCE Page 92
Object Oriented Analysis and Design CS6502
• In Smalltalk, for example, the Subject and Observer interfaces are defined
in the root class Object, making them available to all classes.
Case study – the Next Gen POS system, Inception -Use case Modeling - Relating Use cases –
include, extend and generalization - Elaboration - Domain Models - Finding conceptual
classes and description classes – Associations – Attributes – Domain model refinement –
Finding conceptual class Hierarchies - Aggregation and Composition
point-of-sale(POS)
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.
SVCE Page 93
Object Oriented Analysis and Design CS6502
A POS system increasingly must support multiple and varied client-side terminals and
interfaces.
Inception:
The purpose of the inception step is not to define all the requirements, or generate a
believable estimate or project plan.
Inception phase should be relatively short for most projects, such as one or a few
weeks long.
The intent of inception is to establish some initial common vision for the objectives of
the project, determine if it is feasible, and decide if it is worth some serious
investigation in elaboration.
SVCE Page 94
Object Oriented Analysis and Design CS6502
Requirements:
Requirements are capabilities and conditions to which the system and more broadly,
the project must conform.
Types of Requirements:
Functional—features, capabilities, security.
Usability—human factors, help, documentation.
Reliability—frequency of failure, recoverability, predictability.
Performance—response times, throughput, accuracy, availability, resource usage.
Supportability—adaptability, maintainability, internationalization, configurability.
Implementation—resource limitations, languages and tools, hardware.
Interface—constraints imposed by interfacing with external systems.
Operations—system management in its operational setting.
Packaging
Legal—licensing and so forth
2.USE-CASE MODEL
SVCE Page 95
Object Oriented Analysis and Design CS6502
Notations:
An actor is something with behavior, such as a person (identified by role), computer system,
or organization; for example, a cashier.
Informally then, a use case is a collection of related success and failure scenarios that
describe actors using a system to support a goal. For example, here is a casual format use
case that includes some alternate scenarios:
Handle Returns
Main Success Scenario: A customer arrives at a checkout with items to return. The cashier
uses the POS system to record each returned item ...
Alternate Scenarios:
If the credit authorization is reject, inform the customer and ask for an alternate payment
method.
If the item identifier is not found in the system, notify the Cashier and suggest manual entry
of the identifier code (perhaps it is corrupted).
If the system detects failure to communicate with the external tax calculator system, ...
Use cases are text documents, not diagrams, and use-case modeling is primarily an act
of writing text, not drawing. However, the UML defines a use case diagram to
illustrate the names of use cases and actors, and their relationships.
Black-box use cases are the most common and recommended kind; they do not describe the
internal workings of the system, its components, or design. Rather, the system is described as
having responsibilities, which is a common unifying metaphorical theme in object-oriented
thinking—software elements have responsibilities and collaborate with other elements that
have responsibilities it is possible to specify what the system must do (the functional
requirements) without deciding how it will do it (the design).
SVCE Page 96
Object Oriented Analysis and Design CS6502
Formality Types
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.
SVCE Page 97
Object Oriented Analysis and Design CS6502
Preconditions state what must always be true before beginning a scenario in the use case.
Preconditions are not tested within the use case; rather, they are conditions that are assumed
to be true. Typically, a precondition implies a scenario of another use case that has
successfully completed, such as logging in, or the more general "cashier is identified and
authenticated."
SVCE Page 98
Object Oriented Analysis and Design CS6502
Success guarantees (or postconditions) state what must be true on successful completion of
the use case.either the main success scenario or some alternate path. The guarantee should
meet the needs of all stakeholders.
Use cases can be related to each other. For example, a subfunction use case such as Handle
Credit Payment may be part of several regular use cases, such as Process Sale and Process
Rental. Organizing use cases into relationships has no impact on the behavior or requirements of
the system. Rather, it is simply an organization mechanism to (ideally) improve communication
and comprehension of the use cases, reduce duplication of text, and improve management of the
use case documents.
3 types:
The include Relationship
The extend Relationship
The generalize Relationship
A concrete use case is initiated by an actor and performs the entire behaviour desired by the
actor . These are the elementary business process use cases. For example, Process Sale is a
concrete use case.
Abstract use case is never instantiated by itself; it is a subfunction use case that is part of
another use case. Handle Credit Payment is abstract; it doesn't stand on its own, but is always
part of another story, such as Process Sale.
A use case that includes another use case, or that is extended or specialized by
another use case is called a base use case. Process Sale is a base use case with
respect to the included Handle Credit Payment subfunction use case.
On the other hand, the use case that is an inclusion, extension, or specialization is
called an addition use case. Handle Credit Payment is the addition use case in
the include relationship to Process Sale.
– a dotted line labeled <<extend>> with an arrow toward the base case.
– The extending use case may add behavior to the base use case. The base class
declares “extension points”.
<<extend>>
ELABORATION
Elaboration is the initial series of iterations during which the team does serious
investigation, implements (programs and tests) the core architecture, clarifies most
requirements, and tackles the high-risk issues.
Elaboration often consists of between two and four iterations; each iteration is
recommended to be between two and six weeks
Each iteration is timeboxed, meaning its end date is fixed; if the team is not likely to
meet the date, requirements are placed back on the future tasks list, so that the
iteration can end on time with a stable and tested release.
2. Design Model: This is the set of diagrams that describes the logical design. This includes
software class diagrams, object interaction diagrams ,package diagrams, and so forth.
3. Software Architecture Document: A learning aid that summarizes the key architectural
issues and their resolution in the design. It is a summary of the outstanding design ideas and
their motivation in the system.
4. Data Model : This includes the database schemas, and the mapping strategies between
object and non-object representations.
Domain Models
Conceptual Classes:
The domain model illustrates conceptual classes or vocabulary in the domain. Informally, a
conceptual class is an idea, thing, or object. More formally, a conceptual class may be
considered in terms of its symbol, intension, and extension
DOMAIN MODEL:
ADDING ASSOCIATIONS
An association is a relationship between types (or more specifically, instances of those types)
that indicates some meaningful and interesting connection.
In the UML associations are defined as "the semantic relationship between two
or more classifiers that involve connections among their instances."
Association Guidelines:
Too many associations tend to confuse a domain model rather than illuminate it. Their
discovery can be time-consuming, with marginal benefit.
Avoid showing redundant or derivable associations
SVCE Page 110
Object Oriented Analysis and Design CS6502
Roles:
Each end of an association is called a role. Roles may optionally have:
1.name
2.multiplicity expression
3.navigability
Multiplicity:
Multiplicity defines how many instances of a class A can be associated with one
instance of a class B
Naming Associations
Name an association based on a TypeName-VerbPhrase-TypeName format where the verb
phrase creates a sequence that is readable and meaningful in the model context.
Association names should start with a capital letter, since an association represents a
classifier of links between instances; in the UML, classifiers should start with a capital letter.
Two common and equally legal formats for a compound association name are:
• Paid-by
• PaidBy
DOMAIN MODEL:
ADDING ATTRIBUTES:
Data Types
Attributes should generally be data types
Association Classes:
Association class, in which we can add features to the association itself. ServiceContract
may be modeled as an association class related to the association between Store and
AuthorizationService.
In the UML, this is illustrated with a dashed line from the association to the association class.
visually communicates the idea that a Service-Contract and its attributes are related to the
association between a Store and AuthorizationService, and that the lifetime of the
ServiceContract is dependent on the relationship.
Guidelines:
Aggregation is shown in the UML with a hollow or filled diamond symbol at the composite
end of a whole-part association.
It clarifies the domain constraints regarding the eligible existence of the part
independent of the whole. In composite aggregation, the part may not exist outside of the
lifetime of the whole.
Operations—such as copy and delete—applied to the whole often propagate to the parts
In the POS domain, the SalesLineItems may be considered a part of a composite Sale;
in general, transaction line items are viewed as parts of an aggregate transaction. In addition
to conformance to that pattern, there is a create-delete dependency of the line items on the
Sale—their lifetime is bound within the lifetime of the Sale. By similar justification,
ProductCatalog is an aggregate of Product-Specifications
Role name:
Each end of an association is a role, which has various properties, such as:
name
multiplicity
A role name identifies an end of an association and ideally describes the role played by
objects in the association. Figure shows role name examples.
Roles in associations are appealing because they are a relatively accurate way to express the
notion that the same instance of a person takes on multiple (and dynamically changing) roles
in various associations. I, a person, simultaneously or in sequence, may take on the role of
writer, object designer, parent, and so on.
On the other hand, roles as concepts provides ease and flexibility in adding unique attributes,
associations, and additional semantics. Furthermore, the implementation of roles as separate
classes is easier because of limitations of current popular object-oriented programming
languages—it is not convenient to dynamically mutate an instance of one class into another,
or dynamically add behavior and attributes as the role of a person changes.
Derived Elements:
A derived element can be determined from others. Attributes and associations are the most
common derived elements
For example, a Sale total can be derived from SalesLineItem and Product-Specification
information. In the UML, it is shown with a "/" preceding the element name.
Qualified Associations
A qualifier may be used in an association; it distinguishes the set of objects at the far end of
the association based on the qualifier value. An association with a qualifier is a qualified
association.
In fig 2 qualification reduces the multiplicity at the far end from the qualifier, usually down
from many to one
Reflexive Associations:
A concept may have an association to itself; this is known as a reflexive association.
Ordered Elements:
If associated objects are ordered, this can be shown as in Figure, For example, the
SalesLineItems must be maintained in the order entered
A UML package is shown as a tabbed folder.Subordinate packages may be shown within it.
The package name is within the tab if the package depicts its elements; otherwise, it is
centered within the folder itself.
An element is owned by the package within which it is defined, but may be referenced in
other packages. In that case, the element name is qualified by the package name using the
pathname format PackageName::ElementName
Package Dependencies:
If a model element is in some way dependent on another, the dependency may be shown with
a dependency relationship, depicted with an arrowed line. A package dependency indicates
that elements of the dependent package in some way know about or are coupled to elements
in the target package.
For example, if a package references an element owned by another, a dependency exists.
Thus, the Sales package has a dependency on the Core Elements package.
At times, it is inconvenient to draw a package diagram, but still desirable to indicate the
package that the elements are a member of.
In this situation, include a note (dog-eared note) on the diagram, as illustrated,
To partition the domain model into packages, place elements together that:
are in the same subject area — closely related by concept or purpose
are in a class hierarchy together
participate in the same use cases
are strongly associated
Core/Misc Package:
A Core/Misc package is useful to own widely shared concepts or those without an obvious
home. In later references, the package name will be abbreviated to Core.
There are no new concepts or associations particular to this iteration in this Package.
Signals
Notations:
Transition
Events
state
System sequence diagrams - Relationship between sequence diagrams and use cases- Logical
architecture and UML package diagram – Logical architecture refinement - UML class
diagrams – UML interaction diagrams - Applying GoF design patterns
SSD needs:
-External events
-Timer events
-Faults/exception
Illustrates input and output events related to the system under discussion.
For the purpose of software development, the system boundary is chosen to be the
software system itself.
System event
System operation
– Strict layered
– Relaxed layered
Typical Layers
• User interface
• In strict layering, a layer only calls upon services in the layer directly below it.
Software Architecture
• Selection of structural elements and their interfaces, along with their behavior.
• The logical architecture is the large-scale organization of the classes into packages
(namespaces), subsystems, and layers.
Reverse-Engineering
• UML case tools is to reverse engineer the source-code and generate a package
diagram automatically.
Package
UI Domain
UI
UI::Swing UI::Web
Swing Web
Domain::Sales
Domain
Sales
Layers Benefits
• Logical segmentation.
• GUI
• Business infrastructure
• Tech services
Cohesive Responsibilities
• Lower representation gap between real world domain and software design.
• Tiers were originally logical layers, but now the term has come to mean physical
nodes.
• Layers are vertical slices, while partitions are horizontal divisions of subsystems
within a layer. E. g. tech services may contain Security and Reporting
Model-View Separation
• Don’t connect non-UI objects directly to UI objects. Don’t let a Sale object reference
directly a Jframe
• No application layer
• Hiding UI objects
• System operations invoked on the system are request generated by an actor via UI
layer onto the application layer.
– All layers deployed within the same process on the same node.
• Interface
• Application logic
• Storage
– Monitoring application
– Simulation application
• +/- visibility,compartments.
• Multiple perspectives
UML Attributes
•
UML Attributes: Attribute Text & Association lines
1. Navigation arrow
4. No association name
• Property string
– {Ordered}/{Ordered,List}
//}
Dependency
• Kinds of dependency,
– Implementation of an interface
– Attributes
Dependency Labels
Interfaces
• Guideline:
Qualified Association
Association class
• It treats association itself as a class & model it with attributes, operation & other
features.
Singleton classes
• Class can be marked with a ‘1’ in the upper right corner of the compartment
Active class
• Shown with double vertical lines on left & right side of class box
• Types:
– Sequence diagram
Sequence Diagram
Communication Diagram
– Actual lifelines
– Dashed ->UML
– Solid/dashed ->UML2
• Messages
– Actual lifelines
– Dashed ->UML
– Solid/dashed ->UML2
• Messages
• Message syntax
– Return var=message(parameter)
• Getdate--
• -- adate
Creation of Instances
Diagram frames
Frame formats
Frame Meaning
operator
region Critical regions within which only one thread can run
SD notation
• Conditional message :
Nesting of frames
Interaction diagrams
• Asynchronous message
– doesn’t block
– Filled arrow.
• Links
– Instance of an association
Instance creation
Conditional messages
Iteration or looping
design patterns are becoming common knowledge, which leads to better communication.
To summarize design patterns save time, energy while making your life easier.
The following GOF design patterns are explored in the subsequent sections :
Adapter
Analysis
Factory
Singleton
Strategy
Composite
SINGLETON
The singleton pattern deals with situations where only one instance of a class must be
created. Take the case of a system administrator or superuser. This person has the right to
do everything in a computer system. In addition we will also have classes representing
normal users. Therefore we must ensure that these classes have no access to the super
user constructor. The solution to this problem in C++ and Java is to declare the superuser
constructor private. The superuser class itself has a private static attribute sysadmin,
which is initialised using the class constructor. Now we get an instance of the super user
class with a public static method that returns sysadmin. Here is the class diagram:
FACTORY METHOD
The Factory Method pattern deals with situations where at runtime one of several similar
classes must be created. Visualize this as a factory that produces objects. In a toy factory
for instance we have the abstract concept of toy. Every time we get a request for a new
toy a decision must be made - what kind of a toy to manufacture. Similarly to the
Singleton pattern the Factory Method pattern utilises a public static accessor method. In
our example the abstract Toyfactory class will have a getInstance() method, which is
inherited by its non abstract subclasses.
ADAPTER
Sometimes you will have two classes that can in principle work well together, but they
can't interface with each other for some reason. This kind of problem occurs when
travelling abroad and you carry an electric shaver with you. Although it will work
perfectly when you are at home. There can be problems in a foreign country, because of a
different standard voltage. The solution is to use an adapter. Let's turn our attention back
to the software domain. Here we will have an interface which defines new methods for
example getElectricity2. An adapter class will wrap around the Shaver class. The adapter
class will implement the interface with the new method.
PROXY
The Proxy pattern deals with situations where you have a complex object or it takes a
long time to create the object. The solution to this problem is to replace the complex
object with a simple 'stub' object that has the same interface. The stub acts as a body
double. This is the strategy used by the Java Remote Method Invocation API. The reason
to use the proxy pattern in this case is that the object is on a remote server causing
network overhead. Other reasons to use the proxy can be restricted access (Java applets
for example) or time consuming calculations.
DECORATOR
The Decorator is usually a subclass, that is a body double for its superclass or another
class with identical interface. The goal of the Decorator pattern is to add or improve the
capabilities of the super class.
COMPOSITE
The composite is often encountered in GUI packages like for instance the Java Abstract
Windwing Toolkit (AWT) or Microsoft Foundation (MFC) classes. All objects in this
pattern have a common abstract superclass that descibes basic object conduct. The base
class in the MFC hierarchy is CObject. It provides functions for debugging and
serialization. All the MFC classes even the most basic ones inherit these facilities.
that it's just a matter of writing down datatypes as appropriate. Thanks to OOP and the
Template Design Pattern less code is required for this task. First we need to define an
abstract Template class let's call it SortTemplate and it will have methods sort, compare
and process (performs one cycle of the algorithm). Then we define concrete classes for
each datatype. These classes are subclasses of SortTemplate and implement the compare
and process methods.
STRATEGY
The Strategy Design Pattern makes it possible choose an implementation of an algorithm
at run time. The implementation classes implement the same interface. In the case of the
Java AWT Layout classes, the common interface is LayoutManager.
OO development is iterative
Interaction diagrams and DCD’s will be used as the input to the code generation
process.
OOA/D artifacts feed into implementation model in a traceable manner
Some tools generate partial code from UML
But programming not trivial code generation step
Programmers make changes as they work out the details
Therefore, Expect and plan for change and deviation from design during
programming.
Reference Attributes
Reference Attributes are suggested by associations and navigability in a class
diagram.
Note that reference attributes may be implied rather than explicit on a class
diagram. You may have to ask “How is this association accomplished.”
Example: A product specification reference on a Sales Line Item.
Each end of an association is a role. Reference Attributes are often suggested by
role names.
(use role names as the names of reference attributes).
{
ProductDescription desc = catalog.ProductDescription(id);
currentSale.makeLineItem(desc, qty);
}
1: desc := getProductDescription(id)
SVCE Page 171
:Product
Catalog
Object Oriented Analysis and Design CS6502
Collection classes
Sale
public class Sale
{ isComplete : Boolean
... time : DateTime SalesLineItem
lineItems
private List lineItems = new ArrayList(); becomeComplete() quantity : Integer
1..*
} makeLineItem()
getSubtotal()
makePayment()
getTtotal()
{lineItems.add( new
SalesLineItem(desc,qty));
}
Order of Implementation
First implement classes that are loosely coupled then move on to classes that
are closely coupled.
Store
7
address : Address
1 2
name : Text
3 ProductDescription
ProductCatalog
addSale(...)
description : Text
... price : Money
1 1..* itemID : ItemID
getProductDesc(...)
...
1
1 Sale
5
6
Register isComplete : Boolean 4
time : DateTime SalesLineItem
...
becomeComplete() quantity : Integer
endSale() 1 1..*
makeLineItem(...)
Test – Driven
enterItem(...) or Test – FirstmakePayment(...)
Development getSubtotal()
makeNewSale()
getTotal()
makePayment(...)
...
amount : Money
1
...
Object Oriented Analysis and Design CS6502
• A unit
– Is a smallest software component that can be compiled and
executed.
– Is a software component that would never be assigned to more than
one developer to develop.
Hence to define an object – oriented unit as the work of one person, which ends
up as a set of class operations.
Example:
• To make Lever class the smart object because it knows when it is in the
intermittent state.
• With this choice , when the response to the lever event puts the lever in
the INT state, a method gets the dial status and simply tells the wiper
what speed is needed.
• With this choice three classes are more tightly coupled and hence less
reusable.
• Problem – lever in INT and a dial event occurs, no message would be
sent to wiper because there is no reason for the lever to get dial position.
Third choice
• More encapsulated the classes are, the more they are composed ( more
reusable) & tested.
Implications of inheritance
Checking Account and savings account are stand alone units to test.
If we do not flatten we would not have access to balance attributes.
Implications of polymorphism
– Month
– Year
CRC - Class Responsibility Cards for each class.
Class: CalendarUnit
Class: testIt
Class: Date
Classes as units
3 views of a class:
Static class
Compile-time view
Execution time view
------------------------------------------------------------------------------------------------
--------------------
OO INTEGRATION TESTING
Levels of Testing
Requirements System
Specification Testing
Preliminary Integration
Design Testing
Detailed
Unit
Design
Testing
Coding
In UML defined OO software, collaboration & sequence diagrams are the basis
for integration testing. At the system level – UML description is comprised of
various levels of use cases, use case diagram, class definitions and class
diagrams.
After this level, integration level details are added. Collaboration diagram
shows message traffic among classes
Top-Down
Bottom-Up
Sandw ich
Big Bang
Pair-wise
Neighborhood
3. Based on Paths
MM-Paths
. Atomic System Functions
At the class level, the behavior model of class is state chart.State charts serve as
test cases. At a higher level, it is difficult to combine state charts.
Start with ultra-center and add nodes that are one edge away, then add nodes
that are 2 edges away and so on..
------------------------------------------------------------------------------------------------
----------------
SVCE Page 191
Object Oriented Analysis and Design CS6502
Sequence diagram
-Class level
Sequence diagram traces execution time path .Serve as basis for integration
testing.
------------------------------------------------------------------------------------------------
---------------------
• Method/Message path
• MM-path starts with a method and ends when it reaches a method that
does not issue any messages of its own.
-------
--
------------------------------------------------------------------------------------------------
Data can get values from inheritance tree.Data can be defined at various stages
of message passing.Program graphs are formed
Definition
petrinet
GUI TESTING
• Test a GUI application – begin with user input events and all system
output events.
Example
High level complete view of application. State are external appearances of GUI.
Methods:Run test cases from a specifically coded driver that would provide
values for input data and check output values against expected values.
Use GUI as a test bed. Good for small applications.Harder to capture text
execution results.
Methods: Concentrates all logic in one place and simply uses the status of the
option buttons as conditions in IF test
Second – more object oriented – have methods in each option button object.
Event driven petri nets to describe threads to be tested.Port i/p and o/p events
in currency conversion GUI.
Atomic system functions and data places that needed to make EPDN of the
GUI.
The next step is building an EPDN description of the currency conversion GUI
is to develop EPDN’s for individual atomic system functions.
System level threads are built by composing atomic system function into
sequence.
T1=<s1,s4,s6,s7>
T2=<s1,s2,s6,s7>
T3=<s3,s1,s6,s8>
T4=<s5,s1,s7,s8>
Set T constitutes minimum level of system testing for the currency conversion
GUI.
------------------------------------------------------------------------------------------------
SYSTEM TESTING:
• Port Input
• Output events.
project Inception
Essential Usecases
• Essential usecases add actor and system events to high level usecase.
• Actors – sources of system level inputs.
• Actors – people, devices, adjacent systems or abstractions such as time.
• The numbering of actor actions and system responses show their
approximate sequences in time.
• Essential usecases add actor and system events to high level usecase.
• Actors – sources of system level inputs.
• Actors – people, devices, adjacent systems or abstractions such as time.
• The numbering of actor actions and system responses show their
approximate sequences in time.
Expanded EUC
Real Usecases :
There are four identifiable levels with corresponding coverage metrics for
GUI applications.
Two of these are dependent on UML specification.
Level 1
SVCE Page 209
Object Oriented Analysis and Design CS6502
Level 3:
• Derive test cases from finite state machines derived from finite state
description of the external appearance of the GUI.
• A test case from this formulation is a circuit.
• Nine test cases are derived.
Level 4: