chapter 1 t software engineering and computer programming t course presentations are available for...
DESCRIPTION
Computer Science t Dates from the 1940’s t Study of algorithms t Algorithm implementation t Tied to mathematics t Tries to discover principles underlying hardware and softwareTRANSCRIPT
![Page 1: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/1.jpg)
Chapter 1
Software Engineering and Computer Programming
Course presentations are available for view and downloading on the course web page:
http://www.d.umn.edu/~jallert
![Page 2: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/2.jpg)
Goals
The goal of CS is the discovery of fundamental principles underlying computer programming
Software Engineering is about the construction of software systems
“pure” versus “applied” science They also have many common interests
![Page 3: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/3.jpg)
Computer Science
Dates from the 1940’s Study of algorithms Algorithm implementation Tied to mathematics Tries to discover principles underlying
hardware and software
![Page 4: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/4.jpg)
Software Engineering
Dates from late 1960’s Develop models of systems Major concerns are
– efficiency– reliability
Applies CS principles to construct better systems
![Page 5: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/5.jpg)
Basic processes for all CS professionals
Theory Abstraction Design
![Page 6: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/6.jpg)
Theory
Definitions, axioms, theorems, proofs Interpretation of results Example: Analysis of algorithm efficiency
![Page 7: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/7.jpg)
Abstraction
Developing models of the world– isolate the essential features of a problem– example: flipping a coin
• does not need to know denomination, metal, picture• simulates only one of two random outcomes
Test problem approaches
![Page 8: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/8.jpg)
Design
Requirements Specifications Program design Program implementation Testing Analysis
![Page 9: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/9.jpg)
The
The concerns of the computer scientist and the software engineer
Theory Abstraction
Design
Softwareengineer
Computerscientist
Datastructures
![Page 10: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/10.jpg)
Data Structures and ADT’s
![Page 11: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/11.jpg)
Data structure
Definition: A ‘data structure’ consists of
– A base storage method • (i.e. an array)
– One or more algorithms that are used to access or modify that data
![Page 12: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/12.jpg)
Program example
Here is a program demonstrating a dice data structure.
This first example is a procedural approach to the problem.
![Page 13: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/13.jpg)
// Code Example 1-1: // dice program that does not use an // abstract data type (adt) // // Compare this approach to cx1-2.cpp. #include "dslib.h" // standard header files for text #include <stdlib.h>
![Page 14: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/14.jpg)
int main() { int die1, die2, total; randomize(); // pseudorandom number generator die1 = random(6) + 1; // random(6) returns random number // between 0 and 5 die2 = random(6) + 1; total = die1 + die2; cout << "first die: " << die1; cout << “ second die: " << die2; cout << endl; cout << "total for roll is: ”; cout << total << endl; return 0; }
![Page 15: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/15.jpg)
Data structures dilemma Possible dice data structures
– two integers, each between 1 and 6– simple to implement, simple operations
Deck of cards data structure– more difficult, especially operations
Air traffic control system– very difficult– needs a model– high level of “software engineering”
![Page 16: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/16.jpg)
Abstract Data Type (ADT)
Gives us a tool to use to control complexity
Definition: a collection of data and operations– Data characteristics
• DOES NOT include method of representation– Operations
• DOES NOT include how implemented
![Page 17: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/17.jpg)
Definition of ADT
An Abstract Data Type (ADT) is – a well-specified collection of data
• known as the characteristics, or data state
– and a group of operations that can be performed upon the data• known as behaviors or operations
– member functions (C++)
– methods (Java)
![Page 18: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/18.jpg)
About ADTs
The ADT’s specification describes – what data can be stored
• (the characteristics of the ADT), – and how it can be used
• (the operations), – but not how it is implemented or
represented in the program.
![Page 19: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/19.jpg)
Decoupling ADTs do not specify how the data structure will be
implemented There may be many ways The data specification has been decoupled from the
implementation. This means that software development can be less
complex (fewer details to consider) Also, software development is more flexible (the
actual structure is not fixed)
![Page 20: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/20.jpg)
Dice ADT Characteristics (data state):
• Represents a pair of 6-sided dice, that can be rolled to get a random sum between 2 and 12.
Operations:– int roll()
• Precondition: none.• Task: A random value between 1 and 6 is
stored for each of the dice.• Returns: The sum of the two dice values, lying
between 2 and 12.
![Page 21: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/21.jpg)
Dice ADT operations (con’t)
– int die1()• Precondition: The dice have been rolled at
least once.• Postcondition: None.• Returns: The value of the first die.
– int die2()• Precondition: The dice have been rolled at
least once.• Postcondition: None.• Returns: The value of the second die.
![Page 22: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/22.jpg)
A program using a Dice ADT // Illustrates solution to a // "dice simulation", using // abstract data types. // // Dice ADT // // Characteristics: // Represents a pair of 6-sided dice, // that can be rolled to get a // random sum between 2 and 12. //
![Page 23: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/23.jpg)
Dice ADT operations comments // Operations: // int roll() // Preconditions: none // Postcondition: random value from 1-6 // is stored for each of the dice. // Returns: sum of the two dice values, // lying between 2 and 12
![Page 24: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/24.jpg)
die1() and die2() operations // int die1() // Precondition: dice have been rolled // at least once. // Postcondition: None // Returns: The value of the first die.
// int die2() // Precondition: dice have been rolled // at least once. // Postcondition: None // Returns: The value of the second die.
![Page 25: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/25.jpg)
Dice ADT program
// Note on encapsulation: // The representation of the // dice is contained within global // variables - we'll see shortly a better // way to do this. #include <iostream.h> #include <stdlib.h> #include "dslib.h" int dice_1, dice_2;
![Page 26: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/26.jpg)
Roll()
int roll() {// note -- you don't really want to call // randomize every time you roll the dice, // but for this simplified design you // don’t have much choice. randomize(); dice_1 = random(6) + 1; dice_2 = random(6) + 1; return dice_1 + dice_2; }
![Page 27: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/27.jpg)
die1() and die2()
int die1() { return dice_1; } int die2() { return dice_2; } // end of Dice ADT
![Page 28: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/28.jpg)
Client Code (the main program)
int main() // test program to demonstrate Dice ADT { cout << "The value rolled is: ”; cout << roll() << endl; cout << "The first die was: ”; cout << die1() << endl; cout << "The second die was: ”; cout << die2() << endl; return 0; }
![Page 29: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/29.jpg)
Exercise 1-4, p. 9
Some games for young children use colored squares on a board and a spinner that, in effect, picks one of the colors at random. Suppose that the game has five colors - red, green, blue, yellow and orange.
Design a spinner ADT. Do not write any code, just the ADT.
![Page 30: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/30.jpg)
Spinner problem
What is the data state (characteristics) of this ADT?– enumerated type: colors– spinner - of type colors
What are the operations– spin (randomly chooses a color)
![Page 31: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/31.jpg)
Spin() operation
Precondition:– none
Postcondition:– none
Returns:– the value of the spinner
![Page 32: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/32.jpg)
The Software Life Cycle
![Page 33: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/33.jpg)
The waterfall model of software development
Initiation Analysis Design Implementation Testing Maintenance
![Page 34: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/34.jpg)
Initiation
Feasibility study Examination of alternatives Cost-benefit analysis Make-or-buy study
![Page 35: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/35.jpg)
Analysis
Determines the exact requirements of the system Systems analyst (liaison between domain
experts and software engineers) Domain experts know the goals and purposes of
the software Software engineers will build the system Analyst creates functional specifications
document
![Page 36: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/36.jpg)
Functional specifications
Specifies exact functions the system must provide
Specifies special requirements– minimum performance limits
Legal requirements which must be met
![Page 37: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/37.jpg)
Design
Uses functional specifications as a blueprint Systems architect Deliverable is a technical, or coding
specification This is the most critical step in the process
– bad design may be impossible to implement– difficult to maintain (i.e. Y2K)
![Page 38: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/38.jpg)
Implementation
Writing the code Must meet coding specifications Develop system and user documentation
![Page 39: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/39.jpg)
Testing
Must start with a test plan– sample input: expected output– compares observed to expected
May use separate staff Final line of defense against unreliable
software
![Page 40: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/40.jpg)
Maintenance
Latent errors– Only become apparent after testing is finished
Adaptive maintenance– Changes to fit new environments– new OS, hardware, software
Enhancements– improved functionality– often for least experienced programmers
![Page 41: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/41.jpg)
The waterfall model of software development
Initiation
Analysis
Design
Implementation
Testing
Maintenance
![Page 42: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/42.jpg)
The waterfall model: A summary of the players and the deliverables
Phase Who Performs Deliverable
Initiation Managers Request for development
Analysis Systems analyst Functional specification
Design Systems architect Design specification
Implementation Programmer Documented code
Testing Systems tester Test plan and report
Maintenance Maintenanceprogrammer
![Page 43: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/43.jpg)
Critiques of waterfall method
Expensive Slow Unrealistic No emphasis on prototypes No connection with end users
![Page 44: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/44.jpg)
Prototyping
Often built with 4GL to provide GUI May only be a shell
– no functionality Implementation
– Direct– Parallel– Phased– Pilot
![Page 45: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/45.jpg)
Reusability
Programmers often “reinvent the wheel” No equivalent of “interchangeable parts” Software often not reusable in other apps OOP addresses these concerns
– inheritance New design techniques: design patterns
– provide a library of recurring designs– example: STL in C++– we will not use the STL in this class
![Page 46: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/46.jpg)
Documentation
How much? On what? What form? Three levels of documenters
– Technical writers– System documentation
• Software engineers/programmers• Internal and external
– Client documentation
![Page 47: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/47.jpg)
Internal documentation
Precondition– The assumed state of the data structures
Postcondition– The effects on the data structures– What the function has done
Returns– The value(s) returned
![Page 48: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/48.jpg)
Why C++?
Easy data abstraction OOP More features than C
![Page 49: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/49.jpg)
Evolution ADT concept
– Specification and implementation of a data structure aren’t the same
– But they are related and should be kept together– Pascal, C and other procedural languages do
not allow this. – Languages like Modula-2 and ADA allow you
to make ‘modules’ containing both
![Page 50: Chapter 1 t Software Engineering and Computer Programming t Course presentations are available for view and downloading on the course web page: t](https://reader033.vdocument.in/reader033/viewer/2022051717/5a4d1b5e7f8b9ab0599ac094/html5/thumbnails/50.jpg)
Evolution (continued)
C++ supports the module concept by allowing you define classes and instantiate them as objects
Objects may be created that inherit characteristics from other objects
You can use an object without knowing how it is implemented– Exact implementation may take many forms
(polymorphism)