Chapter 1 The Phases of Software Development. Software Development Phases ● Specification of the task ● Design of a solution ● Implementation of solution.

Slides:



Advertisements
Similar presentations
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Advertisements

Chapter 1. The Phases of Software Development. Data Structure 2 Chapter outline  Objectives  Use Javadoc to write a method’s complete specification.
1 Design by Contract Building Reliable Software. 2 Software Correctness Correctness is a relative notion  A program is correct with respect to its specification.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Zhigang Zhu, CSC212 Data Structures - Section FG Lecture 1: Introduction Instructor: Zhigang Zhu Department of Computer Science City College.
 An important topic: preconditions and postconditions.  They are a method of specifying what a function accomplishes. Preconditions and Postconditions.
CS 201 Functions Debzani Deb.
1 CMSC 132: Object-Oriented Programming II Nelson Padua-Perez William Pugh Department of Computer Science University of Maryland, College Park.
Chapter 1 Principles of Programming and Software Engineering.
Chapter 1 Software Engineering. Homework ► Read Section 2.2 (pages 79-98) ► Answer questions: ► 7, 8, 11, 12, & 13 on page 134. ► Answer on paper, hand.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Edgardo Molina, CSC212 Data Structures - Section AB Lecture 1: Introduction Instructor: Edgardo Molina Department of Computer Science City College.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
CS 1031 Introduction (Outline) The Software Development Process Performance Analysis: the Big Oh. Abstract Data Types Introduction to Data Structures.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Xiaoyan Li, CSC211 Data Structures Lecture 1: Introduction Instructor: Prof. Xiaoyan Li Department of Computer Science Mount Holyoke College.
Chapter 1 Introduction. Goal to learn about computers and programming to compile and run your first Java program to recognize compile-time and run-time.
COP 3530 PROGRAM, FILE & DATA STRUCTURES Syllabus Syllabus Lab Information Lab Information Overrides Overrides Questions? Questions?
CS Fall 2007 Dr. Barbara Boucher Owens. CS 2 Text –Main, Michael. Data Structures & Other Objects in Java Third Edition Objectives –Master building.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Data Structures Chapter 1- Introduction Mohamed Mustaq.A.
1 C++ Plus Data Structures Nell Dale Chapter 1 Software Engineering Principles Modified from the Slides made by Sylvia Sorkin, Community College of Baltimore.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
Programming Life Cycle Problem analysisunderstand the problem Requirements definition specify what program will do High- and low-level designhow it meets.
P An important topic: preconditions and postconditions. p They are a method of specifying what a function accomplishes. Preconditions and Postconditions.
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
P An important topic: preconditions and postconditions. p They are a method of specifying what a function accomplishes. Illinois State University Department.
 An important topic: preconditions and postconditions.  They are a method of specifying what a method accomplishes. Preconditions and Postconditions.
Software Development p Data structure p A collection of data organized so that the data can be accessed using a set of specific techniques p Object-oriented.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
Data Structures Using C++ 2E
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Data Structure Introduction Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2010.
Testing CSE 160 University of Washington 1. Testing Programming to analyze data is powerful It’s useless (or worse!) if the results are not correct Correctness.
Chapter 1 Software Engineering Principles. Problem analysis Requirements elicitation Software specification High- and low-level design Implementation.
1 Introduction 1. Why Data Structures? 2. What AreData Structure? 3. Phases of Software Development 4. Precondition and Postcondition 5. Examples.
George Wolberg, CSC212 Data Structures Lecture 1: Introduction Instructor: George Wolberg Department of Computer Science City College of New York.
FUNCTIONS. Midterm questions (1-10) review 1. Every line in a C program should end with a semicolon. 2. In C language lowercase letters are significant.
Chapter 2 Principles of Programming and Software Engineering.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Software Engineering Algorithms, Compilers, & Lifecycle.
9.1 CLASS (STATIC) VARIABLES AND METHODS Defining classes is only one aspect of object-oriented programming. The real power of object-oriented programming.
1 Sections 7.2 – 7.7 Nested Control Statements Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Principles of Programming & Software Engineering
Chapter 1 The Phases of Software Development
Welcome to CSIS 10B Overview of Course Software Design (from Nyhoff)
C++ Plus Data Structures
CSCI-235 Micro-Computer Applications
Chapter 1 The Phases of Software Development
The Software Development Cycle
Principles of Programming and Software Engineering
About the Presentations
Algorithm and Ambiguity
Designing and Debugging Batch and Interactive COBOL Programs
Unit# 9: Computer Program Development
Preconditions, Postconditions & Assertions
Introduction to Data Structures
Slides by Steve Armstrong LeTourneau University Longview, TX
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Data Structures and Algorithms for Information Processing
Preconditions and Postconditions
Week 4 Lecture-2 Chapter 6 (Methods).
Single-Result Functions & Modularity
Preconditions and Postconditions
The Software Development Cycle
Presentation transcript:

Chapter 1 The Phases of Software Development

Software Development Phases ● Specification of the task ● Design of a solution ● Implementation of solution ● Analysis of solution ● Testing and debugging ● Maintenance and evolution of the system ● Obsolescence

Specification ● Precise description of problem ● May be one of the most difficult phases

Design ● Algorithm – set of instructions for solving problem ● Not originally done in programming language – pseudocode – Formal modeling language (UML) ● Decompose problem into smaller – more manageable subtasks – map to subprograms – Need to be as independent of each other as possible ● Reuse ● Modification – All domain information should be located only 1 place in the code ● Each subprogram should only do 1 task – Each subprogram should be treated as a black box – specification not implementation – called procedural abstraction / information hiding

 An important topic: preconditions and postconditions.  They are a method of specifying what a function accomplishes. Preconditions and Postconditions Data Structures and Other Objects Using C++

