Unformatted text preview:

Software Testing and Maintenance Modifying Code Jeff Offutt SWE 437 George Mason University 2008 Thanks to Jeff Lei Susan Eisenbach Jonathan Hardwick and Rolf Howarth Programming for Maintainability 1 2 3 4 5 SWE 437 Software Testing and Maintenance Change Overview Understanding the Program Configuration Management Programming for Change Program Style Jeff Offutt 2 Maintenance vs Development Maintenance change must reflect the goals and style of the existing system Adding a new room costs more than adding a room in the first place We have to understand an existing system before changing it How to accommodate the change What are the potential ripple effects What skills and knowledge are required SWE 437 Software Testing and Maintenance Jeff Offutt 3 Major Maintenance Activities Change identification What to change why to change Program understanding How to make the change determining the ripple effect Carrying out the change and testing How to actually implement the change and ensure it is correct Configuration management How to manage and control the changes Management issues How to build a team SWE 437 Software Testing and Maintenance Jeff Offutt 4 Development Models Code and Fix Ad hoc not well defined Waterfall Sequential does not capture the evolutionary nature of software Spiral Heavily relies on risk assessment Iterative Incremental but constant changes may erode system architecture Jeff Offutt SWE 437 Software Testing and Maintenance 5 Code and Fix Model Problem Found Fix it SWE 437 Software Testing and Maintenance Jeff Offutt 6 Osborne s Waterfall Model Identification of need for change Change request submitted Requirements analysis Change request rejected approved Task scheduled Design analysis Design review Code modification Review of proposed change Testing Documentation update Standards audit cancellation User acceptance Post installation review of changes Task completed 7 Jeff Offutt SWE 437 Software Testing and Maintenance Boehm s Spiral Model Management decision Proposed changes Approved changes Change Implemented Evaluation Results New version Software in use SWE 437 Software Testing and Maintenance Jeff Offutt 8 Iterative Enhancement Model Analyze existing system Redesign current version and implement Characterize proposed modifications Jeff Offutt SWE 437 Software Testing and Maintenance 9 Maintenance Effort software maintenance effort Survey by Leintz and Swanson 1980 54 7 45 3 Non discretionary maintenance emergency fixes debugging changes to input data changes to hardware SWE 437 Software Testing and Maintenance Discretionary maintenance enhancements for users documentation improvement improving efficiency Jeff Offutt 10 Maintenance vs Development Effort Maintenance Effort Development analysis SWE 437 Software Testing and Maintenance specification design implementation testing operation Jeff Offutt 11 Programming for Maintainability 1 Change Overview Understanding the the Program Program 2 Understanding 3 Configuration Management 4 Programming for Change 5 Program Style SWE 437 Software Testing and Maintenance Jeff Offutt 12 What to Understand Problem Domain Capture domain knowledge from documentation end users or the program source Execution Behavior Input output relations knowledge of data flow control flow and core algorithms Cause Effect Relations How different parts affect and depend on each other Product Environment Relation How the product interacts with the environment Jeff Offutt SWE 437 Software Testing and Maintenance 13 Comprehension Process Read documentation Read the source code Run the program SWE 437 Software Testing and Maintenance Static analysis Dynamic analysis Jeff Offutt 14 Comprehension Process Knowledge base Expertise and background knowledge Mental model Encodes the current understanding Assimilation Obtain information from various sources Comprehension Strategies Top down Start with the big picture and then gradually work towards understanding the low level details Bottom up Start with low level semantic structures and then group them into high level more meaningful structures Opportunistic A combination of top down and bottom up SWE 437 Software Testing and Maintenance Jeff Offutt 15 Factors that Influence Understanding Expertise Domain knowledge programming skills Program structure Modularity level of nesting Documentation Readability accuracy up to date Coding conventions Naming style design patterns Comments Quality shall convey additional information Program presentation Good use of indentation and spacing SWE 437 Software Testing and Maintenance Jeff Offutt 16 Example of a Maintenance Task Small scale Illustrates the steps Quality measures Meyer Maintainability Efficiency Conciseness These measures are frequently in conflict Many C programmers short sightedly emphasize conciseness and efficiency over maintainability This increases future programmer cost Jeff Offutt SWE 437 Software Testing and Maintenance 17 Analysis Stage The parser should accept files with a for extension rather than files with f or F extensions Track down the C function responsible for validating the file names of input code using ls grep and vi Determine detailed changes needed Analysis Accept files ending with for Find the C function Decide what to change SWE 437 Software Testing and Maintenance Jeff Offutt 18 What Does This Code Do char Analysis c name s ft Accept files ending with for char s Find the C function char b s0 Decide what to change int c b s0 s while c s if c b s if s s0 3 s 2 c s f c F infname s0 Fatal filename must end in f or F s ft b copys b s c return b SWE 437 Software Testing and Maintenance Jeff Offutt 19 Looking at the Implementation What the program component does What is its role in the given change How the component performs its function How can we change it to perform its new role Why the component operates in the way it does Why is the system going to fall apart when you change this component SWE 437 Software Testing and Maintenance Jeff Offutt 20 What How Why What Function performs file name filtering Removes leading path names and replaces the first character of the suffix with the integer character held in ft How Expand the program into a more comprehensible pseudo C notation Why Look at the users of the result of the function Try to do preventative maintenance at the same time so future alterations will be easier Replace obscure code by either explicit code or comment it thoroughly Jeff Offutt SWE 437 Software Testing and


View Full Document

MASON SWE 437 - Modifying Code

Loading Unlocking...
Login

Join to view Modifying Code and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Modifying Code and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?