COMP61511 (Fall 2017) Software Engineering Concepts In Practice - - PowerPoint PPT Presentation

comp61511 fall 2017 software engineering concepts in
SMART_READER_LITE
LIVE PREVIEW

COMP61511 (Fall 2017) Software Engineering Concepts In Practice - - PowerPoint PPT Presentation

COMP61511 (Fall 2017) Software Engineering Concepts In Practice Week 4 Bijan Parsia & Christos Kotselidis < bijan.parsia christos.kotselidis , @manchester.ac.uk> (bug reports welcome!) 1 Whatever Works Primitive Technology:


slide-1
SLIDE 1

1

COMP61511 (Fall 2017) Software Engineering Concepts In Practice

Week 4

Bijan Parsia & Christos Kotselidis

< , @manchester.ac.uk> (bug reports welcome!) bijan.parsia christos.kotselidis

slide-2
SLIDE 2

2

Whatever Works

Primitive Technology: Tiled Roof Hut

slide-3
SLIDE 3

3.1

Preliminaries

slide-4
SLIDE 4

3.2

What Is Construction?

A definition: Software construction is the creation, assembly,

  • r

modification

  • f

executable programs typically via modification of the source code.

slide-5
SLIDE 5

3.3

Abstraction Hierarchy Of A System

Not the only formulation of such a hierarchy!

slide-6
SLIDE 6

3.4

Architecture Vs. Construction

slide-7
SLIDE 7

3.5

Coding As Problem Solving

Software engineering is problem solving Hence, the foundational nature of problem definition Writing or modifying code Is also a form of problem solving We hope smaller problems. Pro tip: Always know the problem you're solving!

slide-8
SLIDE 8

3.6

The Big Four (Plus Two)

Four primary activities

  • 1. Creating

We need functionality

  • 2. Debugging

We need correctness

  • 3. Refactoring (last week!)

We need comprehensibility

  • 4. Optimising

We need efficiency (wrt to some resource) Plus two Testing & Reading

slide-9
SLIDE 9

3.7

Testing Is Everywhere

All primary activities involve testing Whether formal or informal E.g., Creation (whether test first or not)

slide-10
SLIDE 10

3.8

Reading Is Everywhere

Reading code is a key skill Other people's code that you are using that you are modifying Your own code! whether using or modifying "Reading" (understanding) systems is a key skill Grasping the problem , requirements, architecture Relating code to those

slide-11
SLIDE 11

3.9

10 lines of code = 10 issues. 500 lines of code = "looks fine." Code reviews.

10:58 AM - Nov 5, 2013

106 8,033 4,409 I Am Devloper

​@iamdevloper Follow

Reviews

slide-12
SLIDE 12

4.1

Creation

Mindset

slide-13
SLIDE 13

4.2

What Is (Code) Creation?

Code creation (or coding) is the addition of new functionality by the generation of new code and units of code Key activity! Often directly measured Productivity as LOC/day (Though, deleting code might be better!) Does not have to be ex nihilo Cut-paste-modify reuse counts Reuse counts!

slide-14
SLIDE 14

4.3

Prerequisites

Remember the ! What's your overall problem definition What part are you tackling What are the pertinent requirements Understand the architecture And how your current code fits in Know the local standards E.g., code formatting style prerequisites

slide-15
SLIDE 15

4.4

Architecture

A good architecture should:

  • 1. help you determine where your code should go
  • 2. constrain how functionality is divvyed up
  • 3. determine your communication channels
  • 4. give you a sense of things fitting together

that is shared Code-Architecture conflicts indicate A problem with one or the other A limit

slide-16
SLIDE 16

4.5

Technology Choices

Different technology choices affect code Language Mono- vs. poly-glot Typing regime "Batteries" Mindshare etc. Frameworks, libraries, OSs, etc.

slide-17
SLIDE 17

4.6

Tools

