24
Software Construction

Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Embed Size (px)

Citation preview

Page 1: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Software Construction

Page 2: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Implementation

System Specification

RequirementsAnalysis

ArchitecturalDesign

DetailedDesign

Coding &Debugging

Unit Testing

SystemTesting

Maintenance

Page 3: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

System Construction/Implementation (cont.)

• Reviewing other team members’ low-level designs and code and having them review yours

• Polishing code by carefully formatting and commenting it

• Integrating software components that have been built separately

• Tuning code to make it smaller and faster

Page 4: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

System Construction/Implementation

• Verifying that the groundwork has been laid so that construction can proceed successfully

• Designing and writing routines and modules• Creating data types and naming variables• Selecting control structures and organizing

blocks of statements • Finding and fixing errors

Page 5: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Why is Software Construction Important?

• Construction is a large part of software development

• Construction is the pivotal (center) activity in software development

• With a focus on construction, the individual programmer’s productivity can improve enormously

• Construction’s product, the source code, is often the only accurate description of the software

• Construction is the only activity that’s guaranteed to be done

Page 6: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Software Metaphors/Style of Programming

1. Software Penmanship: Writing Code:It is like writing a casual letter – just write it from start to finish. It does not require any formal planningProblems: if the software is a project that requires more than one person

Page 7: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Software Metaphors/Style of Programming (cont.)

2. Software Farming: Growing a System:It is like planting seeds and growing crops. You design a piece, code a piece, test a piece and add it to the system a little bit at a timeProblems: you don’t have any direct control over how the software develops

Page 8: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Software Metaphors/Style of Programming (cont.)

3. Software Oyster Farming: System Accretion:

This approach is done by adding to your software a small amount at a time, that is, incremental designing, building and testing

Problems: it takes time to finish, but more reliable

Page 9: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Software Metaphors/Style of Programming (cont.)

4. Software Construction: Building Software:

– Developing software like building a tower– It covers planning, preparation, and

execution– Apply reuse code, library, tools, etc to speed

up the process

Page 10: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Prerequisites to Construction (Why is it important?)

• Prerequisites: the work that must be done to prepare for software construction.

• Many programmers don’t make preparation because: – They can’t resist the urge to begin coding

– Managers force programmer to do coding soon

• Doing prerequisites before construction is necessary for: – Planning the stages of software development

– Create a blueprint to be reviewed and approved before coding

– Finding error or mistakes at the early stages

Page 11: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Problem-Definition Prerequisite

 

Problem Definition

Requirements Analysis

Architecture

Construction

System Testing

Future Improvement

A clear statement of the problem that the system is supposed to solve.

Page 12: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Requirements Prerequisite

• Formal requirements is important – Help to ensure that the user, not programmer, drives the system

functionality– Minimize changes to a system after development– Specifying requirements adequately is a key to a project

success, perhaps even more important than effective construction techniques.

• The cost of errors detected in architecture stage is 5 times more expensive than in requirement phase. If detected in coding, 10 times more expensive; during system test is 20 times; during acceptance test is 50 times; and during maintenance is 100 times.

Page 13: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Architecture/Design Prerequisite

• The quality of the design determines the conceptual integrity of the system, and the quality of the system

Page 14: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Typical architectural components:

• Program organization (project modules)• Change strategy (make it flexible to change)• Buy vs build decisions (tools, libraries)• Major data structures (database structure)• Key algorithms (such as sorting technique)• Major objects to be implemented• Generic functionality (user interface, input/output)• Error processing (preventing & detecting error)• Robustness (ability to continue running after error)• Performance goals (in terms of speed & memory)• General architectural quality (open platform, future improvements)

Page 15: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Language Selection Program Best Languages Worst Lang

Structured data C/C++, Pascal Basic, Assembler

Quick project Visual Programming Pascal, Assembler

Fast execution Assembler, C Basic

Easy-to-maintain Pascal, C++ Fortran

Real-time program. Assembler, C Basic, Fortran

String manipulation Basic Pascal C

Database Oracle, DB2, Informix Access,

GUI + OO Visual Programming C, Cobol, Fortran

Numeric Processing Fortran Basic, C++

Page 16: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

STEPS IN BUILDING ROUTINE

Design the routine

Check the design

Check the codeCode the routine

Begin

Done

Page 17: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

PDL (Program Design Language)

• Use English-like statements that precisely describe specific operations

• Avoid syntactic elements from the target programming language

• Write PDL at the level of intent• Write PDL at a low enough level that generating

code from it will be nearly automatic

Page 18: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Example of PDL

Increment resource number by 1Allocate a dig struc using mallocIf malloc() returns NULL then return 1Invoke 0Srsrc_init to initialize a resource

Example of bad PDL

Example of Good PDLKeep track of current number of resourcesIf another resource is available Allocate a dialog box structure

If a dialog box structure could be allocatedNote that one more resource in useInitialize the resourceStore the resource number

EndifEndifReturn TRUE if a new resource was created

Page 19: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Benefits of using PDL

• PDL makes reviews easier• PDL supports the idea of iterative

refinement• PDL makes changes easier• PDL minimizes commenting efforts• PDL is easier to maintain than other forms

of design documentation

Page 20: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Design the Routine

• Check the prerequisites• Define the problem the routine will solve• Name the routine• Decide how to test the routine• Think about efficiency• Research the algorithms and data structures• Write the PDL• Think about the data• Check the PDL• Iterate

Page 21: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Code the Routine

• Write the routine declaration – Example:

// This routine outputs an error msg // based on an error code supplied ....

Procedure RecordErrorMsg{

ErrorCode : ErrorCode_t;Var Status: Status_t;

};

Page 22: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Code the Routine

• Turn the PDL into high-level comments,– Example:

begin//set the default status

....

end

Page 23: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Code the Routine• Fill in the code below each comment Example:

• Check the code informally • Clean up the leftovers• Repeat steps as needed

begin// set the default status Status := Failure; ……

end

Page 24: Software Construction. Implementation System Specification Requirements Analysis Architectural Design Detailed Design Coding & Debugging Unit Testing

Code the Routine

• Check the code formally– Mentally check the routine for errors– Compile the routine– Use the computer to check the routine for

errors– Remover errors from the routine