agile software constructionbeatrice/agile_and_iv1300/lectures/f4_a… · 5 advantages of explicit...

84
AGILE Software Construction Beatrice Åkerblom [email protected]

Upload: others

Post on 03-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

AGILE SoftwareConstruction

Beatrice Å[email protected]

Page 2: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

2

Outline for the lecture

DesignDesign

PostdeliveryPostdeliveryMaintenanceMaintenance

ImplementationImplementation

Page 3: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

DesignDesign

Design

We will look at architectural design, design-by-contract anddesign patterns

PostdeliveryPostdeliveryMaintenanceMaintenanceImplementationImplementation

Page 4: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

4

Software architecture

❖ The design process for identifying the sub-systems making up a system and the frameworkfor sub-system control and communication isarchitectural design.

❖ The output of this design process is adescription of the software architecture.

❖ Architectural design:

~ Is done at an early stage of the system designprocess.

~ Represents the link between specification anddesign processes.

~ Often carried out in parallel with somespecification activities.

~ It involves identifying major systemcomponents and their communications.

Page 5: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

5

Advantages of explicitarchitecture

❖ Stakeholder communication

~ Architecture may be used as a focus ofdiscussion by system stakeholders.

❖ System analysis

~ Means that analysis of whether the system canmeet its non-functional requirements ispossible.

❖ Large-scale reuse

~ The architecture may be reusable across arange of systems.

Page 6: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

6

Architecture and systemcharacteristics

❖ Performance

~ Localise critical operations and minimisecommunications. Use large rather than fine-grain components.

❖ Security

~ Use a layered architecture with critical assetsin the inner layers.

❖ Safety

~ Localise safety-critical features in a smallnumber of sub-systems.

❖ Availability

~ Include redundant components andmechanisms for fault tolerance.

❖ Maintainability

~ Use fine-grain, replaceable components.

Page 7: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

7

Architectural conflicts

❖ Using large-grain components improvesperformance but reduces maintainability.

❖ Introducing redundant data improves availabilitybut makes security more difficult.

❖ Localising safety-related features usually meansmore communication, leading to degradedperformance

Page 8: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

8

System structuring

❖ Concerned with decomposing the system intointeracting sub-systems.

❖ The architectural design is normally expressedas a block diagram presenting an overview ofthe system structure.

❖ More specific models showing how sub-systemsshare data, are distributed and interface witheach other may also be developed.

Page 9: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

9

Box and line diagrams

❖ Very abstract - they do not show the nature ofcomponent relationships nor the externallyvisible properties of the sub-systems.

❖ However, useful for communication withstakeholders and for project planning.

Page 10: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

10

Architectural designdecisions

❖ Is there a generic application architecture thatcan be used?

❖ How will the system be distributed?

❖ What architectural styles are appropriate?

❖ What approach will be used to structure thesystem?

❖ How will the system be decomposed intomodules?

❖ What control strategy should be used?

❖ How will the architectural design be evaluated?

❖ How should the architecture be documented?

Page 11: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

11

Architectural styles

❖ The architectural model of a system mayconform to a generic architectural model orstyle.

❖ An awareness of these styles can simplify theproblem of defining system architectures.

❖ However, most large systems areheterogeneous and do not follow a singlearchitectural style.

Page 12: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

12

Architectural models

❖ Used to document an architectural design.

❖ Static structural model that shows the majorsystem components.

❖ Dynamic process model that shows the processstructure of the system.

❖ Interface model that defines sub-systeminterfaces.

❖ Relationships model such as a data-flow modelthat shows sub-system relationships.

❖ Distribution model that shows how sub-systems are distributed across computers.

Page 13: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

13

System organisation

❖ Reflects the basic strategy that is used tostructure a system.

❖ Three organisational styles are widely used:

~ A shared data repository style

~ A shared services and servers style

~ An abstract machine or layered style

Page 14: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

14

The repository model

❖ Sub-systems must exchange data. This may bedone in two ways:

~ Shared data is held in a central database orrepository and may be accessed by all sub-systems

~ Each sub-system maintains its own databaseand passes data explicitly to other sub-systems.

❖ When large amounts of data are to be shared,the repository model of sharing is mostcommonly used

Page 15: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

15

CASE toolsetarchitecture

Page 16: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

16

Repository modelcharacteristics

❖ Advantages

~ Efficient way to share large amounts of data

~ Sub-systems need not be concerned with howdata is produced Centralised managemente.g. backup, security, etc.

~ Sharing model is published as the repositoryschema.

❖ Disadvantages

~ Sub-systems must agree on a repository datamodel. Inevitably a compromise

~ Data evolution is difficult and expensive