Development environments Editors IDEs Source control Dynamic tools Compilers Debuggers & Testers Profilers Static tools Lint, syntax, style checkers etc.

slide-18
SLIDE 18

4.7

Awarenesses

Situational Awareness Your perception of the current pertinent factors for decision making Good situational awareness Tracks all pertinent factors to the right degree in a manner to drive appropraite reactions at low cost Drives tactics and thus action Understanding Your systematic grasp of all factors related to decision making Results from sensemaking More cognitive (indirectly drives action)

slide-19
SLIDE 19

4.8

Getting In The Zone

Given a problem, our solving can be focused we have tight situational awareness the "situation" is the problem and solution space we react rather than act unfocused

  • ur awareness is scattered

distracted/multitasking disengaged confused The "zone" is a much higher productivity state

slide-20
SLIDE 20

4.9

Admin

Record-keeping is extremely helpful And sometimes required, e.g., billable hours Tracking helps! (a lot can be automated) Time Effort (and sense of effort) What was done (and why, by whome) Mood Discussions and decisions Some is better than none; enough is better still; there is too much

slide-21
SLIDE 21

4.10

Programmer Credos

Three Virtues

According to Larry Wall(1), the original author of the Perl programming language, there are three great virtues of a programmer; Laziness, Impatience and Hubris

  • 1. Laziness: The quality that makes you go to great effort

to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful and document what you wrote so you don't have to answer so many questions about it.

  • 2. Impatience: The anger you feel when the computer is

being lazy. This makes you write programs that don't just react to your needs, but actually anticipate them. Or at least pretend to.

  • 3. Hubris: The quality that makes you write (and

maintain) programs that other people won't want to say bad things about.

(1) Quoted from "Programming Perl", 2nd Edition, O'Reilly & Associates, 1996

slide-22
SLIDE 22

5.1

Debugging

—Grace Hopper's Bug Report

slide-23
SLIDE 23

5.2

Defects Again

Recall: A defect in a software system is a quality level (for some quality) that is not acceptable. We focus on defects primarily Though robustness is also key More stability, i.e., doesn't crash functional Correctness

slide-24
SLIDE 24

5.3

What Is Debugging?

Debugging is the modification of code to remove (or mitigate) correctness defects. We don't count missing functionality defects Debugging starts after a purported detection Input: a result of testing or a bug report We allow mitigation Not properly fixing the bug But enough so it's less damaging Must still involve code modification Other workarounds don't count!

slide-25
SLIDE 25

5.4

Functional Landscape (Enhanced)

slide-26
SLIDE 26

5.5

Debug Cycle

Input: An indication of a defect Stabilise — Make reliabily repeatable Isolate (or localise) — To the smallest unit Explain — What's wrong with the code Repair — Replace the broken code Test — Verify the fix Check for Regressions Masked bugs Nearby bugs

slide-27
SLIDE 27

5.6

Indication

An indication of a defect is a tangible record of a behaviour contrary to the (explicit or implicit) functional specification in a designated situation. Key parts: Situation Preferably, sufficiently described for replication Expected Behaviour Witnessed Behaviour Typically with some explanation why it's wrong Often very vague

slide-28
SLIDE 28

5.7

Indication?

Often very vague Program crashed sometime during this test Actually, only on ! Open Office on Ubuntu won't print Tuesdays From John Regehr, " " Classic Bug Reports

slide-29
SLIDE 29

5.8

Stabilise

Bugs are often very situation dependent Precise input + state OS, hardware Sequence of actions Length of operating A stabilsed bug is reliably repeatable preferrably with minimal sufficient conditions

slide-30
SLIDE 30

5.9

Isolate (Localise)

Bugs are often very local Single LOC Single routine Particular class They don't have to be! Communication points are vulnerable A defect is isolated if you have identified the minimum subsystem necessary to exhibit the defect for an trigger input and situtation

slide-31
SLIDE 31

5.10

Explain & Repair

