Lesson 5 o 4th Ed

ADVANCED PLACEMENT computer science - C++

Lesson 5:  Software Engineering

 

INTRODUCTION:                 The growth of computers in society has led to the development of a new discipline called software engineering.  Instead of working with beams, concrete, wires, or electricity, software engineers devise computer based solutions to problems.  Such problems invariably involve information.  Software engineers develop the programs to create, store, manipulate, and transmit such information.

 

The objective of any engineer is to build a functioning, reliable, and cost-effective solution to a problem.  Just as there is more to building a bridge than welding and pouring concrete, there is more to software engineering than writing code.  This lesson provides an overview of the process of developing effective software.

 

The key topics for this lesson are:

 

A.    Software Engineering

B.    Goals of Program Design

C.    Strategies of Software Design

D.    Program Implementation

E.    Analysis of Software

 

 

VOCABULARY:                     SOFTWARE ENGINEERING             DESIGN

ANALYSIS                                         SPECIFICATIONS            

ABSTRACTION                 CONTROL ABSTRACTION

DATA ABSTRACTION                    DECOMPOSITION

DATA STRUCTURE                                   ALGORITHM

IMPLEMENTATION

INFORMATION HIDING

 

DISCUSSION:                        A.    Software Engineering

 

1.    Definition:  refers to the entire process of developing a computer-based solution to a problem.

 

2.    Definition of a software engineer:  Someone who develops a program to solve a business or scientific problem.  Here is a short list of very important software systems used in our society:

 

Word processing

ATM's at banks

E-mail

Airline reservation systems

Weather forecasting

Internet browsers

Network communications

 

3.    Software engineering is constantly evolving as more efficient techniques are developed to design and maintain software.  While there are many different approaches to software development, this lesson will present strategies common to most textbooks. 

 

4.    Software development can be broken down into three aspects:

 

Design - effective planning and design of software.

Implementation - writing the code in a systematic fashion.

       Analysis - testing the reliability of the software and analyzing its efficiency.

 

5.    Software engineering is a critical topic for two important reasons.  Software systems are often huge undertakings involving thousands or millions of lines of code.  It is not practical to just sit down and write a large program.  The process of planning the software is just as important as writing the code.  More than 80% of the cost of a computer system in business and government is devoted to software development expenses, demanding a systematic and cost-effective approach.

 

 

B.    Goals of Program Design

 

1.    Program design is best defined as the planning and strategies used to develop software.  There are four goals of the program design phase.  The software should be:

 

Reliable

Understandable (easy-to-read)

Adaptable

Reusable

 

2.    Software should be reliable; it should work.  It is critical that software correctly solve the problems as specified by the customer.  The most important first step in program design is to listen to and understand the needs of the customer.

 

3.    The program produced should be relatively easy to understand by another programmer.  Software should be designed in such a manner that others can understand the strategies used to solve the problem.  This is important for the simple reason that software is often finished or revised by another programmer.  If it is difficult to understand, it will take more time and money to develop such software.

 

4.    Adaptability refers to the ease with which software can be revised and updated to meet new demands and conditions.  Because the computer industry changes so fast, software must adapt to keep up with changes.  Effective software is written in such a way that it can be easily maintained and improved.

 

5.    Reusable software is written in such a way that sections of it can be recycled in other programs.  Rather than start each program from scratch, developers should utilize existing code which already solves parts of the problem.  The trend toward object-oriented programming has facilitated recycling of code.

 

 

C.    Strategies of Software Design

 

1.    The process of designing effective software consists of two key strategies:  definition of the problem and structural design of the program.

 

2.    A problem must first be defined before it can be solved.  In this introductory computer science course most of the problems will be carefully specified and this phase will be minimized.  In real-life programming problems and larger projects, the problems will not be "pre-analyzed" and you will need to determine the specifications of the problem.

 

3.    Defining the problem should result in a written and comprehensive description of the problem to be solved.  These specifications will guide the programmer through the second phase of the design process.

 

4.    Once the problem is understood and the goals of the program are specified, the task of program design can begin.  Before code is written these preliminary steps should be taken:

 

Identification of reusable components from pre-existing code

Decomposition of the problem

Choice of data structures and algorithms

Design of the user-interface

 

