1 / 27

CS2006 - Data Structures I

CS2006 - Data Structures I. Chapter 2 Principles of Programming & Software Engineering. Topics. Software Life Cycle. Introduction. How do you write a Java program? Old fashion way Write code Compile Check syntax Run Check logic How long will this take? Which phase takes more time?.

efoley
Download Presentation

CS2006 - Data Structures I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS2006 - Data Structures I Chapter 2 Principles of Programming & Software Engineering

  2. Topics • Software Life Cycle

  3. Introduction • How do you write a Java program? • Old fashion way • Write code • Compile • Check syntax • Run • Check logic • How long will this take? • Which phase takes more time?

  4. Introduction • A better way • Systematic way (Structured approach) • Specify problem • Analyze • Design • Implement • Test • Maintain

  5. Introduction • SW Engineering: • Computer science branch that provides techniques for development of computer programs • Systematic approach to analyze, design, implement, and maintain software • Uses CASE tools

  6. The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing 7. Refining 8. Production 9. Maintainence

  7. 1. Specification & Analysis • Specification • A contract between the module and any other module using it • Doesn't include information about how the task is to be performed or the method of solution, but what • May involve construction of a prototype program to get more details from users.

  8. 1. Specification & Analysis • Example: • “begin & write a software to store a library’s catalogue of books” • Input: • Librians enter new books as they arrive • Library users enter search keys to search through our list

  9. 1. Specification & Analysis • Process: • Add new book • Search for books • Output: • Show all the info about a book • Requirements • What type of processing is required • Are there any time/space/performance constraints

  10. 2. Design • Given: • Clear & detailed specification of all aspects of the problem • Output: • Design for a solution to the problem • Idea: • Use modular design • Divide & conquer • Divide the problem into smaller manageable parts.

  11. 2. Design • Generate an outline of the problem solution. • Requires breaking the entire problem down into small manageable parts - modules. • Modules are self-contained units of code.

  12. 2. Design • Design Example: Sort Function • Purpose: • Sort an array of integers • Specification: • Receive an array of N integers (input), where N > 0 (assumption) • Return the array (output) with the integers sorted (action) • Remember: • Specification is a contract

  13. 2. Design • Design Example: Sort Function • First-draft specification: Sort(A, N) // Sorts an array // Precondition: A is an array of N integers; N > 0 // Postcondition:Integers in A are sorted • What is missing?

  14. 2. Design • Design Example: Sort Function • Revised Specification: Sort(A, N) // Sorts an array of MAX_ARRAY elements // Precondition: // A is an array of N integers; // and 1 <= N <= MAX_ARRAY, // where MAX_ARRAY is a global constant // that specifies the maximum size of A // Postcondition: // A [0] <= A [1] <= . . . <= A [N-1], // N is unchanged

  15. 3. Risk Analysis • Risks are primarily business related but can be personal as well. • Example: If a piece of software is not ready in time the company may lose the market to a competitor. • Not an important issue for this course.

  16. 4. Verification • Determining the degree to which a software product fulfills its specification • Formal, theoretical methods for proving algorithm correctness • Assertion (Predicate): • Statement about a particular condition at certain point in an algorithm • Invariant: • Condition that is always true at a certain point in an algorithm

  17. 5. Implementation (Coding) • Coding • Translating the algorithm into a particular programming language & removing syntax errors • Should not start unless previous stages are well defined • Original solution usually simplified

  18. A S1 S2 S3 5. Coding • Bottom-up implementation: • First implement submodules, then modules • Top-down implementation: • Implement a module before implementing its submodules • Use stubs • Refinement might be needed • Stubs: • Dummy functions that do nothing and are placed in the place of submodules to focus attention on the module itself

  19. 6. Testing • Careful design of test data is important • Valid (In-range) data • Invalid (out-of-range) data • Random values of data • Test several times on different circumstances • Any modification in the program needs re-testing

  20. 7. Refining the Solution • Usually involves increasing the "robustness" of a solution. • Often simplifying assumptions are made in the design process that must be removed from final versions. • Example: assume that the input will be be integers between 0 and 1000. • During this step code would be inserted to actually test the input values.

  21. 8. Production • Distribute the SW product to its intended users • Install the SW • Use the SW

  22. 9. Maintenance • Correct errors not discovered during testing • Add more features • Enhance existing features • Modify to suit the user better

  23. Review • The first phase of the life cycle of software is the ______ phase. • design • risk analysis • specification • coding

  24. Review • The syntax errors of a program are removed during the ______ phase of the program’s life cycle. • verification • coding • testing • refining • maintenance

  25. Review • Which of the following is an example of a logical error? • an algorithm that calculates the monthly payment of a loan displays incorrect results • an array subscript in a program goes out of range • a program expects a nonnegative number but reads –23 • the beginning of a while loop is written as “whille” instead of “while”

  26. Review • During the design phase of the software life cycle, the program is divided into ______. • invariants • loops • Modules • prototypes

  27. Review • A prototype program is created during the ______ phase of the software life cycle. • design • specification • Coding • testing

More Related