Explaining the bug You can articulate the mechanism of the bug Your bug theory You can manipulate the bug Trigger or avoid it Produce variants Predict its behaviour Fix it Repairing the bug Modifying the code so the defect is eliminated May not be possible!

slide-32
SLIDE 32

5.11

Test

Post fix You need to verify Your theory Your *execution of the fix You need to guard against Unintended consequences! "New" bugs arise Bugs in the fix The fix is incomplete The fix triggers a regression Masked bugs

slide-33
SLIDE 33

5.12

Check Nearby

Bugs come in families Similar mistakes You did it once, you might have done it twice Persistent misunderstanding with multiple manifestations Clustered mistakes Some bugs hidden A crash conceals much Some routines are broken Lots of debt! A bug is a predictor of more bugs!

slide-34
SLIDE 34

5.13

Bug Reports To WONTFIX

Sometimes, a fix isn't going to happen The bug is too small Or insignificant Or ambiguous The bug is too big It would change too much behavior Which some people rely on Other debt increases the risk The but is too hard

slide-35
SLIDE 35

6.1

Optimising

slide-36
SLIDE 36

6.2

Resources

Size Running space At all levesl Persistence and transmission Code Time Response vs. thourghput Instant vs. Overall Wall/CPU Time/Instructions

slide-37
SLIDE 37

6.3

What Is Optimisation?

Optmisiation is a transformation of code into sufficiently functionally equivalent code that has "better" resource utilisation. "Sufficiently functionally equivalent" User observable/desirable behaviour is preserved Up to some point It may be specialised to a certain particular scenario Resource utilisation Type and Pattern must be specified

slide-38
SLIDE 38

6.4

Where?

slide-39
SLIDE 39

6.5

Tuning Trade-Offs

Time for Space (and the reverse) Performance for Readability (and the reverse) And other comprehension qualities Not always a trade off for algorithmic improvements Or fat removal Performance for Correctness Performance for Cost

slide-40
SLIDE 40

6.6

Tuning Alternatives

Buy More and Faster Hardware Use the Optimiser Better compilers/frameworks/libraries Input manipulation "It's slow when I do this" "Don't do that!"

slide-41
SLIDE 41

6.7

Tuning Safety

Tuning is risky Even optimisation can be risky! It's easy to make code fast By making it incorrect It's easy to modify the code a lot And not improve performance much Or make worse

slide-42
SLIDE 42

6.8

Tuning As (Performance) Debugging

Input: An indication of a performance defect Stabilise — Make reliabily repeatable Isolate (or localise) — To the smallest unit USE A PROFILER! TEST CASES ARE CRITICAL Explain — What's wrong with the code Repair — Replace the "slow" code Test — Verify the improvements Check for Sufficiency (Was that enough?) Trade-offs (e.g., space consumption) (Correctness) Bugs

slide-43
SLIDE 43

7

Complexity

Slides

slide-44
SLIDE 44

8.1

Boehm's Evidence

Following slides derived from Making Software, Chapter 10

slide-45
SLIDE 45

8.2

Reading Papers

These papers are challenging! Even massaged a bit for the practitioner Lots of technical jargon and techniques Summarizing a vast literature Challenging stats and presentations Don't panic! These are read and reread First reading should focus on key points Later readings should focus on the evidence

slide-46
SLIDE 46

8.3

The Role Of Architecture

Key challenge (Boehm, Making Software, Chp 10) How much should you invest in architecture? Analogy to building We pay the architect 10% of the cost of a building We should spend 10% of the project budget on architecture Is this enough? How would we know? Note: statistically general conclusions may not apply in your case!

slide-47
SLIDE 47

8.4

Bohem's Research Questions:

"By how much should you expect the cost of making changes or fixing defects to increase as a function of project time or product size?" "How much should you invest in early architecting and evidence-based project reviews before proceeding into product development?"

slide-48
SLIDE 48

8.5

Economies