Preconditions and Postconditions Frequently a programmer must communicate precisely what a function accomplishes, without any indication of how the function does its work. Can you think of a situation where this would occur ?

Example  You are the head of a programming team and you want one of your programmers to write a function for part of a project. HERE ARE THE REQUIREMENTS FOR A FUNCTION THAT I WANT YOU TO WRITE. I DON'T CARE WHAT METHOD THE FUNCTION USES, AS LONG AS THESE REQUIREMENTS ARE MET.

What are Preconditions and Postconditions?  One way to specify such requirements is with a pair of statements about the function.  The precondition statement indicates what must be true before the function is called.  The postcondition statement indicates what will be true when the function finishes its work.

Example void write_sqrt(double x) // Precondition: x >= 0. // Postcondition: The square root of x has // been written to the standard output....

Example void write_sqrt( double x) // Precondition: x >= 0. // Postcondition: The square root of x has // been written to the standard output.... }  The precondition and postcondition appear as comments in your program.

Example void write_sqrt( double x) // Precondition: x >= 0. // Postcondition: The square root of x has // been written to the standard output.... }  In this example, the precondition requires that x >= 0 x >= 0 be true whenever the function is called. be true whenever the function is called.

Example write_sqrt( -10 ); write_sqrt( 0 ); write_sqrt( 5.6 ); Which of these function calls meet the precondition ?

Example Which of these function calls meet the precondition ? write_sqrt( -10 ); write_sqrt( 0 ); write_sqrt( 5.6 ); The second and third calls are fine, since the argument is greater than or equal to zero.

Example Which of these function calls meet the precondition ? write_sqrt( -10 ); write_sqrt( 0 ); write_sqrt( 5.6 ); But the first call violates the precondition, since the argument is less than zero.

Example void write_sqrt( double x) // Precondition: x >= 0. // Postcondition: The square root of x has // been written to the standard output.... }  The postcondition always indicates what work the function has accomplished. In this case, when the function returns the square root of x has been written.

Another Example bool is_vowel( char letter ) // Precondition: letter is an uppercase or // lowercase letter (in the range 'A'... 'Z' or 'a'... 'z'). // Postcondition: The value returned by the // function is true if Letter is a vowel; // otherwise the value returned by the function is // false....

Another Example is_vowel( 'A' ); is_vowel(' Z' ); is_vowel( '?' ); What values will be returned by these function calls ?

Another Example is_vowel( 'A' ); is_vowel(' Z' ); is_vowel( '?' ); What values will be returned by these function calls ? true false Nobody knows, because the precondition has been violated.

Another Example is_vowel( '?' ); What values will be returned by these function calls ? Violating the precondition might even crash the computer.

Always make sure the precondition is valid...  The programmer who calls the function is responsible for ensuring that the precondition is valid when the function is called. AT THIS POINT, MY PROGRAM CALLS YOUR FUNCTION, AND I MAKE SURE THAT THE PRECONDITION IS VALID.

... so the postcondition becomes true at the function’s end.  The programmer who writes the function counts on the precondition being valid, and ensures that the postcondition becomes true at the function’s end. THEN MY FUNCTION WILL EXECUTE, AND WHEN IT IS DONE, THE POSTCONDITION WILL BE TRUE. I GUARANTEE IT.

A Quiz Suppose that you call a function, and you neglect to make sure that the precondition is valid. Who is responsible if this inadvertently causes a 40- day flood or other disaster?  You  The programmer who wrote that torrential function  Noah

A Quiz Suppose that you call a function, and you neglect to make sure that the precondition is valid. Who is responsible if this inadvertently causes a 40- day flood or other disaster?  You The programmer who calls a function is responsible for ensuring that the precondition is valid. The programmer who calls a function is responsible for ensuring that the precondition is valid.

On the other hand, careful programmers also follow these rules:  When you write a function, you should make every effort to detect when a precondition has been violated.  If you detect that a precondition has been violated, then print an error message and halt the program.

On the other hand, careful programmers also follow these rules:  When you write a function, you should make every effort to detect when a precondition has been violated.  If you detect that a precondition has been violated, then print an error message and halt the program... ...rather than causing a disaster. a disaster.

Example void write_sqrt( double x) // Precondition: x >= 0. // Postcondition: The square root of x has // been written to the standard output. { assert(x >= 0);...  The assert function (described in Section 1.1) is useful for detecting violations of a precondition.

Advantages of Using Preconditions and Postconditions  Succinctly describes the behavior of a function... ... without cluttering up your thinking with details of how the function works.  At a later point, you may reimplement the function in a new way... ... but programs (which only depend on the precondition/postcondition) will still work with no changes.

Precondition  The programmer who calls a function ensures that the precondition is valid.  The programmer who writes a function can bank on the precondition being true when the function begins execution. Postcondition  The programmer who writes a function ensures that the postcondition is true when the function finishes executing. Summary

C++ Features: Standard Library & Standard Namespace ● #include directive – Similar to import directive in other languages – Much more primitive ● Namespaces – allows limiting visibility of “names” ● Standard namespace – standard C++ libraries ● 2 choices – using namespace std: – Fully qualified identifier

Exception Handling ● Similar to Java and C#

Running Time Analysis ● Machine independent method of measuring run time efficiency ● Determine basic operation for the algorithm ● Expression the number of operations as a function of the data size ● Interested in the order of magnitude of this function – expressed using Big-O notation

Running Time Analysis ● Worst case – maximum number of operations ● Best case – minimum number of operations ● Average case – depends upon the underlying probability distribution

Testing and Debugging ● Good test data – Correct output known – Include values most likely to causes errors ● Boundary values – Fully exercise code ● Every line of code is executed by at least 1 test case