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.

Slides:



Advertisements
Similar presentations
Chapter 5 introduces the often- used data structure of linked lists. This presentation shows how to implement the most common operations on linked lists.
Advertisements

CSC211 Data Structures Lecture 9 Linked Lists Instructor: Prof. Xiaoyan Li Department of Computer Science Mount Holyoke College.
Chapter 12 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common approach to the.
Chapter 8 introduces the technique of recursive programming. As you have seen, recursive programming involves spotting smaller occurrences of a problem.
Container Classes A container class is a data type that is capable of holding a collection of items. In C++, container classes can be implemented as.
L l One of the tree applications in Chapter 9 is binary search trees. l l In Chapter 9, binary search trees are used to implement bags and sets. l l This.
 One of the tree applications in Chapter 10 is binary search trees.  In Chapter 10, binary search trees are used to implement bags and sets.  This presentation.
CSC212 Data Structure Lecture 14 Binary Search Trees Instructor: Prof. George Wolberg Department of Computer Science City College of New York.
 Chapter 2 introduces Object Oriented Programming.  OOP is a relatively new approach to programming which supports the creation of new data types and.
 Chapter 11 has several programming projects, including a project that uses heaps.  This presentation shows you what a heap is, and demonstrates two.
Chapter 1. The Phases of Software Development. Data Structure 2 Chapter outline  Objectives  Use Javadoc to write a method’s complete specification.
CSC212 Data Structure - Section AB Lecture 20 Hashing Instructor: Edgardo Molina Department of Computer Science City College of New York.
 Chapter 7 introduces the stack data type.  Several example applications of stacks are given in that chapter.  This presentation shows another use called.
P Chapter 6 introduces the stack data type. p Several example applications of stacks are given in that chapter. p This presentation shows another use called.
  Chapter 12 presents several common algorithms for sorting an array of integers.   Two slow but simple algorithms are Selectionsort and Insertionsort.
P p Chapter 10 has several programming projects, including a project that uses heaps. p p This presentation shows you what a heap is, and demonstrates.
CSC212 Data Structure - Section FG Lecture 21 Quadratic Sorting Instructor: Zhigang Zhu Department of Computer Science City College of New York.
 Chapter 10 introduces trees.  This presentation illustrates the simplest kind of trees: Complete Binary Trees. Complete Binary Trees Data Structures.
Copyright © 1999, Carnegie Mellon. All Rights Reserved. Chapter 12 presents several common algorithms for sorting an array of integers. Two slow but simple.
L l Chapter 11 discusses several ways of storing information in an array, and later searching for the information. l l Hash tables are a common approach.
 An important topic: preconditions and postconditions.  They are a method of specifying what a function accomplishes. Preconditions and Postconditions.
L l Chapter 4 introduces the often- used linked list data structures l l This presentation shows how to implement the most common operations on linked.
P Chapter 2 introduces Object Oriented Programming. p OOP is a relatively new approach to programming which supports the creation of new data types and.
 Chapter 8 introduces the queue data type.  Several example applications of queues are given in that chapter.  This presentation describes the queue.
Edgardo Molina, CSC212 Data Structures - Section AB Lecture 1: Introduction Instructor: Edgardo Molina Department of Computer Science City College.
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.
CS Fall 2007 Dr. Barbara Boucher Owens. CS 2 Text –Main, Michael. Data Structures & Other Objects in Java Third Edition Objectives –Master building.
Data Structures Chapter 1- Introduction Mohamed Mustaq.A.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
P An important topic: preconditions and postconditions. p They are a method of specifying what a function accomplishes. Preconditions and Postconditions.
 A Collection class is a data type that is capable of holding a group of items.  In Java, Collection classes can be implemented as a class, along with.
P An important topic: preconditions and postconditions. p They are a method of specifying what a function accomplishes. Illinois State University Department.
CSC211 Data Structures Lecture 20 Hashing Instructor: Prof. Xiaoyan Li Department of Computer Science Mount Holyoke College.
 An important topic: preconditions and postconditions.  They are a method of specifying what a method accomplishes. Preconditions and Postconditions.