Commodity manufacturing exhibits economies of scale Making 1 chip may be much more expensive than 1000 The unit cost diminishes as the number of units increases Software end-unit costs are (can be) zero Cheap to make a copy! Installation & configuration may not be So focus on lines of code or bits of functionality Software exhibits diseconomies of scale The unit cost rises as the number of units increases Potentially exponential! Pgs 166-167 esp. useful

slide-49
SLIDE 49

8.6

Cost Ratios

What's the ratio of cost to fix early vs. late? 1970s 1 in requirements to ≈100 post delivery 1981 1:100 for large code bases But 1:5 for small (2,000-5,000 LOC) 1996 survey (70-125):1 2000s Some evidence of reduction from 1:100 to 1:20 Or even flat (for 1 million line code base)

slide-50
SLIDE 50

8.7

Cost Ratios (For Coursework!)

What's the ratio of cost to fix early vs. late? Think of your coursework! Before deployment (aka submission) Small fixes are cheap

  • Esp. in the currency of the course, i.e., points

After deployment (aka submission) Even "small" fixes are expensive (or impossible) Coursework builds over the semester! So problems can build up

slide-51
SLIDE 51

8.8

Two Strategies

Avoid late bugs Make fixing late bugs cheaper Failure to do both kills the project Failure to do one may be mitigated by the other All our activities should aim for this Thus we want architectures that preclude some bugs confine the effects of all bugs

slide-52
SLIDE 52

8.9

Two Architecture Breakers (Pg 376)

"20% of the defects account for 80% of the costs" "these 20% are...due to inadequate architecture..." Two sorts of costs Direct costs Opportunity costs Two example big failures the OS architecture didn't support fail-over when processors failed lacked a key functionality assuming all messages are short thus borking on 1 million character messages

slide-53
SLIDE 53

8.10

Trade Offs

More up front arch Costs! Runs risk of overruns Since less time for everything else Potentially, getting arch right Reduces rework time Note, changing requirements can kill getting it right

slide-54
SLIDE 54

8.11

Sweet Spots

slide-55
SLIDE 55

8.12

Summary (Pg 403)

"...the greater the project's size, criticality, and stability, the greater the need for validated architecture feasibility evidence. "very very small low-criticality projects with high volatility, the architecting efforts make little difference" Note: There are other cost drivers; check the assumptions!

slide-56
SLIDE 56

9.1

Creation

Classes

slide-57
SLIDE 57

9.2

Margaret Hamilton

Next to the Apollo project navigation software code

slide-58
SLIDE 58

9.3

Abstract Data Types (1)

A datatype is a set of values with associated operations An abstract datatype is a datatype characterised entirely by the operations independent of implementation details A concrete datatype (or implementation of an ADT) is a representation of a set of values with particular implementations of the operations

slide-59
SLIDE 59

9.4

ADT Example: Lists

slide-60
SLIDE 60

9.5

ADT Example: Integers

Integers Abstract Values: All (or finate subsets of) integers Operations: +,-,*,/,<,=,> Concrete (representation) 32 bit 2s-complement or 64 bit 2s-complement or arrays or floats (Javascript) or

slide-61
SLIDE 61

9.6

ADT Example: Databases

CRUD Create-Read-Update-Delete Very abstract! Some Mappings (from ): Operation SQL HTTP DDS Create / write Read (Retrieve) read / take Update (Modify) / write Delete (Destroy) dispose Wikipedia INSERT PUT POST SELECT GET UPDATE PUT PATCH DELETE DELETE

slide-62
SLIDE 62

9.7

Why ADTs?

Separate interface and implementation The client only needs to think about the interface Up to a point! Abstractions leak Simpler and clearer Focuses on the semantics of the type Tells you the critical functionality

slide-63
SLIDE 63

9.8

Units Of Creation

A code unit is a syntactically complete(able) chunk of a program that enacts some behavior. Line of Code Block or control structure Routines/procedures/functions/methods/operations Classes/modules Packages/modules Individual routines and classes are what get unit tested