~ No scope for specific management policies

~ Difficult to distribute efficiently.

Page 17: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

17

Client-server model

❖ Distributed system model which shows howdata and processing is distributed across arange of components.

❖ Set of stand-alone servers which providespecific services such as printing, datamanagement, etc.

❖ Set of clients which call on these services.

❖ Network which allows clients to access servers.

Page 18: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

18

Film and picture library

Page 19: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

19

Client-servercharacteristics

❖ Advantages

~ Distribution of data is straightforward

~ Makes effective use of networked systems.May require cheaper hardware

~ Easy to add new servers or upgrade existingservers.

❖ Disadvantages

~ No shared data model so sub-systems usedifferent data organisation. Data interchangemay be inefficient

~ Redundant management in each server

~ No central register of names and services - itmay be hard to find out what servers andservices are available.

Page 20: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

20

Layered model

❖ Used to model the interfacing of sub-systems.

❖ Organises the system into a set of layers (orabstract machines) each of which provide a setof services.

❖ Supports the incremental development of sub-systems in different layers. When a layerinterface changes, only the adjacent layer isaffected.

❖ However, often artificial to structure systems inthis way.

Page 21: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

21

Version managementsystem

Page 22: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

22

Modulardecomposition

styles

❖ Styles of decomposing sub-systems intomodules.

❖ No rigid distinction between system organisationand modular decomposition.

Page 23: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

23

Modulardecomposition

❖ Another structural level where sub-systems are decomposed intomodules.

❖ Two modular decomposition modelscovered

~ An object model where the system isdecomposed into interacting object;

~ A pipeline or data-flow model wherethe system is decomposed intofunctional modules which transforminputs to outputs.

❖ If possible, decisions aboutconcurrency should be delayed untilmodules are implemented.

Page 24: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

24

Object models

❖ Structure the system into a set ofloosely coupled objects with well-defined interfaces.

❖ Object-oriented decomposition isconcerned with identifying objectclasses, their attributes andoperations.

❖ When implemented, objects arecreated from these classes and somecontrol model used to coordinateobject operations.

Page 25: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

25

Invoice processingsystem

Page 26: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

26

Object modeladvantages

❖ Objects are loosely coupled so theirimplementation can be modified withoutaffecting other objects.

❖ The objects may reflect real-world entities.

❖ OO implementation languages are widely used.

❖ However, object interface changes may causeproblems and complex entities may be hard torepresent as objects.

Page 27: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

27

Function-orientedpipelining

❖ Functional transformations processtheir inputs to produce outputs.

❖ May be referred to as a pipe and filtermodel (as in UNIX shell).

❖ Variants of this approach are verycommon.

❖ When transformations are sequential,this is a batch sequential model whichis extensively used in data processingsystems.

❖ Not really suitable for interactivesystems.

Page 28: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

28

Invoice processingsystem

Page 29: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

29

Pipeline modeladvantages

❖ Supports transformation reuse.

❖ Intuitive organisation for stakeholdercommunication.

❖ Easy to add new transformations.

❖ Relatively simple to implement as either aconcurrent or sequential system.

❖ However, requires a common format for datatransfer along the pipeline and difficult tosupport event-based interaction.

Page 30: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

30

Control styles

❖ Are concerned with the control flow betweensub-systems. Distinct from the systemdecomposition model.

❖ Centralised control

~ One sub-system has overall responsibility forcontrol and starts and stops other sub-systems.

❖ Event-based control

~ Each sub-system can respond to externallygenerated events from other sub-systems orthe system’s environment.

Page 31: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

31

Centralised control

❖ A control sub-system takes responsibility formanaging the execution of other sub-systems.

❖ Call-return model

~ Top-down subroutine model where controlstarts at the top of a subroutine hierarchy andmoves downwards. Applicable to sequentialsystems.

❖ Manager model

~ Applicable to concurrent systems. One systemcomponent controls the stopping, starting andcoordination of other system processes. Can beimplemented in sequential systems as a casestatement.

Page 32: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

32

Call-return model

Page 33: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

33

Real-time systemcontrol

Page 34: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

34

Broadcast model

❖ Effective in integrating sub-systemson different computers in a network.

❖ Sub-systems register an interest inspecific events.

❖ When these occur, control istransferred to the sub-system whichcan handle the event.

❖ Control policy is not embedded in theevent and message handler. Sub-systems decide on events of interestto them.

❖ However, sub-systems don’t know if orwhen an event will be handled.

Page 35: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

35

Selectivebroadcasting

Page 36: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

36

Interrupt-drivensystems

❖ Used in real-time systems where fastresponse to an event is essential.