CSC211 Data Structures Lecture 21 Quadratic Sorting Instructor: Prof. Xiaoyan Li Department of Computer Science Mount Holyoke College.
CSC211 Data Structures Lecture 18 Heaps and Priority Queues Instructor: Prof. Xiaoyan Li Department of Computer Science Mount Holyoke College.
P p Chapter 10 introduces trees. p p This presentation illustrates the simplest kind of trees: Complete Binary Trees. Complete Binary Trees Data Structures.
Container Classes  A container class is a data type that is capable of holding a collection of items.  In C++, container classes can be implemented as.
CSC212 Data Structure Lecture 16 Heaps and Priority Queues Instructor: George Wolberg Department of Computer Science City College of New York.
Xiaoyan Li CSC211 Data Structures Lecture 2 ADT and C++ Classes (I) Instructor: Prof. Xiaoyan Li Department of Computer Science Mount Holyoke College.
Zhigang Zhu, CSC212 Data Structure - Section FG Lecture 2 ADT and C++ Classes (I) Instructor: Zhigang Zhu Department of Computer Science City.
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.
Chapter 1 The Phases of Software Development. Software Development Phases ● Specification of the task ● Design of a solution ● Implementation of solution.
Chapter 1 The Phases of Software Development
Welcome to CSIS 10B Overview of Course Software Design (from Nyhoff)
Linked Lists in Action Chapter 5 introduces the often-used data public classure of linked lists. This presentation shows how to implement the most common.
Chapter 1 The Phases of Software Development
Collection Classes A Collection class is a data type that is capable of holding a group of items. In Java, Collection classes can be implemented as a class,
Using a Stack Chapter 6 introduces the stack data type.
Hash Tables Chapter 11 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common approach.
Using a Stack Chapter 6 introduces the stack data type.
Quadratic Sorting Chapter 12 presents several common algorithms for sorting an array of integers. Two slow but simple algorithms are Selectionsort and.
Heaps Chapter 10 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates two.
Heaps Chapter 10 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates two.
Using a Stack Chapter 6 introduces the stack data type.
Heaps Chapter 11 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates.
Preconditions and Postconditions
Using a Stack Chapter 6 introduces the stack data type.
Hash Tables Chapter 12 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common.
Hash Tables Chapter 11 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common approach.
Hash Tables Chapter 11 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common approach.
Using a Queue Chapter 8 introduces the queue data type.
Using a Queue Chapter 8 introduces the queue data type.
Preconditions and Postconditions
Heaps Chapter 10 has several programming projects, including a project that uses heaps. This presentation shows you what a heap is, and demonstrates two.
Hash Tables Chapter 11 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common approach.
Presentation transcript:

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 programming p A method of programming that emphasizes information hiding and component reuse

Phases of Software Development p Specification of the task p Design a solution p Implementation of the solution p Analysis of the solution p Testing/debugging the implementation p Maintenance and evolution of the system

Specifications p Requirements define the scope of the project p Resources specifies people, equipment, software, time, and money available p Specifications describe precisely what the software should do

Design p Describes how the software meets the specifications p Typically describes components of the software and how they interact

Implementation p Translating the design into a specified programming language(s) p Must follow style guidelines p Don’t change the design without going to a previous phase

Analysis p How well does the implementation meet the specifications p Sometimes referred to as validation

Testing and Debugging p Goal is to find bugs before user does p Alpha versus beta testing p Regression testing p Integration testing p Top-down versus bottom-up p Must consider p Boundary cases p Exceptional cases p Expected error cases

Lubarsky’s Law of Cybernetic Entomology There’s always one more bug!

Brook’s Law Adding more programmers to a late software project makes it later

Deadline-Dan’s Demon Every task takes twice as long as you think it will. If you double the time you think it will take, it will take 4 times as long.

Gilb’s 2 nd Law of Unreliability Any system that depends on human reliability is inherently unreliable.

p An important topic: preconditions and postconditions. p They are a method of specifying what a method accomplishes. Preconditions and Postconditions Data Structures and Other Objects Using Java

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

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

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

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

Example // Precondition: x >= 0. // Postcondition: The square root of x has // been written to the standard output. public void writeSqrt( double x)... } p The precondition and postcondition appear as comments in your program. p They are usually placed before the method’s implementation.

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

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

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

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

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

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

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

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

Another Example isVowel( '?' ); What values will be returned by these method calls ? Violating the precondition might even crash the program.

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

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

A Quiz Suppose that you call a method, 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 method ®Noah

A Quiz Suppose that you call a method, 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 method is responsible for ensuring that the precondition is valid. The programmer who calls a method is responsible for ensuring that the precondition is valid.

On the other hand, careful programmers also follow these rules: p When you write a method, you should make every effort to detect when a precondition has been violated. p 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: p When you write a method, you should make every effort to detect when a precondition has been violated. p If you detect that a precondition has been violated, then print an error message and halt the program... p...rather than causing a disaster. a disaster.

Example // Precondition: x >= 0. // Postcondition: The square root of x has // been written to the standard output. public void writeSqrt( double x) { if (x < 0) throw new IllegalArgumentException(“Negative x”);... p Throwing an exception(described in Section 1.1) is useful.

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

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

T HE E ND Presentation copyright 1999, Addison Wesley Longman For use with Data Structures and Other Objects Using Java by Michael Main. Some artwork in the presentation is used with permission from Presentation Task Force (copyright New Vision Technologies Inc.) and Corel Gallery Clipart Catalog (copyright Corel Corporation, 3G Graphics Inc., Archive Arts, Cartesia Software, Image Club Graphics Inc., One Mile Up Inc., TechPool Studios, Totem Graphics Inc.). Students and instructors who use Data Structures and Other Objects Using Java are welcome to use this presentation however they see fit, so long as this copyright notice remains intact.