5.    It makes sense to recycle code to solve part of your new problem.  Whenever possible re-use code from pre-existing sources.  Your C++ compiler provides some standard libraries and the Standard Template Library (as defined by Hewlett-Packard) is emerging as a reference source of defined objects.

 

6.    To decompose a problem means to break it down into reasonably-sized pieces.  The strategy of top-down design involves breaking the problem down until sections of the program can be solved with a self-contained routine.  This technique will be used throughout the curriculum guide.

 

7.    A data structure is the strategy chosen to store the data for a program.  This choice will have implications for the design of the program and its efficiency.  An algorithm is a routine to solve part of the overall problem.  The algorithms are, in part, dictated by the selection of the data structure.

 

8.    Lastly, the program must interact with a user.  How will the user interact with the program?  Most programs utilize keyboard input, but others also use modems, files, or a mouse. 

 

9.    Design of the user-interface must also consider how to deal with input errors.

 

 

D.    Program Implementation

 

1.    The implementation phase involves converting the design outline of the problem into a working program using a programming language.  As with the design stage, the programmer should keep in mind the same four goals during the implementation phase.  The program should be:

 

Reliable

Written in a clear and understandable manner

Adaptable, it should be easy to modify and improve

Result in modules or sections that could be used in other programs

 

2.    An important strategy used to shape the implementation phase is the concept of abstraction.  The term abstraction as used in computer science refers to using a routine without knowing the inner details.  It allows the programmer to separate usage from implementation.  Abstraction is applied at two different levels in computer science, control abstraction and data abstraction.

 

3.    Control abstraction refers to the development of individual modules (functions in C++) to solve an algorithmic problem.  For example, suppose a list of data is to be used in a program.  The main program could call previously defined routines, the details of which are hidden from the main program.  This is illustrated below:

 

         

 

      

       The three routines can be thought of as black boxes.  The main program typically will send input to each box and receive output back from each routine.  This is control abstraction.  Each routine is developed independently from the rest of the program and other parts of the program use the developed routines without knowing the details.

 

4.    Data abstraction raises the strategy to a higher level.  Data abstraction involves encapsulating the values needed to represent an object with the operations needed to manipulate the object.  This results in an abstract data type which can be used and recycled in many different programs.  A good example of an abstract data type (ADT) is the apstring class as supplied by the College Board.  The object implemented is a string of characters.  The operations supported by this object will include string I/O, concatenating strings together, relational operations of comparing strings, and other routines.  A string ADT can be used by any program which needs to solve problems involving strings.

 

5.    The implementation of the ADT is hidden from the user of the ADT.  The client program uses the ADT without knowing the implementation details.  This is called information hiding.

 

        

 

 

6.    The computer science concepts used to develop programs are relatively independent of the programming language used.  A majority of this course will focus on standard features available in most high-level programming languages.  These features include:

 

Input and output

Control constructs:  sequence, selection, and iteration

Standard algorithms:  searching, sorting, insertion and deletion of data

Standard data structures:  built-in data types, arrays, structures, records, strings, lists, and more

Handling errors

 

 

E.    Analysis of Software

 

1.    To analyze a program involves understanding, evaluation, and testing of the code.  Program analysis occurs both during and after the implementation of the code.

 

2.    Testing of code should occur during the sequential development of the program.  As each module is developed it should be tested in isolation.  The test data used should examine general and boundary cases.  After the module has been thoroughly tested, it can be integrated into the main program and re-tested in the context of the developing program.

 

3.    Testing of code will require strategies for debugging errors.  Programmers use three strategies for debugging code:

 

a.  Using the debugger included with the compiler.

b.  Adding extra print statements to diagnose the problem.

c.  Hand tracing the execution of the code using the source code listing (sometimes called "code walk through").

 

4.    An analysis of the algorithms used in the program is sometime necessary.  Whenever appropriate the curriculum will analyze the efficiency of algorithms for space and time.

 

5.    Eventually a completed program will need to be modified.  Analysis of programs also includes the understanding and modification of existing code.

 

SUMMARY/REVIEW:          The more complex the problem being solved, the greater the need for advanced planning.  Successful software solutions do not just happen.  They require enormous amounts of planning and hard work before they can be coded and tested.  In this lesson you have been presented with an overview of software engineering.  These principles will be applied as much as possible throughout the remainder of the course.

 

ASSIGNMENT:                     Worksheet W.A.5.1, Software Engineering