❖ There are known interrupt types witha handler defined for each type.

❖ Each type is associated with amemory location and a hardwareswitch causes transfer to its handler.

❖ Allows fast response but complex toprogram and difficult to validate.

Page 37: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

37

Interrupt-drivencontrol

Page 38: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

38

Referencearchitectures

❖ Architectural models may be specific to someapplication domain.

❖ Two types of domain-specific model

~ Generic models which are abstractions from anumber of real systems and which encapsulatethe principal characteristics of these systems.

~ Reference models which are more abstract,idealised model. Provide a means ofinformation about that class of system and ofcomparing different architectures.

❖ Generic models are usually bottom-up models --Reference models are top-down models.

Page 39: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

39

Referencearchitectures

❖ Reference models are derived from a study ofthe application domain rather than fromexisting systems.

❖ May be used as a basis for systemimplementation or to compare different systems.It acts as a standard against which systems canbe evaluated.

❖ OSI model is a layered model for communicationsystems.

Page 40: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

40

OSI reference model

Page 41: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

41

Object identification

❖ Identifying objects (or object classes)is the most difficult part of objectoriented design.

❖ There is no 'magic formula' for objectidentification. It relies on the skill,experience and domain knowledge ofsystem designers.

❖ Object identification is an iterativeprocess.

❖ You are unlikely to get it right firsttime.

Page 42: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

42

Approaches toidentification

❖ Use a grammatical approach based ona natural language description of thesystem (used in Hood OOD method).

❖ Base the identification on tangiblethings in the application domain.

❖ Use a behavioural approach andidentify objects based on whatparticipates in what behaviour.

❖ Use a scenario-based analysis. Theobjects, attributes and methods ineach scenario are identified.

Page 43: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

43

Further objects andobject refinement

❖ Use domain knowledge to identifymore objects and operations

❖ Active or passive objects

~ Objects that are passive act onrequest rather than autonomously.This introduces flexibility at theexpense of controller processingtime.

Page 44: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

44

Design models

❖ Design models show the objects andobject classes and relationshipsbetween these entities.

❖ Static models describe the staticstructure of the system in terms ofobject classes and relationships.

❖ Dynamic models describe thedynamic interactions between objects.

Page 45: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

45

Examples of designmodels

❖ Sub-system models that show logicalgroupings of objects into coherentsubsystems.

❖ Sequence models that show thesequence of object interactions.

❖ State machine models that show howindividual objects change their statein response to events.

❖ Other models include use-casemodels, aggregation models,generalisation models, etc.

Page 46: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

46

Subsystemmodels

❖ Shows how the design is organisedinto logically related groups of objects.

❖ In the UML, these are shown usingpackages - an encapsulationconstruct.

❖ This is a logical model. The actualorganisation of objects in the systemmay be different.

Page 47: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

47

Sequence models

❖ Sequence models show the sequenceof object interactions that take place

~ Objects are arranged horizontallyacross the top;

~ Time is represented vertically somodels are read top to bottom;

~ Interactions are represented bylabelled arrows,

~ Different styles of arrow representdifferent types of interaction;

~ A thin rectangle in an object lifelinerepresents the time when the objectis the controlling object in thesystem.

Page 48: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

48

Statecharts

❖ Show how objects respond to differentservice requests and the statetransitions triggered by theserequests

~ If object state is Shutdown then itresponds to a Startup() message;

~ In the waiting state the object iswaiting for further messages;

~ If reportWeather () then systemmoves to summarising state;

~ If calibrate () the system moves to acalibrating state;

~ A collecting state is entered when aclock signal is received.

Page 49: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

49

Object interfacespecification

❖ Object interfaces have to be specifiedso that the objects and othercomponents can be designed inparallel.

❖ Designers should avoid designing theinterface representation but shouldhide this in the object itself.

❖ Objects may have several interfaceswhich are viewpoints on the methodsprovided.

❖ The UML uses class diagrams forinterface specification but Java mayalso be used.

Page 50: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

50

Testing during theDesign Phase

❖ Design must correctly reflectspecifications

❖ Design itself must be correct

❖ Transaction-driven inspections

Page 51: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

51

Challenges of theDesign Phase

❖ Design team should not do too much

~ Detailed design should not becomecode

❖ Design team should not do too little

~ It is essential for the design team toproduce a complete detailed design

❖ We need to grow great designers

Page 52: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

52

Design by contract

❖ A methodology for designing software❖ Originally in Eiffel❖ Design should include the creation of precise

and checkable interfaces

~ Software entities have obligations to otherentities based upon formalized rules betweenthem

~ Acceptable and unacceptable input values ortypes and their meanings

