Pfleeger and Atlee, Software Engineering: Theory and Practice CS499 Chapter 7 Writing the Programs Shari L. Pfleeger Joann M. Atlee 4 th Edition.

Slides:



Advertisements
Similar presentations
ISBN Prentice-Hall, 2006 Chapter 7 Writing the Programs Copyright 2006 Pearson/Prentice Hall. All rights reserved.
Advertisements

ISBN Prentice-Hall, 2006 Unit 6 Writing the Programs Copyright 2006 Pearson/Prentice Hall. All rights reserved.
Lecture # 2 : Process Models
Chapter 2 Modeling the Process and Life Cycle Shari L. Pfleeger
Pfleeger and Atlee, Software Engineering: Theory and Practice CS499 Chapter 7 Writing the Programs Shari L. Pfleeger Joann M. Atlee 4 th Edition.
Program Slice Program slice was a concept first discussed by Mark Weiser in the early 1980’s –He especially noticed that when people debug, they trace.
Documentation 1 Comprehending the present – Investing in the future.
© Copyright 2011 John Wiley & Sons, Inc.
Chapter 1 4th Edition What is Software Engineering Shari L. Pfleeger
Detailed Design Kenneth M. Anderson Lecture 21
Jump to first page 1 System Design (Finalizing Design Specifications) Chapter 3d.
Understanding the Mainline Logical Flow Through a Program (continued)
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Lecturer: Dr. AJ Bieszczad Chapter 76-1 Software engineering standards Standards for you Standards for others Matching design with implementation.
Chapter 24 - Quality Management Lecture 1 1Chapter 24 Quality management.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
CH07: Writing the Programs Does not teach you how to program, but point out some software engineering practices that you should should keep in mind as.
Chapter 7 Software Engineering Objectives Understand the software life cycle. Describe the development process models.. Understand the concept of modularity.
1 Software Construction Software Construction Chapter 1.
CS 501: Software Engineering Fall 1999 Lecture 16 Verification and Validation.
Design-Making Projects Work (Chapter7) n Large Projects u Design often distinct from analysis or coding u Project takes weeks, months or years to create.
Software Engineering Management Lecture 1 The Software Process.
1 The Software Development Process  Systems analysis  Systems design  Implementation  Testing  Documentation  Evaluation  Maintenance.
SOFTWARE DESIGN (SWD) Instructor: Dr. Hany H. Ammar
Software Design Deriving a solution which satisfies software requirements.
Chapter 9 Testing the System Shari L. Pfleeger Joann M. Atlee
Software Development Cycle What is Software? Instructions (computer programs) that when executed provide desired function and performance Data structures.
SE: CHAPTER 7 Writing The Program
1 CSC 222: Computer Programming II Spring 2004 See online syllabus at: Course goals:
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
1 Systems Analysis and Design in a Changing World, Thursday, January 18, 2007.
Cohesion and Coupling CS 4311
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
UHD::3320::CH121 DESIGN PHASE Chapter 12. UHD::3320::CH122 Design Phase Two Aspects –Actions which operate on data –Data on which actions operate Two.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
Systems Analysis and Design in a Changing World, Fourth Edition
© 2006 ITT Educational Services Inc. SE350 System Analysis for Software Engineers: Unit 10 Slide 1 Chapter 13 Finalizing Design Specifications.
CMSC 345 Programming. Organization of Coding Process Select “core” to implement first, following an incremental development model Reconsider architectural.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
The Software Development Process
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Spreadsheet Engineering Builders use blueprints or plans – Without plans structures will fail to be effective Advanced planning in any sort of design can.
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.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
SOFTWARE ENGINEERING. Objectives Have a basic understanding of the origins of Software development, in particular the problems faced in the Software Crisis.
Design and Planning Or: What’s the next thing we should do for our project?
Chapter 16 Quality Assurance Through Software Engineering Systems Analysis and Design Kendall & Kendall Sixth Edition.
Software Engineering Issues Software Engineering Concepts System Specifications Procedural Design Object-Oriented Design System Testing.
Chapter 13 Finalizing Design Specifications
Agenda: Overview of Agile testing Difference between Agile and traditional Methodology Agile Development Methodologies Extreme Programming Test Driven.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
PPT07: Program Design LEILA CLAASSEN. Programming Standards PROGRAMS MAKE OUR LIVES EASIER; THEY ARE WRITTEN FOR PEOPLE BY PEOPLE, MOST OFTEN IN GROUPS.
1 Program Design: “Writing the Programs” CEN 4020 Software Engineering Kyle J. Test.
Software Design and Development Development Methodoligies Computing Science.
Coupling and Cohesion Schach, S, R. Object-Oriented and Classical Software Engineering. McGraw-Hill, 2002.
Coupling and Cohesion Pfleeger, S., Software Engineering Theory and Practice. Prentice Hall, 2001.
7. Modular and structured design
Chapter ? Quality Assessment
Software testing strategies 2
Chapter 5 Designing the Architecture Shari L. Pfleeger Joanne M. Atlee
Documentation for Developers
Chapter 7 Writing the Programs Shari L. Pfleeger Joann M. Atlee 4th Edition.
Software Design Lecture : 9.
PPT and video are due no later than March 1, 2019
Presentation transcript:

Pfleeger and Atlee, Software Engineering: Theory and Practice CS499 Chapter 7 Writing the Programs Shari L. Pfleeger Joann M. Atlee 4 th Edition

Pfleeger and Atlee, Software Engineering: Theory and Practice CS499 Contents 7.1 Programming Standards and Procedures 7.2 Programming Guidelines 7.3 Documentation 7.4 The Programming Process 7.5 Information System Example 7.6 Real Time Example 7.7 What this Chapter Means for You

Pfleeger and Atlee, Software Engineering: Theory and Practice CS499 Chapter 7 Objectives Standards for programming Guidelines for reuse Using design to frame the code Internal and external documentation

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Standards and Procedures Standards for you –methods of code documentation Standards for others –Integrators, maintainers, testers –Prologue documentation –Automated tools to identify dependencies Matching design with implementation –Low coupling, high cohesion, well-defined interfaces

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Standards and Procedures Sidebar 7.1 Programming Standards at Microsoft Allow flexibility to be creative and evolve product’s details in stages Flexibility does not preclude standards

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Control Structures Make the code easy to read Build the program from modular blocks Make the code not too specific, and not too general Use parameter names and comments to exhibit coupling among components Make the dependency among components visible

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Example of Control Structures Control skips around among the program’s statements benefit = minimum; if (age < 75) goto A; benefit = maximum; goto C; if (AGE < 65) goto B; if (AGE < 55) goto C; A:if (AGE < 65) goto B; benefit = benefit * bonus; goto C; B:if (age < 55) goto C; benefit = benefit * 1.5; C:next statement Rearrange the code if (age < 55) benefit = minimum; elseif (AGE < 65) benefit = minimum + bonus; elseif (AGE < 75) benefit = minimum * bonus; else benefit = maximum;

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Algorithms Common objective and concern: performance (speed) Efficiency may have hidden costs –cost to write the code faster –cost to test the code –cost to understand the code –cost to modify the code

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Data Structures Several techniques that used the structure of data to organize the program –keeping the program simple –using a data structure to determine a program structure

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Keep the Program Simple Example: Determining Federal Income Tax 1.For the first $10,000 of income, the tax is 10% 2.For the next $10,000 of income above $10,000, the tax is 12 percent 3.For the next $10,000 of income above $20,000, the tax is 15 percent 4.For the next $10,000 of income above $30,000, the tax is 18 percent 5.For any income above $40,000, the tax is 20 percent tax = 0. if (taxable_income == 0) goto EXIT; if (taxable_income > 10000) tax = tax ; else{ tax = tax +.10*taxable_income; goto EXIT; } if (taxable_income > 20000) tax = tax ; else{ tax = tax +.12*(taxable_income-10000): goto EXIT; } if (taxable_income > 30000) tax = tax ; else{ tax = tax +.15*(taxable_income-20000); goto EXIT; } if (taxable_income < 40000){ tax = tax +.18*(taxable_income-30000); goto EXIT; } else tax = tax *(taxable_income-40000); EXIT;

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Keep the Program Simple Example Define a tax table for each “bracket” of tax liability Simplified algorithm for (int i=2; level=1; i <= 5; i++) if (taxable_icome > bracket[i]) level = level + 1; tax= base[level]+percent[level] * (taxable_income - bracket[level]); BracketBasePercent , , , ,

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Data Structures Example: Rooted Tree Recursive data structure Graph composed of nodes and lines –Exactly one node as root –If the lines emanating from the root are erased, the resulting graph is a rooted tree

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines General Guidelines to Preserve Quality Localize input and output Employ pseudocode Revise and rewrite, rather than patch Reuse –Producer reuse: create components designed to be reused in future applications –Consumer reuse: reuse components initially developed for other projects

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Example of Pseudocode The design for a component of a text processing system states COMPONENT PARSE_LINE Read nest eighty characters. IF this is a continuation of the previous line, »Call CONTINUE ELSE determine command type ENDIF CASE of COMMAND_TYPE COMMAND_TYPE is paragraph: Call PARAGRAPH COMMAND_TYPE is indent : Call INDENT COMMAND_TYPE is skip line: Call SKIP_LINE COMMAND_TYPE is margin : Call MARGIN COMMAND_TYPE is new page : Call PAGE COMMAND_TYPE is double space : Call DOUBLE_SPACE COMMAND_TYPE is single space : Call SINGLE_SPACE COMMAND_TYPE is break : Call BREAK COMMAND_TYPE is anything else: Call ERROR ENDCASE

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Example of Pseudocode Intermediate pseudocode PARAGRAPH: Break line, flush line buffer. Advance one line between paragraph. If fewer than 2 line left on page, eject. Set line pointer to paragraph indent. INDENT: Break line, flush line buffer. Get indent parameter. Set line pointer to indent parameter, set left margin to indent. SKIP_LINE: Break line, flush line buffer. Get line parameter. Advance (parameter) lines or eject if not enough space left on current page. MARGIN: Break line, flush line buffer. Get margin parameter. Set line pointer to left margin. Set right margin to margin. PAGE: Break line, flush line buffer. Eject page. Set line pointer to left margin SOUBLE_SPACE: Set interline space to 2. SINGLE_SPACE: Set interline space to 1 BREAK: Break line, flush line buffer. Set pointer to left margin

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Example of Pseudocode Regrouped FIRST: PARAGRAPH, INDENT, SKIP_LINE, MARGIN, BREAK, PAGE: Break line, flush line buffer. SOUBLE_SPACE, SINGLE_SPACE : No break line, no flush line buffer. SECOND: INDENT, SKIP_LINE, MARGIN: Get parameter. PARAGRAPH, BREAK, PAGE, DOUBLE_SPACE, SINGLE_SPACE: No parameter needed. THIRD: PARAGRAPH, INDENT, SKIP_LINE, MARGIN, BREAK, PAGE: Set new line pointer. DOUBLE_SPACE, SINGLE_SPACE: New line pointer unchanged. FOURTH: Individual action taken

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Example of Pseudocode Final pseudocode INITIAL: Get parameter for indent, skip_line, margin. Set left margin to parameter for indent. Set temporary line pointer to left margin for all but paragraph; for paragraph, set to paragraph indent. LINE_BREAKS: If not (DOUBLE_SPACE or SINGLE_SPACE), break line, flush line buffer and set line pointer to temporary line pointer If 0 lines left on page, eject page and print page header. INDIVIDUAL CASES: INDENT, BREAK: do nothing. SKIP_LINE: skip parameter lines or eject PARAGRAPH: advance 1 line; if < 2 lines or page, eject. MARGIN: right_margin = parameter. DOUBLE_SPACE: interline_space = 2. SINGLE_SPACE: interline_space = 1; PAGE: eject page, print page header

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Consumer Reuse Four key characteristics to check about components to reuse –does the component perform the function or provide the data needed? –is it less modification than building the component from scratch? –is the component well-documented? –is there a complete record of the component’s test and revision history?

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Producer Reuse Several issues to keep in mind –make the components general –separate dependencies (to isolate sections likely to change) –keep the component interface general and well-defined –include information about any faults found and fixed –use clear naming conventions –document data structures and algorithms –keep the communication and error-handling sections separate and easy to modify

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Programming Guidelines Sidebar 7.2 Selecting Components for Reuse at Lucent Reuse Council –Created inventory of components –Formed matrix with the features of all past and planned projects –Met every week to make component selections, inspect design documentation, and monitor levels of reuse

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Documentation Internal documentation –header comment block –meaningful variable names and statement labels –other program comments –format to enhance understanding –document data (data dictionary) External documentation –describe the problem –describe the algorithm –describe the data

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Documentation Information Included in Header Comment Block What is the component called Who wrote the component Where the component fits in the general system design When the component was written and revised Why the component exists How the component uses its data structures, algorithms, and control

