Software Engineering Chapter09 Implementation [compatibility Mode]

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Software Engineering Chapter09 Implementation [compatibility Mode] as PDF for free.

More details

  • Words: 636
  • Pages: 16
Chapter 9 Implementation Lecturer Dr. Elfadil Abdalla College of Information Technology

1

Objectives • Describe – Characteristics of good implementations – Best practices to achieve them

• Understand role of comments • Learn debugging techniques • Analyze refactoring

2

Introduction • Implementation: transforming detailed design into valid program • Detailed design may be done as part of implementation – Faster – Less cohesive and less organized

• Writing code, unit testing, debugging, configuration management 3

Characteristics of a Good implementations • Readability – The code can easily be read and understood by other programmers

• Maintainability – The code can easily be modified and maintained

• Performance – All other things being equal, the implementation should perform as fast as possible

• Traceability – All code elements should correspond to a design element. Code can be traced back to design 4

Characteristics of a Good implementations (Cont.) • Correctness – The implementation should do what it is intended to do

• Completeness – All of the system requirements are met

• Other issues: – Relative importance ? – Tradeoffs ? 5

Programming Style and Coding guidelines • • • •

Organization-specific Important for consistency Programmers can get used to them easily Usually mandate: – Indenting, formatting – Naming conventions (for files, variables etc) – Language features to use or avoid

6

Style issues - I • Be consistent and highlight meaning • Naming – Convey meaning – Be consistent – Warning: If you can’t think of a good name chances are you don’t understand or the design can be improved – Multicultural issues 7

Style issues - II • Separating words, capitalization – c_uses_this_style – JavaUsesThisOne

• Indentation and Spacing • Function/Method size – When is it too big ? When to break ?

• File naming • Error prone constructs 8

Comments • Types: – Repeat of the code – Explanation of the code – Marker in the code – Summary of the code – Description of the code intent – External references

• Keep up to date !! 9

Debugging • Locating and fixing errors in code. • Errors noticed by testing, inspection, use. • Four phases – Stabilization (reproduction) • The purpose is to be able to reproduce the error on a particular configuration, and to find out the conditions led to the error by constructing a minimal test case.

10

Debugging (Cont.) – Localization • The process of localization involves finding the sections of the code that led to the error.

– Correction • It involves changing the code to fix error

– Verification – Making sure the error is fixed, and no other errors were introduced with changes in the code.

11

Debugging II • Heuristics: – – – –

Some routines will have many errors Routines with an error tend to have more New code tends to have more error Particular ones: languages, parts, coders

• Tools – – – – –

Code comparators Extended checkers (lint) Interactive debuggers Special libraries Others: Profilers, pre/post conditions, test coverage 12

Assertions • Pre-condition: condition your module requires in order to work • Post-condition: condition that should be true if your module worked • Assertion: Executable statement that checks a condition and produces an error if it is not met • Assertions supported by many languages 13

Performance optimization • Performance tradeoffs – Readability ? – Maintainability ?

• Correctness is usually more important • Profiler: runs a program and calculates how much time it spends on each part • Cost-benefit analysis • Measure before ‘optimizing’ 14

Refactoring • Improving your code style without affecting its behavior Bad Smells • Duplicated code • Long method • Large class • Switch statement • Feature envy • Intimacy 15

Refactoring (Cont.) Refactorings • Extract method • Substitute algorithm • Move method • Extract class

16

Related Documents