software dev - midterm 2

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/47

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

48 Terms

1
New cards

method for debugging

  1. stabilize the error

  2. locate the source of the error

  3. fix the defect

  4. test the fix

  5. look for similar errors

2
New cards

stabilize the error

  • find a test case that reproduces the error each time executed

  • vary the test case to recognize which factor influences the error and which ones do not

  • simplify the test case to the smallest amount of factors, data, and functionality expected to produce the error

3
New cards

locate the source of the error

  • brainstorm to produce a set of hypothesis

  • create experiments, additional tests to obtain data to prove/disprove the hypothesis, and to locate the error

4
New cards

breakpoint

  • intentional stopping or pausing place in your code, set within a debugging tool

  • program executes normally until the breakpoint

  • suspends execution before that line of code runs

5
New cards

refactoring

the process of restructuring existing code to make it easier to make it cleaner and more efficient without changing its external behavior

6
New cards

extract method

a specific refactoring method where you take a chunk of code from a long method and move it into its own, new method

7
New cards

strategy to recover what a method is doing

  • identify what is used as input:

    • parameters

    • instance attributes/fields

    • static variables

  • Identify what is the overall effect, output of a method call

    • Identify all exit points and their return values

    • instance attributes/fields

    • static variables

8
New cards

class interface

  • a java interface that accompanies a class

  • set of public methods of a class

9
New cards

add comments

  • to clarify intent: what is code supposed to compute

  • to summarize code at a higher level of abstractions:

    • gives guidance to the reader where to find a particular feature

10
New cards

Steps in building a method

  • design the routine

  • check the design

  • code the routine

  • review and test the code

11
New cards
12
New cards

benefits of pseudocode

  • makes reviews easier

  • supports the idea of iterative refinement

  • makes changes easier (before coding)

  • minimizes commenting effort

  • easier to maintain than other forms of design documentation

13
New cards

pseudocode programming proccess

  1. check prerequisites

  2. name the method

  3. decide how to test the method

  4. check for existing solutions (reuse code, ideas)

  5. consider error handling

  6. consider efficiency (no premature optimzation)

  7. check for existing data types, algorithms

  8. think about the data (data types, what to store)

  9. write/refine description in pseudocode

  10. check/review pseudocode

14
New cards

coding: once you got the pseudocode

  • write the routine declaration

  • write the first and last statements, and turn the pseudocode into high level comments

  • fill in the code below each comment

  • check the code

  • clean up leftovers

15
New cards

static analysis

  • reads the code but never run sit

  • it can see what kind of input you expect, but not the actual value

16
New cards

McCabe's Cyclomatic Complexity

  • counts the total number of linearly independent paths through a program 

  • a path is a unique route code can take from start to end

  • a higher CC number means the code is more complex and has more branches

  • PMD: number of decision points plus one for method entry

    • 11+ is very high complexity

17
New cards

NPathComplexity

  • number of acyclic execution paths through that method

  • it is multiplicative

  • value >= 200: reduce complexity

18
New cards

ExcessiveMethodLength

  • indicates that the method is doing too much

    • reduce method size by creating helper methods, remove cp&paste code

19
New cards

ExcessiveParameterList

  • indicates that a new object should be created to wrap the numerous parameters, try to group the parameters together

20
New cards

ExcessiveClassLength

  • indicates that the class may be trying to do too much

  • try to break it down and reduce size to something more manageable

21
New cards

ExcessivePublicCount

large number of public methods/attributes indicates the class may need to be broken up to limit efforts for thoroughly testing it

22
New cards

TooManyFields

  • too many fields could be redesigned to have fewer fields, passibly through some nested object grouping of some of the info

23
New cards

Findbugs: correctness bug

  • an apparent coding mistake resulting in code that was not what the developer intended

  • strive for a low false positive rate

24
New cards

Findbugs: bad practice

  • violations of recommended and essential coding practice

  • ex: hash code and equals problems, cloneable idiom, dropped exceptations, serializable problems, and misuse of finalize

25
New cards

Findbugs: dodgy

  • code that is confusing, anomalous, or written in a way that leads itself to errors.

  • ex: dead local stores, switch fall through, unconfirmed casts, and redundant null check of value known to be null

26
New cards

PMD: SwitchDensity

measures the concentration of case statements within a switch block

27
New cards

PMD: CognitiveComplexity

  • adds a penalty for loops, conditionals, catch blocks, goto labels, break/continue to a label, and recursion

  • adds an increasing penalty for nested structures

  • use helper methods to fix

28
New cards

PMD: LawOfDemeter

  • a method should only call methods on its own class, objects, or parameters

  • chain of method calls is not ideal

29
New cards

test case

set in inputs, execution conditions + pass/fail criterion

30
New cards

unit testing

find errors by checking pieces (a single class, method) in isolation

31
New cards

integration testing

find errors by looking at pieces (classes, methods) when they work together

32
New cards

system testing

find errors when running the full system in its environment

33
New cards

regression testing

retest to see if code still works, passes tests it passed before changes were made

34
New cards

how errors are distributed across a code base

  • 80% of errors are found in 20% of a project’s classes or routines

  • 50% of the errors are found in 5% of a project’s classes

35
New cards

black box testing

  • focus: public interface

  • based on: sw requirements spec and interface docs

  • unaware of implementation details

  • particular strength: omission errors

  • test code doesn’t depend on implementation

36
New cards

white box testing

  • focus: source code

  • based on: sw requirements, interface docs + code

  • particular strength: can test complex pieces of code more rigorously

37
New cards

data can exist in 1 of 3 states

  • defined: data initialized but not used yet

  • used: data has been used for computation

  • killed: data was once defined, but is undefined now

38
New cards

equivalence partioning

  • partition parameter/value ranges into groups that would have the same effect

  • for each group create only one test case with a representative value chosen from the equivalence set

39
New cards

error guessing

based on past experience, tester guesses what cases the implementation may not handle correctly

40
New cards

boundary analysis

check cases around limits and extreme cases

41
New cards

bad data test cases includes

  • too little data

  • too much data

  • the wrong kind of data (invalid data)

  • wrong size of data

  • uninitialized data

42
New cards

good data test cases include

  • nominal cases-middle of the roat, expected values

  • minimum normal configuration

  • maximum normal configuration

  • compatibility with old data set

43
New cards

oracle

  • the mechanism that provides the pass/fail criterion for a test case

  • the source of truth that tells you what the correct, expected answer should be

44
New cards

control flow coverage criteria

  • statement (node, block) coverage

  • branch (edge) coverage

    • if/switch conditions

  • condition coverage

    • each basic condition evaluated to true and false (A && B && C)

  • path coverage (structured basis/cyclomatic testing)

    • execution paths through a method

  • data flow (syntactic dependency) coverage

    • define-used pairs of data

  • function coverage

45
New cards

Modified condition/decision coverage

  • requires that each basic condition be shown to be independently affecting the outcome of each decision

  • each variable must be shown to contain the power to flip the switch on its own, without help or interference from the others

  • The Method: Hold everything else constant. Flip the one variable. Does the output flip?

    • Yes: It independently affects the outcome.

    • No: It is being masked by another variable (or the logic is flawed).

46
New cards

statement coverage

measures the percentage of executable statements in your code that have been run at least once during testing

47
New cards

branch coverage

measures the percentage of decision outcomes (branches) that have been executed

48
New cards

condition coverage

requires that each individual boolean condition in a decision statement evaluates to both True and false at least once