Académique Documents
Professionnel Documents
Culture Documents
Outline
What is design How can a system be decomposed into modules What is a module s interface What are the main relationships among modules Prominent software design techniques and information hiding The UML collection of design notations Design of concurrent and distributed software Design patterns Architectural styles Component based software engineering
What is design?
Provides structure to any artifact Decomposes system into parts, assigns responsibilities, ensures that parts fit together to achieve a global goal Design refers to both an activity and the result of the activity
Software architecture
Shows gross structure and organization of the system to be defined Its description includes description of
main components of a system relationships among those components Basis for decomposition into its components constraints that must be respected by any design of the components
Product families
think of the current system under design as a member of a program family
Product families
In some cases, changes consists of building new versions. Set of these versions constitutes a family Newer version supersedes older one (removes erros, add new features) Reason for treating diff. versions of a s/w product as one family
They have much common, only partially diff. Share same architecture Common architecture should be designed
2
final product
Version 3
How to do better
Anticipate definition of all family members Identify what is common to all family members, delay decisions that differentiate among different members We will learn how to manage change in design
Module
A well-defined component of a software system A part of a system that provides a set of services to other modules
Services are computational elements that other modules may use
Questions
How to define the structure of a modular system? What are the desirable properties of that structure?
An example
module X uses Y, Z exports var A : integer; type B : array (1. .10) of real; procedure C ( D: in out B; E: in integer; F: in real); Here is an optional natural-language description of what A, B, and C actually are, along with possible constraints or properties that clients need to know; for example, we might specify that objects of type B sent to procedure C should be initialized by the client and should never contain all zeroes. implementation If needed, here are general comments about the rationale of the modularization, hints on the implementation, etc. is composed of R, T end X
Comments in TDN
May be used to specify the protocol to be followed by the clients so that exported services are correctly provided
e.g., a certain operation which does the initialization of the module should be called before any other operation e.g., an insert operation cannot be called if the table is full
Example (cont.)
module R uses Y exports var K : record . . . end; type B : array (1. .10) of real; procedure C (D: in out B; E: in integer; F: in real); implementation
. . .
end T
Benefits
Notation helps describe a design precisely Design can be assessed for consistency
having defined module X, modules R and T must be defined eventually
if not incompleteness
R, T replace X
either one or both must use Y, Z
Example: a compiler
module COMPILER exports procedure MINI (PROG: in file of char; CODE: out file of char); MINI is called to compile the program stored in PROG and produce the object code in file CODE implementation A conventional compiler implementation. ANALYZER performs both lexical and syntactic analysis and produces an abstract tree, as well as entries in the symbol table; CODE_GENERATOR generates code starting from the abstract tree and information stored in the symbol table. MAIN acts as a job coordinator. is composed of ANALYZER, SYMBOL_TABLE, ABSTRACT_TREE_HANDLER, CODE_GENERATOR, MAIN end COMPILER
module MAIN uses ANALYZER, CODE_GENERATOR exports procedure MINI (PROG: in file of char; CODE: out file of char); end MAIN module ANALYZER uses SYMBOL_TABLE, ABSTRACT_TREE_HANDLER exports procedure ANALYZE (SOURCE: in file of char); SOURCE is analyzed; an abstract tree is produced by using the services provided by the tree handler, and recognized entities, with their attributes, are stored in the symbol table. ... end ANALYZER
Other modules
Other modules
module CODE_GENERATOR uses SYMBOL_TABLE, ABSTRACT_TREE_HANDLER exports procedure CODE (OBJECT: out file of char); The abstract tree is traversed by using the operations exported by the ABSTRACT_TREE_HANDLER and accessing the information stored in the symbol table in order to generate code in the output file. end CODE_GENERATOR
M odu le R
M odu le T
C M odu le Z
X's decomposition
M o d u le Y
M o d u le X K M o d u le R M o d u le T
A M o d u le Z
Categories of modules
Functional modules
traditional form of modularization provide a procedural abstraction encapsulate an algorithm
e.g. sorting module, fast Fourier transform module,
ADTs
Correspond to Java and C++ classes Concept may also be implemented by Ada private types and Modula-2 opaque types May add notational details to specify if certain built-in operations are available by default on instance objects of the ADT
e.g., type A_TYPE: ? (:=, =) indicates that assignment and equality check are available
Instantiation
Possible syntax:
module INTEGER_STACK_2 is GENERIC_STACK_2 (INTEGER)
More on genericity
How to specify that besides a type also an operation must be provided as a parameter
generic module M (T) with OP(T) uses ... ... end M
Instantiation
module M_A_TYPE is M(A_TYPE) PROC(M_A_TYPE)
Software generation
e.g., compiler compilers (yacc, interface prototyping tools)
Stepwise refinement
A systematic, iterative program design technique that unfortunately may lead to software that is hard to evolve At each step, problem P decomposed into
sequence of subproblems: P1; P2; Pn a selection: if (cond) then P1 else P2 an iteration: while (cond) do_something
Decomposition tree
Stepwise refinement process may be depicted by a decomposition tree (DT)
root labeled by name of top problem subproblem nodes labeled as children of parent node corresponding to problem children from left to right represent sequential order of execution if and while nodes denoted by suitable decoration
organizing documentation as a top-down flow may be useful for reading purposes, even if the process followed was not topdown
oop
Generalization and specialization
Is a Has a
Object-oriented design
One kind of module, ADT, called class A class exports operations (procedures) to manipulate instance objects
often called methods
If a is a reference to an object
a.op (params);
An example
class E M P LO YE E expo rts func tion FIR S T _N A M E (): string_of_char; func tion LA S T _N A M E (): string_of_char; func tion A G E (): natural; func tion W H E R E (): S IT E ; func tion S A LA R Y : M O N E Y ; proce dure H IR E (FIR S T _N : string_of_char; LA S T _N : string_of_char; IN IT _S A LA R Y : M O N E Y ); Initializes a n ew E M P LO Y E E , assigning a new identifier. proce dure FIR E (); proce dure A S S IG N (S : S IT E ); A n em ployee cannot be assigned to a S ITE if already assigned to it (i.e., W H E R E m ust be diffe rent from S ). It is the clients responsibility to ensure this. The effect is to delete the em ployee from those in W H E R E , add the em ployee to those in S , generate a new id card w ith security cod e to access the site overnight, and update W H E R E . end E M P LO YE E
c la ss A D M IN IS T R A T IV E _ S T A F F in h e rits E M P L O Y E E e x p o rts p ro c e d u re D O _ T H IS (F : F O LD E R ); T h is is a n a dd ition a l o p e ratio n th a t is sp e cific to a d m in istra to rs ; o th e r op e ra tio n s m a y also be a d d ed . e n d A D M IN IS T R A T IV E _ S T A F F c la ss T E C H N IC A L _S T A F F in h e rits E M P L O Y E E e x p o rts fu n c tio n G E T _ S K ILL (): S K ILL ; p ro c e d u re D E F _ S K IL L (S K : S K IL L ); T h es e a re a dd ition a l o p e ratio n s th a t are sp e cific to te ch n icia n s; o the r o p era tio n s m a y a lso b e ad d e d . e n d T E C H N IC A L _S T A F F
Inheritance
A way of building software incrementally A subclass defines a subtype
subtype is substitutable for parent type
Polymorphism
a variable referring to type A can refer to an object of type B if B is a subclass of A
Dynamic binding
the method invoked through a reference depends on the type of the object associated with the reference at runtime
ADMINISTRATIVE_STAFF
TECHNICAL_STAFF
UML associations
Associations are relations that the implementation is required to support Can have multiplicity constraints
TECHNICAL _STAFF * project_member 1..* manages MANAGER 1 1 PROJECT
Aggregation
Defines a PART_OF relation
Differs from IS_COMPOSED_OF Here TRANGLE has its own methods It implicitly uses POINT to define its data attributes
TRIANGLE
1 3 POINT
More on UML
Representation of IS_COMPONENT_OF via the package notation
Class 3
Software architecture
Describes overall system organization and structure in terms of its major constituents and their interactions Standard architectures can be identified
pipeline blackboard event based (publish-subscribe)
Standard architectures
Pipeline Sub-sys processing elements Blackboard comm. Between several Sub-sys event based Event detection by sensor or mesg arrival
Questions
What is the life cycle of a software product? Why do we need software process models? What are the goals of a software process and what makes it different from other industrial processes?
Outline
Traditional answer: "waterfall" lifecycles Flexible, incremental processes Case studies
"synchronize-and-stabilize" (Microsoft) the "open source" development model
Life cycle
The life cycle of a software product
from inception of an idea for a product through
requirements gathering and analysis architecture design and specification coding and testing delivery and deployment maintenance and evolution retirement
Code&Fix
The earliest approach No distinction between end user & programmer. End user scientist or engineer s/w development activity - Write code Model code & fix Fix it to eliminate any errors that have been detected, to enhance existing functionality, or to add new features Source of difficulties and deficiencies
impossible to predict impossible to manage
Consequences of growth in h/w capacity Separation between s/w developer & user. E.g. sales agent or personnel admin. Economic, organizational, physiological issues.
Black berry torch ex.
Fields where system failure have sever consequences. Code & fix was inadequate due to
Increased size, difficult to manage Frequent discovery
The size and economic value of software applications required appropriate "process models
Cost benefit analysis.
Problems
The assumption is that requirements can be fully understood prior to development Interaction with the customer occurs only at the beginning (requirements) and end (after delivery) Unfortunately the assumption almost never holds
feedback
Advantages
Reduce risks by improving visibility Allow project changes as the project progresses
based on feedback from the customer
Feasibility study
Why a new project?
cost/benefits tradeoffs buy vs make
Requires to perform preliminary requirements analysis Produces a Feasibility Study Document
1. Definition of the problem 2. Alternative solutions and their expected benefits 3. Required resources, costs, and delivery dates in each proposed alternative solution
Requirements engineering
Involves
eliciting understanding analyzing specifying
Focus on
what qualities are needed, NOT on how to achieve them
What is needed
Understand interface between the application and the external world Understand the application domain Identify the main stakeholders and understand expectations
different stakeholders have different viewpoints software engineer must integrate and reconcile them
"horizontal" modularity
different viewpoints
A case study
railway automation
Who are the stakeholders?
management of the train company train drivers and their unions passengers (customers) contractors
Case study
how to classify requirements
Safety requirements
the probability of accidents should be less than 10-9 per year
Utility requirements
level of usefulness of the system as perceived by the various stakeholders
Case study
the produced document
Introduction: the mission of the system Architecture: the main structure of the system Specific requirements associated with each subsystem
discussion of how the subsystems requirements guarantee that the overall goals are indeed achieved
Deployment
components allocated on physical architecture
Maintenance
corrective, adaptive, perfective
Maintenance
Requirements errors are main cause of maintenance activities Late discovery of requirements errors causes increased costs
A waterfall model
R e quirem e nts
D esign
C oding and m odule testing Integration and system testing D elivery, deploym ent, and m aintenance
Evolutionary models
Many variants available Product development evolves through increments
"do it twice" (F. Brooks, 1995) evolutionary prototype
Incremental delivery
Identify self-contained functional units that may be delivered to customers To get early feedback
According to T. Gilb, 1988:
Deliver something to the real user Measure the added value to the user in all critical dimensions Adjust design and objectives
Transformation model
Guided by formal methods Specifications transformed into implementations via transformations Still a theoretical reference model
Transformation model
Decisions & rationale Reusable components
Requirements
Formal specifications
Optimization
Verification
Tuning
Spiral model
B. Boehm, 1989
Evolution of process models Waterfall documentation driven Evolutionary increment driven Transformation specification driven
Transformational
specification driven
Spiral
risk driven
The process
Planning phase
vision of the product, specification, schedule
Development
team composed of 2 groups
developers and testers (continuous testing)
process prescribes
daily synchronization product stabilization