Component-Based Software Engineering Component Reuse.
-
Upload
felicia-burns -
Category
Documents
-
view
273 -
download
14
Transcript of Component-Based Software Engineering Component Reuse.
Component-Based Component-Based Software Software
EngineeringEngineering
Component ReuseComponent Reuse
Reuse: Past and Present
reuse is both an old and a new idea. Programmers have reused ideas, abstractions, and processes since the earliest days of computing.
Today, complex, high quality computer-based systems must be built in very short time periods. This mitigates towards a more organized approach to reuse.
The reuse landscape
Designpatterns
Component-baseddevelopment
Componentframeworks
Service-orientedsystems
COTSintegration
Applicationproduct lines
Legacy systemwrapping
Programlibraries
Programgenerators
Aspect-orientedsoftware development
Configurable verticalapplications
the builder tool shows a calculator component that is built from 16 button components
a calculator built from components becomes, itself, a component
Reuse and Inheritance Objects are inherently reusable because they
package state and associated operations. they can be self-contained with no external dependencies.
Inheritance means that a class inherits attributes and operations from a super-class. Essentially, these are being reused.
Multiple inheritance allows several objects to act as a base class so attributes and operations from several sources are reused.
1010
Why inheritance? Extensibility
Reuse of older definitions More operations can be added to an
interface
The replacement principle:
If A extends B then any object of A can be safely used in a context where an object of B is expected.
A Class Lattice
Tape Disk Printer ScreenTextinput
Positionsensor
Dot-matrix Laser Film Ink-jet
Storage Output Input
Peripheral
Attributes andoperations reused byinheritance down the
hierarchy
Problems with Inheritance
As component classes are developed, the inheritance lattice becomes very complex with duplications across the lattice.
In many cases, it may be impossible to avoid inheriting unneeded functionality.
Software Reuse
In most engineering disciplines, systems are designed by composing existing components that have been used in other systems.
Software engineering has been more focused on original development but it is now recognised that to achieve better software, more quickly and at lower cost, we need to adopt a design process that is based on systematic reuse.
Aspects of Reuse Software development with reuse
Developing software given a base of reusable components.
Software development for reuse How to design generic software
components for reuse. Application system reuse
How to write application systems so that they may be readily ported from one platform to another.
Reusable Component Example
Linked list of elements where each element maintains a pointer to the next element in the list.
Commonly implemented in application systems but application-specific components are rarely generic as their operations reflect specific application needs.
Linked list operations are usually independent of the type of element in the list.
A guide for identifying reusable components
Is the component functionality required on future implementation?
Is the component reusable in many implementations with only minor changes?
Is the component hardware-dependent? Can a non-reusable component be
decomposed to yield reusable components?
Reusable Component Types Application system reuse
The whole of an application system may be reused on a different machine. Usually referred to as program portability.
It is common practice for developers of systems (e.g., Microsoft) to make their products available on several platforms.
Sub-system reuse Major sub-systems such as a pattern-matching
system may be reused. Practiced informally in that individual engineers
reuse previous work. Little systematic reuse but increasing reuse awareness.
Reuse Practice Modules or object reuse
The reusable component is a collection of functions or procedures.
Function reuse The reusable component is a single function
(method). Common in some application domains where
domain-specific libraries of reusable functions have been established. Reuse is the principal reason why languages such as FORTRAN are still used.
Reuse Problems Difficult to quantify costs and benefits
of development with reuse. Some software engineers prefer to
rewrite rather than reuse components.
Current techniques for component classification, cataloging and retrieval are immature. The cost of finding suitable components is high.
Reusability Enhancement Name generalization
Names in a component may be modified so that they are not a direct reflection of a specific application entity.
Operation generalization Operations may be added to provide extra
functionality and application specific operations may be removed.
Exception generalization Application specific exceptions are removed and
exception management added to increase the robustness of the component.
Reusable Component Example
Linked list of elements where each element maintains a pointer to the next element in the list.
Class Templates
Many C++ programs use common data structures like stacks, queues and lists.
A program may require a queue of customers and a queue of messages.
It seems to make more sense to implement a queue that can contain any arbitrary type.
How does one do that? The answer is to use type parameterization, more commonly referred to as templates.
Class Templates C++ templates allow one to
implement a generic Queue<T> template that has a type parameter T.
T can be replaced with actual types Once the changes are implemented in
the template Queue<T>, they are immediately reflected in the classes Queue<Customers>, Queue<Messages>, and Queue<Orders>.
C++ Class Templates
C++ provides two kinds of templates: class templates and function templates.
Use function templates to write generic functions that can be used with arbitrary types.
For example, one can write searching and sorting routines which can be used with any arbitrary type.
C++ Function Templates
#include <iostream.h> using namespace std ; template <class T> T max(T a, T b) { return a > b ? a : b ; }
C++ Linked List
template <class elem> class List{public:
List(); // Automatic constructor~List(); // Automatic destructorelem Head (error_indic &Err) ; int Length ( ) ;List <elem> Tail (error_indic &Err) ;friend List <elem> operator == (List <elem> L1, List <elem> L2) ;friend List <elem> Equivalent (List <elem> L1, List <elem> L2) ;void Append (elem E, error_indic &Err) ;
void Add (elem E, error_indic &Err) ; void Add_before (elem E, error_indic &Err) ; void Add_after (elem E, error_indic &Err) ; void Replace (elem E, error_indic &Err) ; void Clear (error_indic &Err ) ; void Prune (error_indic &Err ) ; void Prune_to (elem E, error_indic &Err ) ; void Prune_from (elem E, error_indic &Err ) ; void Remove (elem E, error_indic &Err ) ; void Remove_before (elem E, error_indic &Err ) ; void Remove_after (elem E, error_indic &Err ) ;
C++ Linked List
// I/O functionsvoid Print(error_indic &Err) ;
void Write_list(char* filename, error_indic &Err) ; void Read_list(char* filename, error_indic &Err) ;private:
typedef struct Linkedlist { elem val; Linkedlist* next; } Linkedlist;
Linkedlist* Listhead ; // (Internal) Pointer to start of list};
template <class elem> class Iterator { friend class List <elem> ;public: Iterator () ; ~Iterator () ; void Create (List <elem> L, error_indic &Err) ; void Go_next (error_indic &Err) ; elem Eval (error_indic &Err) ; boolean At_end () ;private: Linkedlist* iter ;} ;
Application System Portability
Portability is a special case of reuse where an entire application is reused on a different platform.
The portability of a program is a measure of the amount of work required to make that program work in a new environment.
Application Program Interfaces
Applicationprogram
Run-timesystem
Operatingsystem
Libraries
Memory and CPU
Operating System Dependencies
The program relies on the use of specific operating system calls such as facilities to support process management.
The program depends on a specific file system organization supported by the operating system.
Development for Portability
Isolate parts of the system which are dependent on the external program interfaces.
Define a portability interface to hide operating system characteristics.
To port the program, only the code behind the portability interface need be rewritten.
A Portability Interface
Portability interface
Application system
Operating systemand I/O calls
Da tareferences
Component Certification The National Security Agency (NSA) National Institute of Standards and Technology (NIST) used the trusted computer security evaluation criteria
(TCSEC), a.k.a. “Orange Book.” as the basis for the Common Criteria, which defines criteria for certifying security features of components
Component Level Design-I
Step 1. Identify all design classes that correspond to the problem domain.
Step 2. Identify all design classes that correspond to the infrastructure domain.
Step 3. Elaborate all design classes that are not acquired as reusable components.
Step 3a. Specify message details when classes or component collaborate.
Step 3b. Identify appropriate interfaces for each component.
Component-Level Design-II
Step 3c. Describe processing flow within each operation in detail.
Step 4. Describe persistent data sources (databases and files) and identify the classes required to manage them.
Step 5. Elaborate deployment diagrams to provide additional implementation detail.
Step 6. Factor the component-level design representation and always consider alternatives.
Synchronous interaction
Tomato soup please
Waiter Diner
What would you like?
And to follow?
Fillet steak
How would you like it cooked?
Rare please
With salad or french fries?
Salad please
ETC.
Hotel booking workflow
Hotels.GetRequirements
Customer
Hotels.CheckAvailability
Hotels.NoAvailability
Hotels.ReserveRooms
Hotels.ConfirmReservation
Retry
Cancel
Rooms OK
No rooms
Interface Design
The interface design is the appearance on the screen and the actual manipulation by the user
• Fonts, colors, logos, key board controls, menus, buttons
• Mouse control or keyboard control?
• Conventions (e.g., "back", "help")
Interface Design
♦ lack of consistency♦ too much memorization♦ no guidance / help♦ no context sensitivity♦ poor response♦ Arcane/unfriendly
Typical Design Errors
Place the User in Control
♦ Define interaction modes in a way that Define interaction modes in a way that does not force a user into unnecessary or does not force a user into unnecessary or undesired actions. undesired actions.
♦ Provide for flexible interaction. Provide for flexible interaction.
♦Streamline interaction as skill levels Streamline interaction as skill levels advance and allow the interaction to be advance and allow the interaction to be customized. customized.
♦ Hide technical internals from the casual Hide technical internals from the casual user. user.
♦ Design for direct interaction with objects Design for direct interaction with objects that appear on the screen. that appear on the screen.
Reduce the User’s Memory Load
♦ Reduce demand on short-term memory.
♦ Establish meaningful defaults.
♦ Define shortcuts that are intuitive.
♦ The visual layout of the interface should be based on a real world metaphor.
♦ Disclose information in a progressive fashion.
Make the Interface Consistent
♦ Allow the user to put the current task into a meaningful context.
♦ Maintain consistency across a family of applications.
♦ If past interactive models have created user expectations, do not make changes unless there is a compelling reason to do so.
Interface Analysis
Interface analysis means understanding the people (end-users) who will interact
with the system through the interface; the tasks that end-users must perform to
do their work, the content that is presented as part of
the interface the environment in which these tasks will
be conducted.
User Analysis Are users trained professionals, technician, clerical, or manufacturing
workers? What level of formal education does the average user have? Are the users capable of learning from written materials or have they
expressed a desire for classroom training? Are users expert typists or keyboard phobic? What is the age range of the user community? Will the users be represented predominately by one gender? How are users compensated for the work they perform? Do users work normal office hours or do they work until the job is
done? Is the software to be an integral part of the work users do or will it be
used only occasionally? What is the primary spoken language among users? What are the consequences if a user makes a mistake using the
system? Are users experts in the subject matter that is addressed by the
system? Do users want to know about the technology the sits behind the
interface?
Testing problems
Costs of testing About 30%-50%
Last phase in project Dijkstra: “Testing can only show the
presence of errors, not their absence”
(Vincenzi et al. 2003, Gao 1999)
Test strategies
Validation testing Component fulfills the requirements Successful when system correct Demonstrate that component meets
requirements Defect testing
Discover faults or defects Successful when system incorrect Use problematic inputs
Black box testing
Source code not used Behavior determined with inputs and
outputs Equivalence partitions
Equivalence partitions
Different classes with common characteristics e.g.
• Positive/negative numbers• Valid/invalid inputs
Identify test cases for each partition
Between 4 and 10Less than 4 More than 10
34 7
1110
White box/Structural testing
Source code/structure known Better input data
Execute each statement Path testing
Execute each independent path Combinations not tested
• When a loop -> infinite combinations• Therefore errors can still occur
Interface testing
Access component through interface Test if interface behaves as specified Errors
Interface misuse• e.g. wrong number of parameters
Interface misunderstanding Timing errors
• Real time applications
Release testing
Goal: meets requirements Functional Non-functional
Usually black-box testing Problems
Difficult to understand component behavior Difficult error isolation, debugging High cost on performance testing
• No information provided by vendor
Quiz 1
In the most general sense, a component is a modular building block for computer software True b. False
Software engineering need to create components from scratch in order to meet customer expectations fully True b. False
Quiz 2
Which is the following is not a technique used for component wrapping Black-box wrapping Clear-box wrapping Gray-box wrapping White-box wrapping
Quiz 3
Defines the services that must be available for the component to execute as specified Provides interface Requires interface Interface Definition Language Interface of a component