Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Quality Engineering

Similar presentations


Presentation on theme: "Software Quality Engineering"— Presentation transcript:

1 Software Quality Engineering
Lecture # 8

2 SQA Goals Requirements quality. The correctness, completeness, and consistency of the requirements model will have a strong influence on the quality of all work products that follow. Design quality. Every element of the design model should be assessed by the software team to ensure that it exhibits high quality and that the design itself conforms to requirements. Code quality. Source code and related work products (e.g., other descriptive information) must conform to local coding standards and exhibit characteristics that will facilitate maintainability. Quality control effectiveness. A software team should apply limited resources in a way that has the highest likelihood of achieving a high quality result.

3 Code Review helps Safety from bugs Easy to understand Ready for change
Improve code Improve programmer

4 Code Review Potential bugs Repetitive code
Disagreement between code and specification. Global variables, and other too-large variable scopes. Optimistic, un-defensive programming. Magic numbers.

5 Code Review Unclear, messy code. Bad variable or method names.
Inconsistent indentation. Convoluted control flow (if and while statements) that could be simplified. Packing too much into one line of code, or too much into one method. Failing to comment obscure code. Having too many trivial comments that are simply redundant with the code. Variables used for more than one purpose.

6 Code Review Misunderstandings of language Misuse of == or .equals() .
Misuse of arrays or List s.

7 Example int[] a = new int[100]; int i = 0; int n = 3; while (n != 1) {
a[i] = n; i++; if (n % 2 == 0) { n = n / 2; } else { n = 3 * n + 1; } a[i] = n; i++;

8 Code Review Misusing (or failing to use) essential design concepts.
Incomplete or incorrect specification for a method or class. Representation exposure for a data abstraction. Immutable datatypes that expose themselves to change. Invariants that aren’t really invariant, or aren’t even stated. Positive comments are also a good thing. Don’t be afraid to make comments about things you really like, for example

9 Code review guidelines
Style Standards Don’t Repeat Yourself (DRY) Comments where needed Fail fast Avoid magic numbers One purpose for each variable Use good names No global variables Return results, don’t print them Use whitespace for readability

10 Code Review Guidelines
All divisors should be tested for zero or garbage value. Always remove unused lines of the source code. Minimize the module coupling and maximize the module strength. All loops, branches and logic constructs should be complete, correct and properly nested and also avoid deep nesting. Complex algorithms should be thoroughly explained. Always ensure that loops iterate the correct number of times. When memory is not required, it is essential to make it free.

11 Code Review Guidelines
Release all allocated memory and resources after the usage. Stack space should be available for running a recursive function. Generally, it is better to write iterative functions. Do not reinvent the wheel. Use existing source code as much as possible. However, do not over-rely on this source code during testing. This portion should also be tested thoroughly.

12 Example public static int dayOfYear(int month, int dayOfMonth, int year) { if (month == 2) { dayOfMonth += 31; } else if (month == 3) { dayOfMonth += 59; } else if (month == 4) { dayOfMonth += 90; } else if (month == 5) { dayOfMonth += ; } else if (month == 6) { dayOfMonth += ; } else if (month == 7) { dayOfMonth += ; } else if (month == 8) { dayOfMonth += ; } else if (month == 9) { dayOfMonth += ; } else if (month == 10) { dayOfMonth += ; } else if (month == 11) { dayOfMonth += ; } else if (month == 12) { dayOfMonth += ; } return dayOfMonth;

13 Example public class Hailstone { /** * Compute a hailstone sequence.
n Starting number for sequence. Assumes n > 0. hailstone sequence starting with n and ending with 1. */ public static List<Integer> hailstoneSequence(int n) { List<Integer> list = new ArrayList<Integer>(); while (n != 1) { list.add(n); if (n % 2 == 0) { n = n / 2; } else{ n = 3 * n + 1; } return list;

14 Example public static int LONG_WORD_LENGTH = 5;
public static String longestWord; public static void countLongWords(List<String> words) { int n = 0; longestWord = ""; for (String word: words) { if (word.length() > LONG_WORD_LENGTH) ++n; if (word.length() > longestWord.length()) longestWord = word; } System.out.println(n);

15 Code Review Checklist

16 References Software testing by Yogesh Singh Various other sources


Download ppt "Software Quality Engineering"

Similar presentations


Ads by Google