~ Return values or types and their meanings

~ Error and excxeption conditions values ortypes that can occur, and their meanings

~ Side-effects

~ Preconditions

~ Postconditions

~ Invariants

Page 53: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

53

Design patterns –History

❖ Architect Christopher Alexander, late 1970s.

~ “ A Pattern Language”

~ “A Timeless Way of Building”

❖ Quiet until 1987 when patterns appeared againat an OOPSLA conference.

❖ In 1995, Erich Gamma, Richard Helm, RalphJohnson, and John Vlissides published “DesignPatterns: Elements of Reusable Object-OrientedSoftware”

Page 54: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

54

Patterns Defined

❖ Patterns are devices that allow programmers toshare knowledge about designs.

❖ When building systems we encounter manyproblems that have occured and will occuragain. Documenting patterns is a way to reusesolutions and possibly share the way to solve aspecific program design problem.

Page 55: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

55

Patterns Defined

❖ The general form for documenting patterns isto define items such as:

~ The motivation or context that this patternapplies to.

~ Prerequisites that should be satisfied beforedeciding to use a pattern.

~ A description of the program structure that thepattern will define.

~ List of participants needed to complete apattern.

~ Consequences of using the pattern (bothpositive and negative).

~ Examples

Page 56: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

56

Pattern Examles

❖ Delegation pattern

❖ Interface pattern

❖ Proxy pattern

❖ Immutable pattern

Page 57: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

ImplementationImplementation

DesignDesign ImplementationImplementation PostdeliveryPostdeliveryMaintenanceMaintenance

Page 58: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

58

ImplementationPhase

❖ Programming-in-the-many

❖ Choice of Programming Language

~ Language is usually specified in contract

~ But what if the contract specifies the product isto be implemented in the “most suitable”programming language?

❖ What language should be chosen?

Page 59: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

59

Choice ofProgramming

Language (contd)

❖ Example

~ QQQ Corporation has been writing COBOLprograms for over 25 years

~ Over 200 software staff, all with COBOLexpertise

~ What is “most suitable” programminglanguage?

❖ Obviously COBOL

Page 60: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

60

Choice ofProgramming

Language (contd)❖ What happens when new language (C++, say) is

introduced

~ New hires

~ Retrain existing professionals

~ Future products in C++

~ Maintain existing COBOL products

~ Two classes of programmers

❖ COBOL maintainers (despised)

❖ C++ developers (paid more)

~ Need expensive software, and hardware to runit

~ 100s of person-years of expertise with COBOLwasted

Page 61: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

61

ProgrammingStandards

❖ Can be both a blessing and a curse

❖ Modules of coincidental cohesion arise fromrules like

~ “Every module will consist of between 35 and50 executable statements”

❖  Better

~ “Programmers should consult their managersbefore constructing a module with fewer than35 or more than 50 executable statements”

Page 62: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

62

Remarks onProgrammingStandards

❖ No standard can ever be universally applicable

❖ Standards imposed from above will be ignored

❖ Standard must be checkable by machine

Page 63: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

63

Remarks onProgramming

Standards (contd)❖ Examples of good programming standards

~ “Nesting of if statements should not exceed adepth of 3, except with prior approval from theteam leader”

~ “Modules should consist of between 35 and 50statements, except with prior approval from theteam leader”

❖ The aim of standards is to make maintenanceeasier

~ If they make development difficult, then theymust be modified

~ Overly restrictive standards arecounterproductive, affecting software quality

Page 64: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

64

Comments forevery module

❖ Module name

❖ Brief description of what the module doe

❖ Programmer’s name

❖ Date module was coded

❖ Date module was approved, and by whom

❖ Module parameters

❖ Variable names, in alphabetical order, and uses

❖ Files accessed by this module

Page 65: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

65

Comments forevery module

❖ Files updated by this moduleModule i/o

❖ Error handling capabilities

❖ Name of file of test data (for regression testing)

❖ List of modifications made, when, approved bywhom

❖ Known faults, if any

Page 66: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

66

Code Walkthroughsand Inspections

❖ Rapid and thorough fault detection

~ Up to 95% reduction in maintenance costs[Crossman, 1982]

Page 67: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

67

Implementationand Integration

Phase❖ Common approach: Implementation first,

followed by integration

~ Poor approach

❖ A better way to do it is to combineimplementation and integration methodically.

Page 68: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

68

Product with 13Modules

❖ Implementation, Then Integration:

~ Code and test each module separately

~ Link all 13 modules together, test product as awhole

Page 69: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

69

Implementation,Then Integration

(contd)❖ Problem 1

