Maintenance
Unit 6. Build and Test the Solution
6.1 Implementation
6.2 Module Testing
6.3 Integration Testing
6.4 Product and Acceptance Testing
6.5 CASE Technology
Assessments
Exercise 7
Multiple-Choice Quiz 6
6.1 Implementation
6.1.1 Reuse
6.1.2 Choice of Programming Language
6.1.3 Good Programming Practices and Coding
Standards
6.1.1 Reuse
Module Reuse
Costs and Constraints in Reuse
What Can Be Reused and When?
Reuse and Maintenance
Module Reuse
The first issue one faces in implementation is
whether to code everything from scratch 只靠自己的双手
从头做起?
whether to reuse existing components.
Although components from all phases of the
software process can be reused
requirements,
specifications,
design,
documentation, and
testing suites,
module reuse is by far the most common type of
reuse.
Reuse
Reuse refers to taking the components of one product to
facilitate the development of a different product with a
different functionality.
Reuse can be accidental 机会重用
if developers realize that a previously developed component can be
reused
reuse can be deliberate. 计划重用
components are constructed with the idea of possible future reutilization
in mind.
Deliberate reuse is better, insofar as such components are likely to be
better documented, better tested, and designed in a uniform style that
makes for easier maintenance.
However, even reused components will have to be retested
during integration testing, because 重用组件要重新测试
!
the range of input they get in a new product might go beyond that of the
Code reuse
In the early days of system building, there was no
reuse: everything was constructed from scratch.
The first common source of code reuse was
subroutine or class libraries, of which there are now
many in the public domain for different languages.
many scientific computing subroutines have been developed
and refined for optimal performance, so in the case of each of
these subroutines there is no need to recode one.
Application Programming Interfaces (APIs) are usually
implemented as operating system calls, but they can be
viewed as subroutine libraries.
Code reuse is also a feature of the many varieties of toolkits
for building graphical user interfaces (GUIs).
Costs and Constraints in Reuse
In reality, only a relatively small percentage of any
software product serves a novel purpose or provides
novel functionality ( 全新的功能 )
approximately 15 %.
That means that, in theory, about 85% could be standardized
and reused.
In practice, on average, only 40 percent is reused.
Smaller modules are frequently more reusable
because they are likely 软件组 件的粒度 问题
to be documented better and
less application specific.
Why only 40% reuse rate
There are several good and some not so good reasons
that tend to limit the extent to reuse.
One common reason is ego( 自负了点 ): the fact that many
software professionals would prefer to rewrite a piece of code
from scratch rather than use someone else’s. 不愿用别人的
A related reason has to do with quality. Developers would reuse
code developed by others if they could be assured that it would
not introduce faults in the new product. 怕出问题 While this
concern is sometimes justified,
both reasons reflect the attitude that no piece of code
is as good as one’s own! 真的 是这 样吗?
practical problems associated with reuse
Retrieval 大海捞针
unless code is deliberately developed and organized for easy
reuse, it may be difficult to locate it in a database of hundreds
and thousands of software modules.
planning for reuse has a price
an increase of 60 percent or higher in development cost — plus
the cost of reusing the component and the cost of implementing
a reuse process.
there may be legal issues to consider. 避免官司 !
In contract software development, the software belongs to the
client, unless it is just licensed.
Internal software reuse is free from this constraint.
Object-oriented systems
OO systems seem to be particularly suited to
code reuse. 貌似 很适合 reuse
Objects are self-contained, which can make both
development and maintenance easier because it allows a
large product to be constructed as a collection of smaller
products.
Maintenance is generally easier and cheaper, and some
classes of objects can be reused.
但尺有所短,寸 有所长……
reuse in OO systems presents its own problems
specifically due to inheritance !
the fragile base class problem, occurs when a base class
changes.
All classes depending on the base class have to be recompiled at least,
and possibly changed.
indiscriminate use of inheritance: 滥用继承
because dependent classes not only inherit all the attributes of their
superclasses but also have their own attributes, they can get big very
quickly!
the use of polymorphism and dynamic binding. 多态与动态
绑定
Polymorphism and dynamic binding represent the ability to invoke the
same method with arguments of different kinds and have the run-time
system determine the appropriate method to use based on the type of
argument.
As powerful as it is, this mechanism makes maintenance and reuse of
code more difficult to understand and troubleshoot.
What Can Be Reused and When?
Reuse is commonly perceived
as being something you do with individual code modules,
as in the case of subroutine libraries,
but code is not the only thing that can be worth
reusing.
if one can browse the inheritance tree of an object-oriented
system, its design can become reusable as well. 继承树本身
就可以重用的!
two approaches to incorporating reuse
There are 2 ways to incorporating reuse into the
code design and implementation phases:
One can develop the control logic for a product from scratch
and reuse pieces of code that incorporate specific operations
of the product.
Alternatively, one can reuse an application framework that
already provides the desired control logic and
develop application specific operations.
the set of classes used for the design of a compiler.
One will need to code from scratch all classes specific to the language
and desired target machine.
Application framework reuse results in higher productivity
Application framework reuse results in higher
productivity than toolkit or library reuse because
more design is reused (recall that design typically has a
higher financial cost than implementation);
logic is harder to design and code than are the specific
operations; and because the control logic will have been
tested.
Code frameworks, those for performing basic
window manager operations are similar to
application frameworks in reusability. 所有 操作系
统平台 的 GUI 界面的窗口管 理都有类似 的!
Design patterns are another kind of design reuse.
A design pattern is a solution to a general design problem in
the form of a set of closely interacting classes that have to be
customized to create a specific design.
The idea of design pattern is drawn from the field of
building architecture.
A GUI generator is an example of a design pattern
a tool that assists the user in constructing a graphical user interface,.
provides a set of abstract widget classes that the developer can combine
to create a custom user interface.
A widget is a graphical object such as a window, a menu, a radio button,
bottom-up
sandwich
Integration testing of products with GUI, however,
poses particular problems.
In non-GUI testing, it is possible to use a rudimentary
CASE tool ( 一般 的 CASE 工具 ) to set up input test
cases and expected outcomes, allowing tests to be
rerun when new modules get integrated. ( 输入与 期
望输 出数 据放在 一个文 件中 与实际 输出 进行 比较
,得 到测 试结果 )
This will not work for products that incorporate a
GUI because user-input events ( mouse clicks )
cannot be stored in a file as other test data can.
The solution is to use a special CASE tool, a GUI testing
environment such as QAPartner or Xrunner.
this type of tool create a machine-readable version of a manual
GUI test case, called a script that can be run as a normal test
case.
6.4 Product and Acceptance Testing
Product Testing
Acceptance Testing
Module testing and integration testing are
verification activities. they check to see
the individual modules are correct
the modules communicate correctly with each other.
integration testing is completed …… the
product is delivered
test the whole product of other behavioral properties.
Who do this?
it is the responsibility of the SQA group in the developer’s
organization
Ensure to find and remove any residual product faults are
Product Testing
The goal of product testing is validation of the
product
checking that the software meets behavioral specifications
including, but not limited to, correctness.
For COTS software
the SQA team’s primary concern is that the product
be free of faults, since it will go to as many
customers as possible.
the financial and public image cost of selling faulty
COTS products can be prohibitive 经费及公众形
象方面 ,代价巨大
after internal product testing is satisfactorily
completed
the product is shipped to alpha and beta test -
sites (prospective buyers)
receive feedback on any remaining faults that the
SQA team may have overlooked.
For COTS software
Another important test to be performed both in-
house and at test sites concerns the utility of the
product,( 产品 效用 ) , the extent to which a
product meets customer needs
when it is correct
when it is used under the conditions permitted by its
specifications.
The concept of utility includes
whether the product does something useful,
whether it is easy to use, and
whether it is cost effective relative to competing products.
如金山 wps, 与微软 ms office
For contract software
most of the remaining testing before delivery will
take place in-house.
The SQA’s primary responsibility is to ensure
the product will pass the acceptance test.
Failure to do so 否则 ……
reflects badly on the management capabilities of the
developer organization 管理无能!
may create a major public relations problem.
So , The SQA group must perform a number of
tests.
What we should do?
The product as a whole must be subjected to
correctness testing
using black-box techniques
similar to the testing at the module level.
The reliability of the product must be tested. include
estimates of mean time between failures
the severity of the effects of a failure.
Severity results must be broken down to include
mean time to repair the product when a fault occurs
the time required to repair the consequences of that fault (the
corruption of client data as a result of the fault occurring).
What we should do?
The robustness of a product under a range of
operating conditions must be tested.
when it receives input that falls outside the range of
legal input given in the specifications. 非法输入 时
The product should not crash
it should minimally respond with an error message saying
that the input could not be processed
preferably giving the reason why the input could not work.
What we should do?
The product should be subjected to stress testing to
check its behavior 强度测 试
under very high user loads (many users logged in at once)
volume testing (very large data files, or a large number of
transactions).
The product should also be tested against any other
specified constraints, such as
performance (response times)
storage, and
security.
All documentation should be checked against
standards set out by the software project
management plan (SPMP).
What we should do?
Finally, the product should be checked for
compatibility with other software used by the client
(installation testing).
When the SQA group determines that the product
has passed all these tests,
the product is ready to be delivered to the client for
acceptance testing.
Acceptance Testing
Acceptance testing is driven by the client.
It can be performed
directly by the client,
by the developer’s SQA in the presence of a client representative
by an SQA group hired by client.
Acceptance testing may include all of the types of testing
that were performed by the developer during product
testing, but the 4 primary components are testing
correctness,
robustness,
performance, and
documentation.
Unlike testing at the developer’s organization,
acceptance testing is performed using the
customer's hardware and actual data.
If test data should be a reflection of actual data,
the specifications may be incorrect
the SQA may have misunderstood them.
If the product replaces an existing product 软件更
新
the specifications should say that the new product would be
run in parallel with the old one until the client is satisfied that
it works satisfactorily.
At that time, the old product can be retired.
6.5 CASE Technology
CASE Technology in General
Coding Tools
Version Management Tools
Build Tools
Integrated Environments
When to Use CASE Technology
CASE Technology in General
When discussing CASE tools (computer-assisted
software engineering tools), it is important to keep
in mind the following distinctions:
Programming-in-the-small:
coding at the level of the code of a single module
Programming-in-the-large:
software development at the module level,
including aspects such as architectural design and integration
Programming-in-the-many:
software production by a team
either at the module level or at the code level
CASE tool scan aid in all aspects of software development
CASE tools, workbenches, and environments can
aid in all aspects of software development.
are also helpful in keeping online a single consistent version
of documentation and
Aid in communication among developers.
store email exchanges over product development issues
provide a record of design decisions.
A particular CASE tool assists in only one aspect of
software production. Code editor
CASE tools are typically classified as front-end or
upperCASE, 不同阶 段起作用
if they assist with the requirements, specification, and design
phases.
Similarly, back-end or lowerCASE tools
assist with implementation, integration, and maintenance.
programs for constructing graphical representations of
software such as data flow diagrams
tools for constructing data dictionaries.
CASE workbenches and environments
In addition to CASE tools, there are also CASE
workbenches and environments.
Workbenches are collections of tools that support a
small number of related activities — like
editing, compiling, linking, testing, and debugging.
Debugging , IDE
is relevant throughout the entire software process,
or at least a large portion of it.
Coding Tools
Coding tools assist the programmer with many aspects of
programming.
Commonly available coding tools include:
Structure editors: tools for writing code that know about the programming
language in which the code is written and that can catch syntax errors;
Pretty printers: tools that produce nicely laid out programs;
Online interface checkers: tools that check that procedures, functions,
and/or methods exist and are being called with the right number and type of
arguments;
Operating system front ends: tools that facilitate compiling, linking, and
loading;
Informative error messages: tools capable of displaying run-time errors at a
level appropriate for the programming language (for example, "Line 24:
division by 0," instead of "Segmentation fault" for a FORTRAN program);
and
Source-level debuggers: run-time tools that produce trace output or can be
used to debug the code interactively by setting breakpoints.
structure editor
a structure editor
incorporates some or all of the other coding tools,
support for online documentation,
the resulting collection of tools constitutes a programming
workbench.
Version Management Tools
During development and maintenance of a software
product, several revisions of each module may arise
in response to requests
for fault removals
enhancements
These changes produce multiple versions of
modules, which can become a nightmare unless
properly managed. 程序员 的恶梦!
The CASE tools help manage software versions.
Version control should begin when the module has passed
SQA inspection.
Before that, there will be too many versions for each module.
Software-versioning tools
Software versioning tools help organizations
manage
multiple versions
Software-versioning tools help developers keep track of
different versions of the software product or of components of
the product, such as
following an incremental life-cycle model 增量开发
making revisions during maintenance. 维护时修改
variations. 模块的异构版
Matters are further complicated by the coexistence of module
variations.
different implementations of the same module for different hardware
platforms.
Software-versioning tools help developers keep track of
different versions of the software product or of components
of the product, such as
might arise when following an incremental life-cycle model or
when making revisions of a product during maintenance.
Although there will be only a single version of each
component (module) in a specific product version, multiple
versions of components will need to be accessible and
distinguished from each other as the new version of the
product is developed.
Matters are further complicated by the coexistence of
module variations.
different implementations of the same module for different hardware
platforms.
Software versioning tools help organizations manage multiple versions
and variations.
Revision and variations
Configuration-control tools are used to specify
which versions and which variations of each
component are required for a particular version of
the complete product — that is, its configuration.
不同的 配置,形成不 同的最终完 整产品
Baselines and access control systems prevent
programmers from working on the same module
simultaneously.
How the Baselines and access control systems do?
The maintenance manager creates a baseline
configuration for the product.
A programmer needing to work on a module
copies that configuration into his or her private workspace
freezes or locks the module that needs to be changed. 做标
记,锁定! Microsoft sourcesafe
No other programmer is allowed to work on a
frozen module.
the changes have been implemented and tested
the new version of the module is installed and
unfrozen
changing the baseline.
Build Tools
Build tools assist in selecting and assembling all the
correct versions of the code.
A build tool needs to be used in conjunction with a
configuration-control tool, ideally to be integrated
with it.
the UNIX make command, which uses a makefile to specify
all components of the system that must be
compiled
linked
in which order.
Integrated Environments
In the context of CASE, integrated environments
usually in reference to user interface integration —
an environment where tools
all have the same visual appearance and
provide access to similar functionality in similar ways.