Pfleeger and Atlee, Software Engineering: Theory and Practice CS The Programming Process Programming as Problem-Solving Polya’s (1957) four distinct stages of finding a good solution –understanding the problem –devising plan –carrying out the plan –looking back

Pfleeger and Atlee, Software Engineering: Theory and Practice CS The Programming Process Extreme Programming Two types of participants –customers: who define the features using stories, describe detailed tests and assign priorities –programmers: who implement the stories

Pfleeger and Atlee, Software Engineering: Theory and Practice CS The Programming Process Pair Programming The driver or pilot: controlling the computer and writing the code The navigator: reviewing the driver’s code and providing feedback

Pfleeger and Atlee, Software Engineering: Theory and Practice CS The Programming Process Whither Programming? Documentation is still essential in agile- methods –Assist the developers in planning, as a roadmap –Helps describe key abstractions and defines system boundaries –Assists in communicating among team members

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Information System Example Piccadilly System Design Description Input: Opposition schedule For each Television company name, create Opposition company. For each Opposition schedule, Locate the Episode where Episode schedule date = Opposition transmission date AND Episode start time = Opposition transmission time Create instance of Opposition program Create the relationships Planning and Competing Output: List of Opposition programs Data dictionary description Opposition schedule = * Data flow *Television company name + {Opposition transmission date + Opposition transmission time + Opposition program name + (Opposition predicted rating)}

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Information System Example Piccadilly System’s Implementation Passing by value void Match:: calv(Episode episode_start_time) {first_advert = episode_start_time + increment; // The system makes a copy of Episode // and your program can use the values directly.} Passing by pointer void Match:: calp(Episode* episode) {episode->setStart (episode->getStart()); // This example passes a pointer to an instance of Episode. // Then the routine can invoke the services (such as setStart // and getStart) of Episode using the -> operator.} Passing by reference void Match:: calr(Episode& episode) {episode.setStart (episode.getStart()); // This example passes the address of Episode. // Then the routine can invoke the services (such as setStart // and getStart) of Episode using the. operator.}

Pfleeger and Atlee, Software Engineering: Theory and Practice CS Real-Time Example Ariane-5 Should have included an exception handler try {} catch (…..) { //attempt to patch up state //either satisfy postcondition or raise exception again}

Pfleeger and Atlee, Software Engineering: Theory and Practice CS What This Chapter Means for You Things to consider when writing a code –organizational standards and guidelines –reusing code from other projects –writing code to make it reusable on future projects –using the low-level design as an initial framework, and moving in several iterations from design to code