Cir 206 Software Engineering Notes - 2
Cir 206 Software Engineering Notes - 2
YEAR 2 SEMESTER 2
CCS 206: SOFTWARE ENGINEERING
NOTES 2
Introduction
Uses of Measurement
• Can be applied to the software process with the intent of improving it on a continuous basis
• Can be used throughout a software project to assist in estimation, quality control, productivity
assessment, and project control
• Can be used to help assess the quality of software work products and to assist in tactical decision
making as a project proceeds
Reasons to Measure
• To characterize in order to
Gain an understanding of processes, products, resources, and environments
Establish baselines for comparisons with future assessments
• To evaluate in order to
Determine status with respect to plans
• To predict in order to
Gain understanding of relationships among processes and products
Build models of these relationships
• To improve in order to
57
Identify roadblocks, root causes, inefficiencies, and other opportunities for improving
product quality and process performance
58
Use of Project Metrics
Software Measurement
Size-oriented Metrics
• Derived by normalizing quality and/or productivity measures by considering the size of the
software produced
• Thousand lines of code (KLOC) are often chosen as the normalization value
• Metrics include
Errors per KLOC - Errors per person-month
Defects per KLOC - KLOC per person-month
Dollars per KLOC - Dollars per page of documentation
Pages of documentation per KLOC
59
• Size-oriented metrics are not universally accepted as the best way to measure the software
process
• Opponents argue that KLOC measurements
Are dependent on the programming language
Penalize well-designed but short programs
Cannot easily accommodate nonprocedural languages
Require a level of detail that may be difficult to achieve
Function-oriented Metrics
• Function-oriented metrics use a measure of the functionality delivered by the application as a
normalization value
• Most widely used metric of this type is the function point:
60
• The table on the next slide provides a rough estimate of the average LOC to one FP in various
programming languages
C++ 66 53 29 178
COBOL 77 77 14 400
Java 55 53 9 214
PL/1 78 67 22 263
Visual 47 42 16 158
Basic
Object-oriented Metrics
• Number of scenario scripts (i.e., use cases)
This number is directly related to the size of an application and to the number of test
cases required to test the system
• Number of key classes (the highly independent components)
Key classes are defined early in object-oriented analysis and are central to the problem
domain
This number indicates the amount of effort required to develop the software
It also indicates the potential amount of reuse to be applied during development
• Number of support classes
Support classes are required to implement the system but are not immediately related to
the problem domain (e.g., user interface, database, computation)
This number indicates the amount of effort and potential reuse
• Average number of support classes per key class
Key classes are identified early in a project (e.g., at requirements analysis)
Estimation of the number of support classes can be made from the number of key classes
GUI applications have between two and three times more support classes as key classes
Non-GUI applications have between one and two times more support classes as key
classes
• Number of subsystems
A subsystem is an aggregation of classes that support a function that is visible to the end
user of a system
61
This is the number of defects per KLOC, where a defect is a verified lack of conformance
to requirements
Defects are those problems reported by a program user after the program is released for
general use
• Maintainability
This describes the ease with which a program can be corrected if an error is found,
adapted if the environment changes, or enhanced if the customer has changed
requirements
Mean time to change (MTTC) : the time to analyze, design, implement, test, and
distribute a change to all users
• Maintainable programs on average have a lower MTTC
62
Software Metrics Baseline Process
System Engineering
Computer-based system
System engineering process
“Business process” engineering
Product engineering
63
Computer-based System
Introduction
System
• System (Webster)
A set or arrangement of things so related as to form a unity or organic whole
A set of facts, principles, rules. etc., … to show a logical plan linking the various parts
A method or plan of classification or arrangement
An established way of doing something such as a method or procedure
Computer-based System
• Defined: A set or arrangement of elements that are organized to accomplish some predefined goal
by processing information
• The goal may be to support some business function or to develop a product that can be sold to
generate business revenue
• A computer-based system makes use of system elements
• Elements constituting one system may represent one macro element of a still larger system
• Example
A factory automation system may consist of a numerical control machine, robots, and
data entry devices; each can be its own system
At the next lower hierarchical level, a manufacturing cell is its own computer-based
system that may integrate other macro elements
• The role of the system engineer is to define the elements of a specific computer-based system in
the context of the overall hierarchy of systems
• A computer-based system makes use of the following four system elements that combine in a
variety of ways to transform information
Software: computer programs, data structures, and related work products that serve to
effect the logical method, procedure, or control that is required
Hardware: electronic devices that provide computing capability, interconnectivity
devices that enable flow of data, and electromechanical devices that provide external
functions
People: Users and operators of hardware and software
Database: A large, organized collection of information that is accessed via software and
persists over time
• The uses of these elements are described in the following:
Documentation: Descriptive information that portrays the use and operation of the
system
Procedures: The steps that define the specific use of each system element or the
procedural context in which the system resides
64
System Engineering Hierarchy
• Defines the processes (e.g., domain classes in OO terminology) that serve the needs of the view
under consideration
• Represents the behavior of the processes and the assumptions on which the behavior is based
• Explicitly defines intra-level and inter-level input that form links between entities in the model
• Represents all linkages (including output) that will enable the engineer to better understand the
view
• May result in models that call for one of the following
Completely automated solution
A semi-automated solution
A non-automated (i.e., manual) approach
• Assumptions
These reduce the number of possible variations, thus enabling a model to reflect the
problem in a reasonable manner
• Simplifications
These enable the model to be created in a timely manner
• Limitations
These help to bound the maximum and minimum values of the system
• Constraints
65
These guide the manner in which the model is created and the approach taken when the
model is implemented
• Preferences
These indicate the preferred solution for all data, functions, and behavior
They are driven by customer requirements
Product Engineering
• Product engineering translates the customer's desire for a set of defined capabilities into a
working product
• It achieves this goal by establishing a product architecture and a support infrastructure
Product architecture components consist of people, hardware, software, and data
Support infrastructure includes the technology required to tie the components together
and the information to support the components
• Requirements engineering elicits the requirements from the customer and allocates function and
behavior to each of the four components
• System component engineering happens next as a set of concurrent activities that address each of
the components separately
Each component takes a domain-specific view but maintains communication with the
other domains
The actual activities of the engineering discipline takes on an element view
• Analysis modeling allocates requirements into function, data, and behavior
• Design modeling maps the analysis model into data/class, architectural, interface, and component
design
66
Product Engineering Hierarchy
Requirements Engineering
Problems with requirements practices
Requirements engineering tasks
Inception
Elicitation
Elaboration
Negotiation
Specification
Validation
Requirements management
Many software developers argue that
Building software is so compelling that we want to jump right in (before having a clear
understanding of what is needed)
Things will become clear as we build the software
Project stakeholders will be able to better understand what they need only after
examining early iterations of the software
Things change so rapidly that requirements engineering is a waste of time
The bottom line is producing a working program and that all else is secondary
All of these arguments contain some truth, especially for small projects that take less than one
month to complete
However, as software grows in size and complexity, these arguments begin to break down and
can lead to a failed software project
67
A Solution: Requirements Engineering
• Begins during the communication activity and continues into the modeling activity
• Builds a bridge from the system requirements into software design and construction
• Allows the requirements engineer to examine
the context of the software work to be performed
the specific needs that design and construction must address
the priorities that guide the order in which work is to be completed
the information, function, and behavior that will have a profound impact on the resultant
design
Inception Task
• During inception, the requirements engineer asks a set of questions to establish…
A basic understanding of the problem
The people who want a solution
The nature of the solution that is desired
The effectiveness of preliminary communication and collaboration between the customer
and the developer
68
• Through these questions, the requirements engineer needs to…
Identify the stakeholders
Recognize multiple viewpoints
Work toward collaboration
Break the ice and initiate the communication
Elicitation Task
• Eliciting requirements is difficult because of
Problems of scope in identifying the boundaries of the system or specifying too much
technical detail rather than overall system objectives
Problems of understanding what is wanted, what the problem domain is, and what the
computing environment can handle (Information that is believed to be "obvious" is often
omitted)
Problems of volatility because the requirements change over time
• Elicitation may be accomplished through two activities
Collaborative requirements gathering
Quality function deployment
• Meetings are conducted and attended by both software engineers, customers, and other interested
stakeholders
• Rules for preparation and participation are established
• An agenda is suggested that is formal enough to cover all important points but informal enough to
encourage the free flow of ideas
• A "facilitator" (customer, developer, or outsider) controls the meeting
69
• A "definition mechanism" is used such as work sheets, flip charts, wall stickers, electronic
bulletin board, chat room, or some other virtual forum
• The goal is to identify the problem, propose elements of the solution, negotiate different
approaches, and specify a preliminary set of solution requirements
• This is a technique that translates the needs of the customer into technical requirements for
software
• It emphasizes an understanding of what is valuable to the customer and then deploys these values
throughout the engineering process through functions, information, and tasks
• It identifies three types of requirements
Normal requirements: These requirements are the objectives and goals stated for a
product or system during meetings with the customer
Expected requirements: These requirements are implicit to the product or system and
may be so fundamental that the customer does not explicitly state them
Exciting requirements: These requirements are for features that go beyond the customer's
expectations and prove to be very satisfying when present
Elaboration Task
• During elaboration, the software engineer takes the information obtained during inception and
elicitation and begins to expand and refine it
• Elaboration focuses on developing a refined technical model of software functions, features, and
constraints
• It is an analysis modeling task
Use cases are developed
Domain classes are identified along with their attributes and relationships
State machine diagrams are used to capture the life on an object
• The end result is an analysis model that defines the functional, informational, and behavioral
domains of the problem
70
• Step Two – Develop use cases, where each one answers a set of questions
• Behavioral elements
Use state diagrams to represent the state of the system, the events that cause the system to
change state, and the actions that are taken as a result of a particular event; can also be
applied to each class in the system
• Flow-oriented elements
Use data flow diagrams to show the input data that comes into a system, what functions
are applied to that data to do transformations, and what resulting output data are produced
Negotiation Task
• During negotiation, the software engineer reconciles the conflicts between what the customer
wants and what can be achieved given limited business resources
• Requirements are ranked (i.e., prioritized) by the customers, users, and other stakeholders
• Risks associated with each requirement are identified and analyzed
• Rough guesses of development effort are made and used to assess the impact of each requirement
on project cost and delivery time
• Using an iterative approach, requirements are eliminated, combined and/or modified so that each
party achieves some measure of satisfaction
71
Specification Task
• A specification is the final work product produced by the requirements engineer
• It is normally in the form of a software requirements specification
• It serves as the foundation for subsequent software engineering activities
• It describes the function and performance of a computer-based system and the constraints that
will govern its development
• It formalizes the informational, functional, and behavioral requirements of the proposed software
in both a graphical and textual format
Validation Task
• During validation, the work products produced as a result of requirements engineering are
assessed for quality
• The specification is examined to ensure that
all software requirements have been stated unambiguously
inconsistencies, omissions, and errors have been detected and corrected
the work products conform to the standards established for the process, the project, and
the product
• The formal technical review serves as the primary requirements validation mechanism
Members include software engineers, customers, users, and other stakeholders
• Is each requirement consistent with the overall objective for the system/product?
• Have all requirements been specified at the proper level of abstraction? That is, do some
requirements provide a level of technical detail that is inappropriate at this stage?
• Is the requirement really necessary or does it represent an add-on feature that may not be essential
to the objective of the system?
• Is each requirement bounded and unambiguous?
• Does each requirement have attribution? That is, is a source (generally, a specific individual)
noted for each requirement?
• Do any requirements conflict with other requirements?
• Is each requirement achievable in the technical environment that will house the system or
product?
• Is each requirement testable, once implemented?
72
• Approaches: Demonstration, actual test, analysis, or inspection
• Does the requirements model properly reflect the information, function, and behavior of the
system to be built?
• Has the requirements model been “partitioned” in a way that exposes progressively more detailed
information about the system?
Analysis Modeling
Requirements analysis
Flow-oriented modeling
Scenario-based modeling
Class-based modeling
Behavioral modeling
A Set of Models
• Flow-oriented modeling – provides an indication of how data objects are transformed by a set of
processing functions
• Scenario-based modeling – represents the system from the user's point of view
• Class-based modeling – defines objects, attributes, and relationships
• Behavioral modeling – depicts the states of the classes and the impact of events on these states
Requirements Analysis
Purpose
• Specifies the software's operational characteristics
• Indicates the software's interfaces with other system elements
• Establishes constraints that the software must meet
• Provides the software designer with a representation of information, function, and behavior
73
– This is later translated into architectural, interface, class/data and component-level
designs
Provides the developer and customer with the means to assess quality once the software is built
Overall Objectives
• Three primary objectives
To describe what the customer requires
To establish a basis for the creation of a software design
To define a set of requirements that can be validated once the software is built
• All elements of an analysis model are directly traceable to parts of the design model, and some
parts overlap
Domain Analysis
• Definition
The identification, analysis, and specification of common, reusable capabilities within a
specific application domain
Do this in terms of common objects, classes, subassemblies, and frameworks
• Sources of domain knowledge
Technical literature
Existing applications
Customer surveys and expert advice
Current/future requirements
• Outcome of domain analysis
Class taxonomies
Reuse standards
Functional and behavioral models
74
Domain languages
Flow-oriented Modeling
Data Modeling
• Identify the following items
Data objects (Entities)
Data attributes
Relationships
Cardinality (number of occurrences)
75
Data Flow and Control Flow
Scenario-based Modeling
76
• Format of the text part of a use case
Activity Diagrams
• Supplements the use case by providing a graphical representation of the flow of interaction within
a specific scenario
• Uses flowchart-like symbols
– Rounded rectangle - represent a specific system function/action
77
– Arrow - represents the flow of control from one function/action to another
– Diamond - represents a branching decision
– Solid bar – represents the fork and join of parallel activities
Class-based Modeling
78
• General classifications for a potential class
External entity (e.g., another system, a device, a person)
Thing (e.g., report, screen display)
Occurrence or event (e.g., movement, completion)
Role (e.g., manager, engineer, salesperson)
Organizational unit (e.g., division, group, team)
Place (e.g., manufacturing floor, loading dock)
Structure (e.g., sensor, vehicle, computer)
• Six class selection characteristics
Retained information
• Information must be remembered about the system over time
Needed services
• Set of operations that can change the attributes of a class
Multiple attributes
• Whereas, a single attribute may denote an atomic variable rather than a class
Common attributes
• A set of attributes apply to all instances of a class
Common operations
• A set of operations apply to all instances of a class
Essential requirements
• Entities that produce or consume information
79
• Using a grammatical parse again, circle the verbs; then select the verbs that relate to the problem
domain classes that were previously identified
• Association
Represented by a solid line between two classes directed from the source class to the
target class
Used for representing (i.e., pointing to) object types for attributes
May also be a part-of relationship (i.e., aggregation), which is represented by a diamond-
arrow
• Generalization
Portrays inheritance between a super class and a subclass
Is represented by a line with a triangle at the target end
• Dependency
A dependency exists between two elements if changes to the definition of one element
(i.e., the source or supplier) may cause changes to the other element (i.e., the client)
Examples
• One class calls a method of another class
• One class utilizes another class as a parameter of a method
80
Example Class Diagram
Behavioral Modeling
81
Example State Diagram
Design Engineering
Introduction
Design quality
Design concepts
The design model
Introduction
Purpose of Design
• Design is where customer requirements, business needs, and technical considerations all come
together in the formulation of a product or system
• The design model provides detail about the software data structures, architecture, interfaces, and
components
• The design model can be assessed for quality and be improved before code is generated and tests
are conducted
Does the design contain errors, inconsistencies, or omissions?
Are there better design alternatives?
Can the design be implemented within the constraints, schedule, and cost that have been
established?
• A designer must practice diversification and convergence
The designer selects from design components, component solutions, and knowledge
available through catalogs, textbooks, and experience
The designer then chooses the elements from this collection that meet the requirements
defined by requirements engineering and analysis modeling
Convergence occurs as alternatives are considered and rejected until one particular
configuration of components is chosen
• Software design is an iterative process through which requirements are translated into a blueprint
for constructing the software
82
Design begins at a high level of abstraction that can be directly traced back to the data,
functional, and behavioral requirements
As design iteration occurs, subsequent refinement leads to design representations at much
lower levels of abstraction
83
d) Evaluate and select design patterns for a design class or subsystem
5) Design any interface required with external systems or devices
6) Design the user interface
7) Conduct component-level design
a) Specify all algorithms at a relatively low level of abstraction
b) Refine the interface of each component
c) Define component-level data structures
d) Review each component and correct all errors uncovered
8) Develop a deployment model
a) Show a physical layout of the system, revealing which components will be located where
in the physical computing environment
Design Quality
Quality's Role
• The importance of design is quality
• Design is the place where quality is fostered
Provides representations of software that can be assessed for quality
Accurately translates a customer's requirements into a finished software product or
system
Serves as the foundation for all software engineering activities that follow
• Without design, we risk building an unstable system that
Will fail when small changes are made
May be difficult to test
Cannot be assessed for quality later in the software process when time is short and most
of the budget has been spent
• The quality of the design is assessed through a series of formal technical reviews or design
walkthroughs
84
7) A design should be derived using a repeatable method that is driven by information obtained
during software requirements analysis
8) A design should be represented using a notation that effectively communicates its meaning
Design Concepts
• Abstraction
Procedural abstraction – a sequence of instructions that have a specific and limited
function
Data abstraction – a named collection of data that describes a data object
• Architecture
The overall structure of the software and the ways in which the structure provides
conceptual integrity for a system
Consists of components, connectors, and the relationship between them
• Patterns
A design structure that solves a particular design problem within a specific context
It provides a description that enables a designer to determine whether the pattern is
applicable, whether the pattern can be reused, and whether the pattern can serve as a
guide for developing similar patterns
• Modularity
Separately named and addressable components (i.e., modules) that are integrated to
satisfy requirements (divide and conquer principle)
Makes software intellectually manageable so as to grasp the control paths, span of
reference, number of variables, and overall complexity
• Information hiding
The designing of modules so that the algorithms and local data contained within them are
inaccessible to other modules
This enforces access constraints to both procedural (i.e., implementation) detail and local
data structures
• Functional independence
Modules that have a "single-minded" function and an aversion to excessive interaction
with other modules
High cohesion – a module performs only a single task
Low coupling – a module has the lowest amount of connection needed with other
modules
• Stepwise refinement
Development of a program by successively refining levels of procedure detail
Complements abstraction, which enables a designer to specify procedure and data and yet
suppress low-level details
• Refactoring
A reorganization technique that simplifies the design (or internal code structure) of a
component without changing its function or external behavior
Removes redundancy, unused design elements, inefficient or unnecessary algorithms,
poorly constructed or inappropriate data structures, or any other design failures
85
• Design classes
Refines the analysis classes by providing design detail that will enable the classes to be
implemented
Creates a new set of design classes that implement a software infrastructure to support the
business solution
• User interface classes – define all abstractions necessary for human-computer interaction
(usually via metaphors of real-world objects)
• Business domain classes – refined from analysis classes; identify attributes and services
(methods) that are required to implement some element of the business domain
• Process classes – implement business abstractions required to fully manage the business domain
classes
• Persistent classes – represent data stores (e.g., a database) that will persist beyond the execution
of the software
• System classes – implement software management and control functions that enable the system
to operate and communicate within its computing environment and the outside world
86
Dimensions of the Design Model
Introduction
• The design model can be viewed in two different dimensions
(Horizontally) The process dimension indicates the evolution of the parts of the design
model as each design task is executed
(Vertically) The abstraction dimension represents the level of detail as each element of
the analysis model is transformed into the design model and then iteratively refined
• Elements of the design model use many of the same UML diagrams used in the analysis model
The diagrams are refined and elaborated as part of the design
More implementation-specific detail is provided
Emphasis is placed on
• Architectural structure and style
• Interfaces between components and the outside world
• Components that reside within the architecture
• Design model elements are not always developed in a sequential fashion
Preliminary architectural design sets the stage
It is followed by interface design and component-level design, which often occur in
parallel
• The design model has the following layered elements
Data/class design
Architectural design
Interface design
Component-level design
• A fifth element that follows all of
the others is deployment-level design
87
Design Elements
• Data/class design
Creates a model of data and objects that is represented at a high level of abstraction
• Architectural design
Depicts the overall layout of the software
• Interface design
Tells how information flows into and out of the system and how it is communicated
among the components defined as part of the architecture
Includes the user interface, external interfaces, and internal interfaces
• Component-level design elements
Describes the internal detail of each software component by way of data structure
definitions, algorithms, and interface specifications
• Deployment-level design elements
Indicates how software functionality and subsystems will be allocated within the
physical computing environment that will support the software
Architectural Design
Introduction
Data design
Software architectural styles
Architectural design process
Assessing alternative architectural designs
Definitions
• The software architecture of a program or computing system is the structure or structures of the
system which comprise
The software components
The externally visible properties of those components
The relationships among the components
88
• Software architectural design represents the structure of the data and program components that
are required to build a computer-based system
• An architectural design model is transferable
It can be applied to the design of other systems
It represents a set of abstractions that enable software engineers to describe architecture
in predictable ways
• Basic Steps
Creation of the data design
Derivation of one or more representations of the architectural structure of the system
Analysis of alternative architectural styles to choose the one best suited to customer
requirements and quality attributes
Elaboration of the architecture based on the selected architectural style
• A database designer creates the data architecture for a system to represent the data components
• A system architect selects an appropriate architectural style derived during system engineering
and software requirements analysis
89
Example Software Architecture Diagram
Data Design
Purpose of Data Design
• Data design translates data objects defined as part of the analysis model into
– Data structures at the software component level
– A possible database architecture at the application level
• It focuses on the representation of data structures that are directly accessed by one or more
software components
• The challenge is to store and retrieve the data in such way that useful information can be
extracted from the data environment
• "Data quality is the difference between a data warehouse and a data garbage dump"
90
A topological layout of the components indicating their runtime interrelationships
A Taxonomy of Architectural Styles
91
Consists of no more and no less than the construction of its parts
Simplifies reuse and maintenance
Is easily made into a parallel or distributed execution in order to enhance system
performance
• Disadvantages
Implicitly encourages a batch mentality so interactive applications are difficult to create
in this style
Ordering of filters can be difficult to maintain so the filters cannot cooperatively interact
to solve a problem
Exhibits poor performance
• Filters typically force the least common denominator of data representation
(usually ASCII stream)
• Filter may need unlimited buffers if they cannot start producing output until they
receive all of the input
• Each filter operates as a separate process or procedure call, thus incurring
overhead in set-up and take-down time
• Use this style when it makes sense to view your system as one that produces a well-defined easily
identified output
The output should be a direct result of sequentially transforming a well-defined easily
identified input in a time-independent fashion
Call-and-Return Style
92
Typically has a single thread of control that travels through various components in the
hierarchy
• Remote procedure call style
Consists of main program and subroutine style of system that is decomposed into parts
that are resident on computers connected via a network
Strives to increase performance by distributing the computations and taking advantage of
multiple processors
Incurs a finite communication time between subroutine call and response
• Object-oriented or abstract data type system
Emphasizes the bundling of data and how to manipulate and access data
Keeps the internal data representation hidden and allows access to the object only
through provided operations
Permits inheritance and polymorphism
• Layered system
Assigns components to layers in order to control inter-component interaction
Only allows a layer to communicate with its immediate neighbor
Assigns core functionality such as hardware interfacing or system kernel operations to the
lowest layer
Builds each successive layer on its predecessor, hiding the lower layer and providing
services for the upper layer
Is compromised by layer bridging that skips one or more layers to improve runtime
performance
• Use this style when the order of computation is fixed, when interfaces are specific, and when
components can make no useful progress while awaiting the results of request to other
components
Data-Centered Style
93
• A client runs on an independent thread of control
• The shared data may be a passive repository or an active blackboard
A blackboard notifies subscriber clients when changes occur in data of interest
• At its heart is a centralized data store that communicates with a number of clients
• Clients are relatively independent of each other so they can be added, removed, or changed in
functionality
• The data store is independent of the clients
• Use this style when a central issue is the storage, representation, management, and retrieval of a
large amount of related persistent data
• Note that this style becomes client/server if the clients are modeled as independent processes
94
Independent Component Style
95
Heterogeneous Styles
• Systems are seldom built from a single architectural style
• Three kinds of heterogeneity
Locationally heterogeneous
• The drawing of the architecture reveals different styles in different areas (e.g., a
branch of a call-and-return system may have a shared repository)
Hierarchically heterogeneous
• A component of one style, when decomposed, is structured according to the rules
of a different style
Simultaneously heterogeneous
• Two or more architectural styles may both be appropriate descriptions for the
style used by a computer-based system
96
• Use an architectural context diagram (ACD) that shows
The identification and flow of all information into and out of a system
The specification of all interfaces
Any relevant support processing from/by other systems
• An ACD models the manner in which software interacts with entities external to its boundaries
• An ACD identifies systems that interoperate with the target system
Super-ordinate systems
• Use target system as part of some higher level processing scheme
Sub-ordinate systems
• Used by target system and provide necessary data or processing
Peer-level systems
• Interact on a peer-to-peer basis with target system to produce or consume data
Actors
• People or devices that interact with target system to produce or consume data
2. Define Archetypes
• Archetypes indicate the important abstractions within the problem domain (i.e., they model
information)
• An archetype is a class or pattern that represents a core abstraction that is critical to the design of
an architecture for the target system
• It is also an abstraction from a class of programs with a common structure and includes class-
specific design strategies and a collection of example program designs and implementations
• Only a relatively small set of archetypes is required in order to design even relatively complex
systems
• The target system architecture is composed of these archetypes
They represent stable elements of the architecture
They may be instantiated in different ways based on the behavior of the system
They can be derived from the analysis class model
The archetypes and their relationships can be illustrated in a UML class diagram
97
Example Archetypes in Software Architecture
98
Archetypes – their methods
• Based on the archetypes, the architectural designer refines the software architecture into
components to illustrate the overall structure and architectural style of the system
• These components are derived from various sources
The application domain provides application components, which are the domain classes
in the analysis model that represent entities in the real world
The infrastructure domain provides design components (i.e., design classes) that enable
application components but have no business connection
• Examples: memory management, communication, database, and task
management
99
The interfaces in the ACD imply one or more specialized components that process the
data that flow across the interface
A UML class diagram can represent the classes of the refined architecture and their relationships
4. Describe Instantiations of the System
100
Approach C: Assessing Architectural Complexity
• The overall complexity of a software architecture can be assessed by considering the
dependencies between components within the architecture
• These dependencies are driven by the information and control flow within a system
• Three types of dependencies
– Sharing dependency U V
• Represents a dependency relationship among consumers who use the same
source or producer
– Flow dependency U V
• Represents a dependency relationship between producers and consumers of
resources
– Constrained dependency U “XOR” V
• Represents constraints on the relative flow of control among a set of activities
such as mutual exclusion between two components
Component-Level Design
Introduction
The software component
Designing class-based components
Designing conventional components
Introduction
Background
• Component-level design occurs after the first iteration of the architectural design
• It strives to create a design model from the analysis and architectural models
The translation can open the door to subtle errors that are difficult to find and correct later
“Effective programmers should not waste their time debugging – they should not
introduce bugs to start with.” Edsgar Dijkstra
• A component-level design can be represented using some intermediate representation (e.g.
graphical, tabular, or text-based) that can be translated into source code
• The design of data structures, interfaces, and algorithms should conform to well-established
guidelines to help us avoid the introduction of errors
101
Object-oriented View
• A component is viewed as a set of one or more collaborating classes
• Each problem domain (i.e., analysis) class and infrastructure (i.e., design) class is elaborated to
identify all attributes and operations that apply to its implementation
This also involves defining the interfaces that enable classes to communicate and
collaborate
• This elaboration activity is applied to every component defined as part of the architectural design
• Once this is completed, the following steps are performed
Provide further elaboration of each attribute, operation, and interface
Specify the data structure appropriate for each attribute
Design the algorithmic detail required to implement the processing logic associated with
each operation
Design the mechanisms required to implement the interface to include the messaging that
occurs between objects
Conventional View
• A component is viewed as a functional element (i.e., a module) of a program that incorporates
The processing logic
The internal data structures that are required to implement the processing logic
An interface that enables the component to be invoked and data to be passed to it
• A component serves one of the following roles
A control component that coordinates the invocation of all other problem domain
components
A problem domain component that implements a complete or partial function that is
required by the customer
An infrastructure component that is responsible for functions that support the processing
required in the problem domain
• Conventional software components are derived from the data flow diagrams (DFDs) in the
analysis model
Each transform bubble (i.e., module) represented at the lowest levels of the DFD is
mapped into a module hierarchy
Control components reside near the top
Problem domain components and infrastructure components migrate toward the bottom
Functional independence is strived for between the transforms
• Once this is completed, the following steps are performed for each transform
Define the interface for the transform (the order, number and types of the parameters)
Define the data structures used internally by the transform
Design the algorithm used by the transform (using a stepwise refinement approach)
Process-related View
• Emphasis is placed on building systems from existing components maintained in a library rather
than creating each component from scratch
• As the software architecture is formulated, components are selected from the library and used to
populate the architecture
• Because the components in the library have been created with reuse in mind, each contains the
following:
A complete description of their interface
The functions they perform
The communication and collaboration they require
102
Designing Class-Based Components
• Open-closed principle
A module or component should be open for extension but closed for modification
The designer should specify the component in a way that allows it to be extended without
the need to make internal code or design modifications to the existing parts of the
component
• Liskov substitution principle
Subclasses should be substitutable for their base classes
A component that uses a base class should continue to function properly if a subclass of
the base class is passed to the component instead
• Dependency inversion principle
Depend on abstractions (i.e., interfaces); do not depend on concretions
The more a component depends on other concrete components (rather than on the
interfaces) the more difficult it will be to extend
• Interface segregation principle
Many client-specific interfaces are better than one general purpose interface
For a server class, specialized interfaces should be created to serve major categories of
clients
Only those operations that are relevant to a particular category of clients should be
specified in the interface
• Components
Establish naming conventions for components that are specified as part of the
architectural model and then refined and elaborated as part of the component-level model
Obtain architectural component names from the problem domain and ensure that they
have meaning to all stakeholders who view the architectural model (e.g., Calculator)
103
Use infrastructure component names that reflect their implementation-specific meaning
(e.g., Stack)
• Dependencies and inheritance in UML
Model any dependencies from left to right and inheritance from top (base class) to bottom
(derived classes)
Consider modeling any component dependencies as interfaces rather than representing
them as a direct component-to-component dependency
Cohesion
• Cohesion is the “single-mindedness’ of a component
• It implies that a component or class encapsulates only attributes and operations that are closely
related to one another and to the class or component itself
• The objective is to keep cohesion as high as possible
• The kinds of cohesion can be ranked in order from highest (best) to lowest (worst)
Functional
• A module performs one and only one computation and then returns a result
Layer
• A higher layer component accesses the services of a lower layer component
Communicational
• All operations that access the same data are defined within one class
Sequential
• Components or operations are grouped in a manner that allows the first to
provide input to the next and so on in order to implement a sequence of
operations
Procedural
• Components or operations are grouped in a manner that allows one to be invoked
immediately after the preceding one was invoked, even when no data passed
between them
Temporal
• Operations are grouped to perform a specific behavior or establish a certain state
such as program start-up or when an error is detected
Utility
• Components, classes, or operations are grouped within the same category
because of similar general functions but are otherwise unrelated to each other
Coupling
• As the amount of communication and collaboration increases between operations and classes, the
complexity of the computer-based system also increases
• As complexity rises, the difficulty of implementing, testing, and maintaining software also
increases
• Coupling is a qualitative measure of the degree to which operations and classes are connected to
one another
• The objective is to keep coupling as low as possible
• The kinds of coupling can be ranked in order from lowest (best) to highest (worst)
• Data coupling
• Operation A() passes one or more atomic data operands to operation B(); the less
the number of operands, the lower the level of coupling
• Stamp coupling
• A whole data structure or class instantiation is passed as a parameter to an
operation
• Control coupling
104
• Operation A() invokes operation B() and passes a control flag to B that directs
logical flow within B()
• Consequently, a change in B() can require a change to be made to the meaning of
the control flag passed by A(), otherwise an error may result
• Common coupling
• A number of components all make use of a global variable, which can lead to
uncontrolled error propagation and unforeseen side effects
• Content coupling
• One component secretly modifies data that is stored internally in another
component
105
• Experienced designers consider all (or most) of the alternative design solutions before
settling on the final design model
• The final decision can be made by using established design principles and guidelines
Designing Conventional Components
Introduction
106
Rules
Conditions 1 2 3 4
Condition A T T F
Condition B F T
Condition C T T
Actions
Action X
Action Y
Action Z
Introduction
• A strategy for software testing integrates the design of software test cases into a well-planned
series of steps that result in successful development of the software
• The strategy provides a road map that describes the steps to be taken, when, and how much effort,
time, and resources will be required
• The strategy incorporates test planning, test case design, test execution, and test result collection
and evaluation
• The strategy provides guidance for the practitioner and a set of milestones for the manager
• Because of time pressures, progress must be measurable and problems must surface as early as
possible
• To perform effective testing, a software team should conduct effective formal technical reviews
107
• Testing begins at the component level and work outward toward the integration of the entire
computer-based system
• Different testing techniques are appropriate at different points in time
• Testing is conducted by the developer of the software and (for large projects) by an independent
test group
• Testing and debugging are different activities, but debugging must be accommodated in any
testing strategy
108
Levels of Testing for Conventional Software
• Unit testing
Concentrates on each component/function of the software as implemented in the source
code
• Integration testing
Focuses on the design and construction of the software architecture
• Validation testing
Requirements are validated against the constructed software
• System testing
The software and other system elements are tested as a whole
• Unit testing
Exercises specific paths in a component's control structure to ensure complete coverage
and maximum error detection
Components are then assembled and integrated
• Integration testing
Focuses on inputs and outputs, and how well the components fit together and work
together
• Validation testing
Provides final assurance that the software meets all functional, behavioral, and
performance requirements
• System testing
Verifies that all system elements (software, hardware, people, databases) mesh properly
and that overall system function and performance is achieved
• Must broaden testing to include detections of errors in analysis and design models
• Unit testing loses some of its meaning and integration testing changes significantly
• Use the same philosophy but different approach as in conventional software testing
• Test "in the small" and then work out to testing "in the large"
Testing in the small involves class attributes and operations; the main focus is on
communication and collaboration within the class
Testing in the large involves a series of regression tests to uncover errors due to
communication and collaboration among classes
• Finally, the system as a whole is tested to detect errors in fulfilling requirements
109
Ensuring a Successful Software Test Strategy
Unit Testing
• Module interface
Ensure that information flows properly into and out of the module
• Local data structures
Ensure that data stored temporarily maintains its integrity during all steps in an algorithm
execution
• Boundary conditions
Ensure that the module operates properly at boundary values established to limit or
restrict processing
• Independent paths (basis paths)
Paths are exercised to ensure that all statements in a module have been executed at least
once
• Error handling paths
Ensure that the algorithms respond correctly to specific error conditions
110
Other Errors to Uncover
• Driver
A simple main program that accepts test case data, passes such data to the component
being tested, and prints the returned results
• Stubs
Serve to replace modules that are subordinate to (called by) the component to be tested
It uses the module’s exact interface, may do minimal data manipulation, provides
verification of entry, and returns control to the module undergoing testing
• Drivers and stubs both represent overhead
Both must be written but don’t constitute part of the installed software product
Integration Testing
111
• Once a set of errors are corrected, more errors occur, and testing appears to enter an endless loop
• Three kinds
Top-down integration
Bottom-up integration
Sandwich integration
• The program is constructed and tested in small increments
• Errors are easier to isolate and correct
• Interfaces are more likely to be tested completely
• A systematic test approach is applied
Top-down Integration
• Modules are integrated by moving downward through the control hierarchy, beginning with the
main module
• Subordinate modules are incorporated in either a depth-first or breadth-first fashion
DF: All modules on a major control path are integrated
BF: All modules directly subordinate at each level are integrated
• Advantages
This approach verifies major control or decision points early in the test process
• Disadvantages
Stubs need to be created to substitute for modules that have not been built or tested yet;
this code is later discarded
Because stubs are used to replace lower level modules, no significant data flow can occur
until much later in the integration/testing process
Bottom-up Integration
• Integration and testing starts with the most atomic modules in the control hierarchy
• Advantages
This approach verifies low-level data processing early in the testing process
Need for stubs is eliminated
• Disadvantages
Driver modules need to be built to test the lower-level modules; this code is later
discarded or expanded into a full-featured version
Drivers inherently do not contain the complete algorithms that will eventually use the
services of the lower-level modules; consequently, testing may be incomplete or more
testing may be needed later when the upper level modules are available
Sandwich Integration
112
When integration for a certain functional group is complete, integration and testing
moves onto the next group
• Reaps the advantages of both types of integration while minimizing the need for drivers and stubs
• Requires a disciplined approach so that integration doesn’t tend towards the “big bang” scenario
Regression Testing
• Each new addition or change to baselined software may cause problems with functions that
previously worked flawlessly
• Regression testing re-executes a small subset of tests that have already been conducted
Ensures that changes have not propagated unintended side effects
Helps to ensure that changes do not introduce unintended behavior or additional errors
May be done manually or through the use of automated capture/playback tools
• Regression test suite contains three different classes of test cases
A representative sample of tests that will exercise all software functions
Additional tests that focus on software functions that are likely to be affected by the
change
Tests that focus on the actual software components that have been changed
Smoke Testing
• Taken from the world of hardware
Power is applied and a technician checks for sparks, smoke, or other dramatic signs of
fundamental failure
• Designed as a pacing mechanism for time-critical projects
Allows the software team to assess its project on a frequent basis
• Includes the following activities
The software is compiled and linked into a build
A series of breadth tests is designed to expose errors that will keep the build from
properly performing its function
• The goal is to uncover “show stopper” errors that have the highest likelihood of
throwing the software project behind schedule
The build is integrated with other builds and the entire product is smoke tested daily
• Daily testing gives managers and practitioners a realistic assessment of the
progress of the integration testing
After a smoke test is completed, detailed test scripts are executed
113
Test Strategies for Object-Oriented Software
• With object-oriented software, you can no longer test a single operation in isolation (conventional
thinking)
• Traditional top-down or bottom-up integration testing has little meaning
• Class testing for object-oriented software is the equivalent of unit testing for conventional
software
Focuses on operations encapsulated by the class and the state behavior of the class
• Drivers can be used
To test operations at the lowest level and for testing whole groups of classes
To replace the user interface so that tests of system functionality can be conducted prior
to implementation of the actual interface
• Stubs can be used
In situations in which collaboration between classes is required but one or more of the
collaborating classes has not yet been fully implemented
Validation Testing
Background
A configuration review or audit ensures that all elements of the software configuration have been
properly developed, cataloged, and have the necessary detail for entering the support phase of the
software life cycle
114
Alpha and Beta Testing
• Alpha testing
Conducted at the developer’s site by end users
Software is used in a natural setting with developers watching intently
Testing is conducted in a controlled environment
• Beta testing
Conducted at end-user sites
Developer is generally not present
It serves as a live application of the software in an environment that cannot be controlled
by the developer
The end-user records all problems that are encountered and reports these to the
developers at regular intervals
After beta testing is complete, software engineers make software modifications and prepare for
release of the software product to the entire customer base
System Testing
Different Types
• Recovery testing
Tests for recovery from system faults
Forces the software to fail in a variety of ways and verifies that recovery is properly
performed
Tests reinitialization, checkpointing mechanisms, data recovery, and restart for
correctness
• Security testing
Verifies that protection mechanisms built into a system will, in fact, protect it from
improper access
• Stress testing
Executes a system in a manner that demands resources in abnormal quantity, frequency,
or volume
• Performance testing
Tests the run-time performance of software within the context of an integrated system
Often coupled with stress testing and usually requires both hardware and software
instrumentation
Can uncover situations that lead to degradation and possible system failure
Debugging Process
• Debugging occurs as a consequence of successful testing
• It is still very much an art rather than a science
• Good debugging ability may be an innate human trait
• Large variances in debugging ability exist
• The debugging process begins with the execution of a test case
• Results are assessed and the difference between expected and actual performance is encountered
• This difference is a symptom of an underlying cause that lies hidden
• The debugging process attempts to match symptom with cause, thereby leading to error
correction
115
Why is Debugging so Difficult?
Debugging Strategies
• binary partitioning
Induction (specific to general): Prove that a specific starting value is true; then prove the
general case is true
Deduction (general to specific): Show that a specific conclusion follows from a set of
general premises
• Data related to the error occurrence are organized to isolate potential causes
• A cause hypothesis is devised, and the aforementioned data are used to prove or disprove the
hypothesis
116
• Alternatively, a list of all possible causes is developed, and tests are conducted to eliminate each
cause
• If initial tests indicate that a particular cause hypothesis shows promise, data are refined in an
attempt to isolate the bug
• Operable
The better it works (i.e., better quality), the easier it is to test
• Observable
Incorrect output is easily identified; internal errors are automatically detected
• Controllable
The states and variables of the software can be controlled directly by the tester
• Decomposable
The software is built from independent modules that can be tested independently
• Simple
The program should exhibit functional, structural, and code simplicity
• Stable
Changes to the software during testing are infrequent and do not invalidate existing tests
• Understandable
The architectural design is well understood; documentation is available and organized
117
Test Characteristics
• A good test has a high probability of finding an error
The tester must understand the software and how it might fail
• A good test is not redundant
Testing time is limited; one test should not serve the same purpose as another test
• A good test should be “best of breed”
Tests that have the highest likelihood of uncovering a whole class of errors should be
used
• A good test should be neither too simple nor too complex
Each test should be executed separately; combining a series of tests could cause side
effects and mask certain errors
White-box Testing
• Uses the control structure part of component-level design to derive the test cases
• These test cases
Guarantee that all independent paths within a module have been exercised at least once
Exercise all logical decisions on their true and false sides
Execute all loops at their boundaries and within their operational bounds
Exercise internal data structures to ensure their validity
• A circle in a graph represents a node, which stands for a sequence of one or more procedural
statements
• A node containing a simple conditional expression is referred to as a predicate node
Each compound condition in a conditional expression containing one or more Boolean
operators (e.g., and, or) is represented by a separate predicate node
A predicate node has two edges leading out from it (True and False)
• An edge, or a link, is a an arrow representing flow of control in a specific direction
118
An edge must start and terminate at a node
An edge does not intersect or cross over another edge
• Areas bounded by a set of edges and nodes are called regions
• When counting regions, include the area outside the graph as a region, too
Black-box Testing
• Complements white-box testing by uncovering different classes of errors
• Focuses on the functional requirements and the information domain of the software
• Used during the later stages of testing after white box testing has been performed
• The tester identifies a set of input conditions that will fully exercise all functional requirements
for a program
• The test cases satisfy the following:
Reduce, by a count greater than one, the number of additional test cases that must be
designed to achieve reasonable testing
Tell us something about the presence or absence of classes of errors, rather than an error
associated only with the specific task at hand
119
Questions answered by Black-box Testing
Equivalence Partitioning
• A black-box testing method that divides the input domain of a program into classes of data from
which test cases are derived
• An ideal test case single-handedly uncovers a complete class of errors, thereby reducing the total
number of test cases that must be developed
• Test case design is based on an evaluation of equivalence classes for an input condition
• An equivalence class represents a set of valid or invalid states for input conditions
• From each equivalence class, test cases are selected so that the largest number of attributes of an
equivalence class are exercise at once
• If an input condition specifies a range, one valid and two invalid equivalence classes are defined
Input range: 1 – 10 Eq classes: {1..10}, {x < 1}, {x > 10}
• If an input condition requires a specific value, one valid and two invalid equivalence classes are
defined
Input value: 250 Eq classes: {250}, {x < 250}, {x > 250}
• If an input condition specifies a member of a set, one valid and one invalid equivalence class are
defined
Input set: {-2.5, 7.3, 8.4} Eq classes: {-2.5, 7.3, 8.4}, {any other x}
• If an input condition is a Boolean value, one valid and one invalid class are define
Input: {true condition} Eq classes: {true condition}, {false condition}
120
• If internal program data structures have prescribed boundaries (e.g., an array), design a test case
to exercise the data structure at its minimum and maximum boundaries
Introduction
Fault-based Testing
• The objective in fault-based testing is to design tests that have a high likelihood of uncovering
plausible faults
• Fault-based testing begins with the analysis model
The tester looks for plausible faults (i.e., aspects of the implementation of the system that
may result in defects)
To determine whether these faults exist, test cases are designed to exercise the design or
code
• If the analysis and design models can provide insight into what is likely to go wrong, then fault-
based testing can find a significant number of errors
• Integration testing looks for plausible faults in method calls or message connections (i.e.,
client/server exchange)
• Three types of faults are encountered in this context
121
Unexpected result
Wrong method or message used
Incorrect invocation
• The behavior of a method must be examined to determine the occurrence of plausible faults as
methods are invoked
• Testing should exercise the attributes of an object to determine whether proper values occur for
distinct types of object behavior
• The focus of integration testing is to determine whether errors exist in the calling code, not the
called code
122
Multiple Class Testing
• testing
• The following sequence of steps can be used to generate multiple class random test cases
1) For each client class, use the list of class methods to generate a series of random test
sequences; use these methods to send messages to server classes
2) For each message that is generated, determine the collaborator class and the
corresponding method in the server object
3) For each method in the server object (invoked by messages from the client object),
determine the messages that it transmits
4) For each of these messages, determine the next level of methods that are invoked and
incorporate these into the test sequence
123