~ Stubs and drivers must be written, then thrownaway after module testing is complete

❖ Problem 2

~ Lack of fault isolation

~ A fault could lie in any of 13 modules or 13interfaces

~ In a large product with, say, 103 modules and108 interfaces, there are 211 places where afault might lie

❖ Solution to both problems

~ Combine module and integration testing

~ “Implementation and integration phase”

Page 70: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

70

Top-downImplementationand Integration

❖ If module m1 calls module m2, then m1 isimplemented and integrated before m2

❖ One possible top-down ordering is:

~ a, b, c, d, e, f, g, h, i, j, k, l, m

❖ Another possible top-down ordering is:

~ a - [a] b, e, h - [a] c, d, f, i - [a, d] g, j, k, l, m

Page 71: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

71

Bottom-upImplementationand Integration

❖ If module m1 calls module m2, then m2 isimplemented and integrated before m1

❖ One possible bottom-up ordering is:  

~ l, m, h, i, j, k, e, f, g, b, c, d, a

❖ Another possible bottom-up ordering is:

~ h, e, b - i, f, c, d - l, m, j, k, g - [b, c, d] a 

Page 72: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

PostdeliveryMaintenance

Maintenance:Any change to any component of the product(including the documentation) after it has

passed the acceptance test.

ImplementationImplementation PostdeliveryPostdeliveryMaintenanceMaintenanceDesignDesign

Page 73: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

73

Types ofmaintenance

Page 74: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

74

Difficulty ofMaintenance

❖ About 67% of the  total cost of aproduct accrues during themaintenance phase

❖ Maintenance is a major income source

❖ Nevertheless, even today manyorganizations assign maintenance to

~ Unsupervised beginners, and

~ Less competent programmers

Page 75: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

75

CorrectiveMaintenance

❖ How to minimize regression faults

~ Consult the detailed documentation forproduct as a whole

~ Consult the detailed documentation foreach individual module

❖ What usually happens

~ There is no documentation at all, or

~ The documentation is incomplete, or

~ The documentation is faulty

❖ The programmer must deduce from thesource code itself all the informationneeded to avoid introducing a regressionfault

Page 76: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

76

CorrectiveMaintenance

(contd)❖ The programmer changes the source

code

❖ Test that the modification workscorrectly using specially constructed testcaases

❖ Check for regression faults using storedtest data

❖ Add specially constructed test cases tostored test data for future regressiontesting

❖ Document all changes

Page 77: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

77

Adaptive andPerfective

Maintenance❖ The maintenance programmer must go

through the phases of

~ Requirements

~ Specifications

~ Design

~ Implementation and integration

❖ Using the existing product as a startingpoint

Page 78: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

78

The Rewards ofMaintenance

❖ Maintainers deal with dissatisfied users– if the users were happy, the productwouldn't need maintenance

❖ The user's problems are often caused bythe individuals that developed theproduct, not by the maintainer

❖ Maintenance is despised by manysoftware developers

❖ Unless good maintenance service isprovided, the client will take futuredevelopment business elswhere

Page 79: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

79

EnsuringMaintainability

❖ Maintenance is not a one-time effort

❖ We must plan for maintenance duringthe entire software life-cycle

~ Design phase – use information hidingtechniques, etc.

~ Implementation phase – select variablenames that are meaningful to futuremaintenance programmers, etc.

~ Documentation must be complete andcorrect, and reflect current version ofevery module

Page 80: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

80

EnsuringMaintainability

(contd)

❖ During the maintenance phase,maintainability must not becompromised

❖ Always be conscious of the inevitablefurther maintenance

❖ Principles leading to maintainability areequally applicable to the maintenancephase itself

Page 81: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

81

Size of InheritanceHierarchy

❖ To find out what the result of calling amethod for some specific object does, wemay need to scan the entire inheritancetree

❖ Inheritance tree may be spread over theentire product

❖ A far cry from “independent units”...

Page 82: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

82

Consequences ofinheritance

❖ Create new subclass by inheritance

~ Does not affect superclass

~ Does not affect any other subclass

❖ Modify this new subclass

~ Again, no affect

❖ Modify a superclass

~ All descendent subclasses are affected

❖ Inheritance can have positive effect ondevelopment and negative effect onmaintenance

Page 83: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

83

Polymorphism andDynamic Binding

❖ Product fails on the invocationmyFile.open ()

~ Which version of open contains thefault?

Page 84: AGILE Software Constructionbeatrice/AGILE_and_IV1300/Lectures/f4_A… · 5 Advantages of explicit architecture Stakeholder communication ~ Architecture may be used as a focus of discussion

End of Today’sLecture

Thanks for your attention!