SOEN6461: Software Design Methodologies Yann-Gal Guhneuc A brief - - PowerPoint PPT Presentation

soen6461 software design methodologies
SMART_READER_LITE
LIVE PREVIEW

SOEN6461: Software Design Methodologies Yann-Gal Guhneuc A brief - - PowerPoint PPT Presentation

SOEN6461: Software Design Methodologies Yann-Gal Guhneuc A brief introduction to software engineering This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 3.0 Unported License Outline Definition


slide-1
SLIDE 1

Yann-Gaël Guéhéneuc

This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 3.0 Unported License

SOEN6461: Software Design Methodologies

A brief introduction to software engineering

slide-2
SLIDE 2

2/110

Outline

 Definition

– Development – Operation – Maintenance – Systematic

  • Agile
  • TDD
  • Oracles

– Disciplined

  • Sub-disciplines
  • Laws
  • Principles
  • Best practices

– Quantifiable

 Conclusion

slide-3
SLIDE 3

3/110

Outline

 Definition

– Development – Operation – Maintenance – Systematic

  • Agile
  • TDD
  • Oracles

– Disciplined

  • Sub-disciplines
  • Laws
  • Principles
  • Best practices

– Quantifiable

 Conclusion

slide-4
SLIDE 4

4/110

Definition

 Software engineering (SE) is the application

  • f a systematic, disciplined, quantifiable

approach to the design, development,

  • peration, and maintenance of software

 SE is also the study of these approaches  SE is the application of engineering to

software

slide-5
SLIDE 5

5/110

Definition

 Software engineering (SE) is the application

  • f a systematic, disciplined, quantifiable

approach to the design, development,

  • peration, and maintenance of software

 SE is also the study of these approaches  SE is the application of engineering to

software

slide-6
SLIDE 6

6/110

Definition

 Design, development, operation, and

maintenance of software

 All activities to deliver and maintain a

software systems

– Include requirements engineering

slide-7
SLIDE 7

7/110

Definition

 SE is all about problem solving

slide-8
SLIDE 8

8/110

Definition

 SE is all about problem solving

Each “section” is introduced with a pair problem/solution

slide-9
SLIDE 9

9/110

Definition

 SE is all about problem solving

Each “section” is introduced with a pair problem/solution

Problem: Solution:

slide-10
SLIDE 10

10/110

Definition

 SE is also all about information hiding and

abstraction

“It’ one of those scientific simplifications: we’ll ignore the whole rest of the problem and just examine this particular aspect of it.” —Larry Wall (creator of Perl, in Masterminds of Programming) – Risk reduction vs. risk sharing/transfer

slide-11
SLIDE 11

11/110

Outline

 Definition

– Development – Operation – Maintenance – Systematic

  • Agile
  • TDD
  • Oracles

– Disciplined

  • Sub-disciplines
  • Laws
  • Principles
  • Best practices

– Quantifiable

 Conclusion

slide-12
SLIDE 12

12/110

Definition

 Software engineering (SE) is the application

  • f a systematic, disciplined, quantifiable

approach to the design, development,

  • peration, and maintenance of software

 SE is also the study of these approaches  SE is the application of engineering to

software

slide-13
SLIDE 13

13/110

Systematic

“Thoroughness and regularity” —Merriam-Webster

slide-14
SLIDE 14

14/110

Systematic

“Thoroughness and regularity” —Merriam-Webster

Problem: how to perform development systematically? Solution: use a well-defined, repeatable process

slide-15
SLIDE 15

15/110

Systematic

 Reuse known architectures, designs, and

implementation

– E.g., pipeline architecture, design patterns, sort algorithms

 Know the “tools of the trade”, learn new tools

slide-16
SLIDE 16

16/110

Systematic

 Tools of the trade

– Hardware systems – Operating systems – Virtual machines – Programming languages – Algorithms and data structures – Libraries – Design patterns – Architecture types

slide-17
SLIDE 17

17/110

Systematic

 Tools of the trade

– Hardware systems – Operating systems – Virtual machines – Programming languages – Algorithms and data structures – Libraries – Design patterns – Architecture types

slide-18
SLIDE 18

18/110

Systematic

 Processes

– Waterfall – Spiral – Iterative and incremental – Agile – RAD – Code and fix

slide-19
SLIDE 19

19/110

Systematic

 Processes

– Waterfall – Spiral – Iterative and incremental – Agile – RAD – Code and fix

slide-20
SLIDE 20

20/110

Outline

 Definition

– Development – Operation – Maintenance – Systematic

  • Agile
  • TDD
  • Oracles

– Disciplined

  • Sub-disciplines
  • Laws
  • Principles
  • Best practices

– Quantifiable

 Conclusion

slide-21
SLIDE 21

21/110

Systematic

 Agile development

– Make it work

  • Tests
  • Quickly

– Make it right

  • Tests
  • Quickly

– Make it fast

  • No early optimisation
slide-22
SLIDE 22

22/110

Systematic

slide-23
SLIDE 23

23/110

Systematic

slide-24
SLIDE 24

24/110

Systematic

“I am 90% done!”

—All developers (when they are late)

slide-25
SLIDE 25

25/110

Systematic

“I am 90% done!”

—All developers (when they are late)

Problem: how to measure success? Solution: use explicit, repeatable criteria

slide-26
SLIDE 26

26/110

Systematic

 Agile development

– Test Driven Development (TDD)

  • Tests as criteria for completion
slide-27
SLIDE 27

27/110

Systematic

 Agile development

– Test Driven Development (TDD)

  • Tests as criteria for completion
slide-28
SLIDE 28

28/110

Systematic

 Agile development

– Test Driven Development (TDD)

  • Tests as criteria for completion
slide-29
SLIDE 29

29/110

Systematic

 Agile development

– Test Driven Development (TDD)

  • Tests as criteria for completion
  • Documentation
slide-30
SLIDE 30

30/110

Systematic

 Agile development

– Test Driven Development (TDD)

  • Tests as criteria for completion
  • Documentation
  • Re-documentation of legacy code
slide-31
SLIDE 31

31/110

Systematic

 Agile development

– Test Driven Development (TDD)

  • Tests as criteria for completion
  • Documentation
  • Re-documentation of legacy code
  • Program understanding
slide-32
SLIDE 32

32/110

Systematic

 Agile development

– Test Driven Development (TDD)

  • Tests as criteria for completion
  • Documentation
  • Re-documentation of legacy code
  • Program understanding
  • Reusability and packaging
slide-33
SLIDE 33

33/110

Outline

 Definition

– Development – Operation – Maintenance – Systematic

  • Agile
  • TDD
  • Oracles

– Disciplined

  • Sub-disciplines
  • Laws
  • Principles
  • Best practices

– Quantifiable

 Conclusion

slide-34
SLIDE 34

34/110

Systematic

 Testing

– Existing data shows that more, not less, testing is needed for OO systems

  • OO has specific constructs that we must be taken into

account during testing

– Unit and integration testing are especially affected as they are more driven by the structure of the system under test

slide-35
SLIDE 35

35/110

Systematic

 Testing

– Procedural programming

  • Basic component: function (procedure)
  • Testing method: based on input/output relation

– Not withstanding the problem of global variables (if any)

slide-36
SLIDE 36

36/110

Systematic

 Testing

– Object oriented programming

  • Basic component: classes

– Data members (state) + sets of methods

  • Objects (instances of classes) are tested
  • Correctness is not only the input/output relation:

it also includes the object state

– The state is not directly accessible

  • Only accessible using public methods
slide-37
SLIDE 37

37/110

Systematic

class Watcher { private: ... int status; ... public: void check_pressure() { ... if (status == 1) ... else if (status ...) ... ... } ... }

slide-38
SLIDE 38

38/110

Systematic

 Testing method check_pressure() in

isolation is meaningless

– The value produced by method check_pressure() depends on the state of class Watcher instances (variable status) – Failures due to incorrect values of variable status can be revealed only with tests that have control and visibility on that variable

slide-39
SLIDE 39

39/110

Systematic

 Moreover, there could be a

– Wrong instance of method inherited in the presence of multiple inheritance – Wrong redefinition of an attribute / data member – Wrong instance of the method called due to dynamic binding and type errors

slide-40
SLIDE 40

40/110

Systematic

 Testing

– Procedural programs – Object-oriented programs

Requires that

– We can build oracle and write tests to give us confidence in the built software systems

slide-41
SLIDE 41

41/110

Outline

 Definition

– Development – Operation – Maintenance – Systematic

  • Agile
  • TDD
  • Oracles

– Disciplined

  • Sub-disciplines
  • Laws
  • Principles
  • Best practices

– Quantifiable

 Conclusion

slide-42
SLIDE 42

42/110

Systematic

 Oracle

– Classical Antiquity (e.g., Ancient Greece, above) – Shamanism (e.g., Korea, right)

slide-43
SLIDE 43

43/110

Systematic

 Oracle

– Or more “recently” in

slide-44
SLIDE 44

44/110

Systematic

 Oracles

– Determine the output that a software component should have for some given input (and possibly some state)

  • Method post-conditions

“When I call this method on that object, I expect this return value”

slide-45
SLIDE 45

45/110

Systematic

 Oracles depend on the abstraction level of

the tests being written

 Abstraction levels with procedural

programming languages

– Basic component: function (procedure) – Testing method: based on input/output relation

  • Not withstanding the problem of global variables
slide-46
SLIDE 46

46/110

Systematic

 Creating oracles is more difficult in object-

  • riented programming than procedural

programming

– The value produced by method check_pressure() depends on the state of class Watcher instances (variable status) – Failures due to incorrect values of variable status can be revealed only with tests that have control and visibility on that variable

slide-47
SLIDE 47

47/110

Systematic

 New abstraction levels with object-oriented

programming languages

– Basic unit testing: testing of a single method

(Intra-method testing)

– Unit testing: testing of a class

(Intra-class testing)

– Integration testing: testing of the interactions among classes

(Inter-class testing)

  • Associations, aggregations, specialisations…
slide-48
SLIDE 48

48/110

Systematic

public void testACAIC() { final IFirstClassEntity firstClassEntity = (IFirstClassEntity) modelForCouplingCohesion .getTopLevelEntityFromID("pom.test.rsc.G2"); Assert.assertEquals( "Computing ACAIC on G2", 7d, metrics.compute("ACAIC", firstClassEntity), 0); }

slide-49
SLIDE 49

49/110

Systematic

public void testACAIC() { final IFirstClassEntity firstClassEntity = (IFirstClassEntity) modelForCouplingCohesion .getTopLevelEntityFromID("pom.test.rsc.G2"); Assert.assertEquals( "Computing ACAIC on G2", 7d, metrics.compute("ACAIC", firstClassEntity), 0); }

That is the oracle

slide-50
SLIDE 50

50/110

Outline

 Definition

– Development – Operation – Maintenance – Systematic

  • Agile
  • TDD
  • Oracles

– Disciplined

  • Sub-disciplines
  • Laws
  • Principles
  • Best practices

– Quantifiable

 Conclusion

slide-51
SLIDE 51

51/110

Definition

 Software engineering (SE) is the application

  • f a systematic, disciplined, quantifiable

approach to the design, development,

  • peration, and maintenance of software

 SE is also the study of these approaches  SE is the application of engineering to

software

slide-52
SLIDE 52

52/110

Disciplined

“Divided in sub-disciplines” “Rigorous”

—WordReference.com

slide-53
SLIDE 53

53/110

Disciplined

“Divided in sub-disciplines” “Rigorous”

—WordReference.com

Problem: how to develop quality products? Solution: use appropriate, explicit, repeatable rules

slide-54
SLIDE 54

54/110

Outline

 Definition

– Development – Operation – Maintenance – Systematic

  • Agile
  • TDD
  • Oracles

– Disciplined

  • Sub-disciplines
  • Laws
  • Principles
  • Best practices

– Quantifiable

 Conclusion

slide-55
SLIDE 55

55/110

Disciplined

 Divided in sub-disciplines

– Software requirements – Software design – Software construction – Software testing – Software maintenance – Software configuration management – Software engineering management – Software engineering process – Software quality assurance

slide-56
SLIDE 56

56/110

Disciplined

 Divided in sub-disciplines

– Software requirements – Software design – Software construction – Software testing – Software maintenance – Software configuration management – Software engineering management – Software engineering process – Software quality assurance

slide-57
SLIDE 57

57/110

Disciplined

 Rigorous

– Laws

  • Lehman’s Laws
  • Brooks’ Law

– Principles

  • SOLID
  • Do not reinvent the wheel
  • Beware of assumptions
  • Deletable code

– Best practices

  • Design patterns
  • Anti-patterns

– Code conventions

slide-58
SLIDE 58

58/110

Disciplined

 Rigorous

– Laws

  • Lehman’s Laws
  • Brooks’ Law

– Principles

  • SOLID
  • Do not reinvent the wheel
  • Beware of assumptions
  • Deletable code

– Best practices

  • Design patterns
  • Anti-patterns

– Code conventions

slide-59
SLIDE 59

59/110

Outline

 Definition

– Development – Operation – Maintenance – Systematic

  • Agile
  • TDD
  • Oracles

– Disciplined

  • Sub-disciplines
  • Laws
  • Principles
  • Best practices

– Quantifiable

 Conclusion

slide-60
SLIDE 60

60/110

Laws

“A statement of an order or relation of phenomena that so far as is known is invariable under the given conditions” —Merriam-Webster

slide-61
SLIDE 61

61/110

Manny Lehman

 Meir M. « Manny » Lehman

– Died 29 December 2010 – Father of the laws of software evolution Stevens Award in 2003 – Cf. http://www.doc.ic.ac.uk/news/archive/story/ manny-lehman – Cf. http://www.ieeeghn.org/wiki/index.php/Oral- History:Meir_Lehman

Manny Lehman *1925 †2010

slide-62
SLIDE 62

62/110

Lehman’s Laws

 Context

– 1974

  • IBM OS/360 et OS/370

– Types of programs

  • S: can be formally specified
  • P: follow an iterative development process
  • E: are embedded in our environment
slide-63
SLIDE 63

63/110

Lehman’s Laws

1.

Continuing change: E-type systems must be continually adapted or they become progressively less satisfactory

2.

Increasing complexity: As an E-type system evolves its complexity increases unless work is done to maintain or reduce it

3.

Self regulation: E-type system evolution process is self regulating with distribution of product and process measures close to normal

4.

Conservation of organisational stability: The average effective global activity rate in an evolving E-type system is invariant over product lifetime

slide-64
SLIDE 64

64/110

Lehman’s Laws

5.

Conservation of familiarity: As an E-type system evolves all must maintain mastery of its content and

  • behaviour. The average incremental growth is invariant

6.

Continuing growth: The functional content of E-type systems must be continually increased to maintain user satisfaction over their lifetime

7.

Declining quality: The quality of E-type systems will appear to be declining unless they are rigorously maintained and adapted to environmental changes

8.

Feedback system: E-type evolution processes constitute multi-level, multi-loop, multi-agent feedback systems; to achieve any improvement over any reasonable base

slide-65
SLIDE 65

65/110

Frederick Brooks

 Frederick Brooks

– Born 19 April 1931 – Father of Brooks’ Law – IEEE J. von Neumann Medal in 1993 – ACM Turing Award in 1999 – Cf. http://en.wikipedia.org/wiki/Fred_Brooks

Frederick Brooks *1931

slide-66
SLIDE 66

66/110

Brooks’ Law

 Context

– 1956–1964

  • Manager of the IBM OS/360 development project
  • Delays in the delivery

 Book

– The Mythical Man-Month: Essays on Software Engineering

 Principle

– Adding manpower to a late software project makes it later

slide-67
SLIDE 67

67/110

Brooks’ Law

slide-68
SLIDE 68

68/110

Brooks’ Law

 Rationale

– It takes some time for the people added to a project to become productive. Brooks calls this the "ramp up" time. New workers must first become educated about the work that has preceded them; also integrate with a team composed of multiple engineers who must educate the new worker in their area of expertise in the code base, day by day

slide-69
SLIDE 69

69/110

Brooks’ Law

 Rationale

– Communication overheads increase as the number of people increases. The number of different communication channels increases along with the square of the number of people

slide-70
SLIDE 70

70/110

Brooks’ Law

 Comments, solutions

– Brooks' Law applies to projects already late – The quantity, quality, and role of the people added to the project also count – Good management and development practices also help to minimize the impact of Brooks' Law – Rather than depending on heroes to carry the day with extraordinary efforts, Wiegers argues that ordinarily-skilled individuals can deliver timely results in the right work environment

slide-71
SLIDE 71

71/110

Brooks’ Law

 Critics

“How to quadruple your productivity with an army of student interns”

  • Tolerate a little crowding
  • Locate next to a deep pool of hackers
  • Know who the best people are and only hire them
  • Pay well
  • Divide tasks to be as loosely-coupled as possible
  • Design your intern projects in advance

https://blogs.oracle.com/ksplice/how-to-quadruple-your-productivity-with-an-army-of-student-interns

slide-72
SLIDE 72

72/110

Laws

 Lehman’s Laws  Brooks’ Law  Others…

More in the following classes

slide-73
SLIDE 73

73/110

Disciplined

 Rigorous

– Laws

  • Lehman’s Laws
  • Brooks’ Law

– Principles

  • SOLID
  • Do not reinvent the wheel
  • Beware of assumptions
  • Deletable code

– Best practices

  • Design patterns
  • Anti-patterns

– Code conventions

slide-74
SLIDE 74

74/110

Outline

 Definition

– Development – Operation – Maintenance – Systematic

  • Agile
  • TDD
  • Oracles

– Disciplined

  • Sub-disciplines
  • Laws
  • Principles
  • Best practices

– Quantifiable

 Conclusion

slide-75
SLIDE 75

75/110

Principles

“A rule or code of conduct” —Merriam-Webster

slide-76
SLIDE 76

76/110

Principles

 SOLID

Acronym coined by Michael Feathers for the principles described by Robert C. Martin – Single responsibility – Open/closed – Liskov substitution – Interface segregation – Dependency inversion

slide-77
SLIDE 77

77/110

SOLID

slide-78
SLIDE 78

78/110

SOLID

 Single responsibility (SRP): “an object

should have only a single responsibility” or “a class or module should have one, and

  • nly one, reason to change”
slide-79
SLIDE 79

79/110

SOLID

 Single responsibility (SRP): “an object

should have only a single responsibility” or “a class or module should have one, and

  • nly one, reason to change”
slide-80
SLIDE 80

80/110

SOLID

 Single responsibility (SRP): “an object

should have only a single responsibility” or “a class or module should have one, and

  • nly one, reason to change”

Change cannot be avoided, see Lehman’s Laws

slide-81
SLIDE 81

81/110

SOLID

 Single responsibility (SRP): “an object

should have only a single responsibility” or “a class or module should have one, and

  • nly one, reason to change”

Change must be acknowledged and planned for from the beginning

slide-82
SLIDE 82

82/110

SOLID

 Single responsibility (SRP): “an object

should have only a single responsibility” or “a class or module should have one, and

  • nly one, reason to change”

Beware of not over-engineering your solution (cf. Kerievsky and agile development)

slide-83
SLIDE 83

83/110

SOLID

 Open/closed (OCP): “objects, classes, and

modules should be open for extension, but closed for modification”

slide-84
SLIDE 84

84/110

SOLID

 Open/closed (OCP): “objects, classes, and

modules should be open for extension, but closed for modification”

– Typing vs. inheritance – Fragile base-class problem

slide-85
SLIDE 85

85/110

SOLID

 Liskov substitution (LSP): “objects in a

program should be replaceable with instances of their subtypes without altering the correctness of that program”

slide-86
SLIDE 86

86/110

SOLID

 Liskov substitution (LSP): “objects in a

program should be replaceable with instances of their subtypes without altering the correctness of that program”

– Inheritance – Polymorphism

slide-87
SLIDE 87

87/110

SOLID

 Interface segregation (ISP): “many client-

specific interfaces are better than one general-purpose interface”

slide-88
SLIDE 88

88/110

SOLID

 Interface segregation (ISP): “many client-

specific interfaces are better than one general-purpose interface”

– Encapsulation (information hiding) – Abstraction

slide-89
SLIDE 89

89/110

SOLID

 Dependency inversion (DIP): “one should

depend upon abstractions, not upon implementations”

slide-90
SLIDE 90

90/110

SOLID

 Dependency inversion (DIP): “one should

depend upon abstractions, not upon implementations”

– Typing – Factory design pattern – Iterator design pattern – Dependency injection

  • Visitor design pattern
  • Strategy design pattern
slide-91
SLIDE 91

91/110

Do Not Reinvent the Wheel

 Bì Shēng (畢昇, 毕昇) in 1041–1048  Choi Yun-ui (최윤의) in 1234*  Johannes Gutenberg circa 1450

* Not a mistake

slide-92
SLIDE 92

92/110

Do Not Reinvent the Wheel

 Bì Shēng (畢昇, 毕昇) in 1041–1048  Choi Yun-ui (최윤의) in 1234*  Johannes Gutenberg circa 1450

* Not a mistake 夢溪筆談/梦溪笔谈 Between 1031–1095

slide-93
SLIDE 93

93/110

Do Not Reinvent the Wheel

 Bì Shēng (畢昇, 毕昇) in 1041–1048  Choi Yun-ui (최윤의) in 1234*  Johannes Gutenberg circa 1450

백운화상초록불조직지심체요절 1377 * Not a mistake 夢溪筆談/梦溪笔谈 Between 1031–1095

slide-94
SLIDE 94

94/110

Do Not Reinvent the Wheel

 Bì Shēng (畢昇, 毕昇) in 1041–1048  Choi Yun-ui (최윤의) in 1234*  Johannes Gutenberg circa 1450

백운화상초록불조직지심체요절 1377 Gutenberg’s Bible

  • c. 1450

* Not a mistake 夢溪筆談/梦溪笔谈 Between 1031–1095

slide-95
SLIDE 95

95/110

Do Not Reinvent the Wheel

 Before implementing a feature, especially a

complicated one, always look for simpler solutions

– Existing piece of code? – Existing libraries?

slide-96
SLIDE 96

96/110

Do Not Reinvent the Wheel

 Yet, when reusing an existing piece of code,

beware of

– Licensing issues – Dependency issues – Ratio cost / benefit in the long term

slide-97
SLIDE 97

97/110

Do Not Reinvent the Wheel

 DRY vs. WET   

https://dev.to/wuz/stop-trying-to-be-so-dry-instead-write-everything-twice-wet-5g33

slide-98
SLIDE 98

98/110

Do Not Reinvent the Wheel

 DRY vs. WET

Don’t Repeat Yourself vs. Write Everything Twice

https://dev.to/wuz/stop-trying-to-be-so-dry-instead-write-everything-twice-wet-5g33

slide-99
SLIDE 99

99/110

Beware of Assumptions

 My name is Yann-Gaël Guéhéneuc

slide-100
SLIDE 100

100/110

Beware of Assumptions

 My name is Yann-Gaël Guéhéneuc

slide-101
SLIDE 101

101/110

Beware of Assumptions

 My name is Yann-Gaël Guéhéneuc

slide-102
SLIDE 102

102/110

Beware of Assumptions

 My name is Yann-Gaël Guéhéneuc

… is my name invalid? … what about yours? 

slide-103
SLIDE 103

103/110

Beware of Assumptions

 http://www.kalzumeus.com/2010/06/17/false

hoods-programmers-believe-about-names/

– People have exactly one canonical full name – People’s names do not change – People’s names are globally unique – …

slide-104
SLIDE 104

104/110

Beware of Assumptions

 Always validate assumptions with clients,

should be part of requirement engineering

– Beware of far-reaching (physically and temporally) assumptions “As for the password, the 18 characters is [a] limitation of the system, changing it to 19 would cause some other problems.” — Private e-mail communication with the developers of a major Web application

slide-105
SLIDE 105

105/110

Deletable Code

“Write code that is easy to delete, not easy to extend”

https://programmingisterrible.com/post/139222674273/write-code-that-is-easy-to-delete-not-easy-to

slide-106
SLIDE 106

106/110

Deletable Code

“Write code that is easy to delete, not easy to extend”

– Step 0: Don’t write code

https://programmingisterrible.com/post/139222674273/write-code-that-is-easy-to-delete-not-easy-to

slide-107
SLIDE 107

107/110

Deletable Code

“Write code that is easy to delete, not easy to extend”

– Step 0: Don’t write code – Step 1: Copy-paste code

https://programmingisterrible.com/post/139222674273/write-code-that-is-easy-to-delete-not-easy-to

slide-108
SLIDE 108

108/110

Deletable Code

“Write code that is easy to delete, not easy to extend”

– Step 0: Don’t write code – Step 1: Copy-paste code – Step 2: Don’t copy paste code

https://programmingisterrible.com/post/139222674273/write-code-that-is-easy-to-delete-not-easy-to

slide-109
SLIDE 109

109/110

Deletable Code

“Write code that is easy to delete, not easy to extend”

– Step 0: Don’t write code – Step 1: Copy-paste code – Step 2: Don’t copy paste code – Step 3: Write more boilerplate

https://programmingisterrible.com/post/139222674273/write-code-that-is-easy-to-delete-not-easy-to

slide-110
SLIDE 110

110/110

Deletable Code

“Write code that is easy to delete, not easy to extend”

– Step 0: Don’t write code – Step 1: Copy-paste code – Step 2: Don’t copy paste code – Step 3: Write more boilerplate – Step 4: Don’t write boilerplate

https://programmingisterrible.com/post/139222674273/write-code-that-is-easy-to-delete-not-easy-to

slide-111
SLIDE 111

111/110

Deletable Code

“Write code that is easy to delete, not easy to extend”

– Step 0: Don’t write code – Step 1: Copy-paste code – Step 2: Don’t copy paste code – Step 3: Write more boilerplate – Step 4: Don’t write boilerplate – Step 5: Write a big lump of code

https://programmingisterrible.com/post/139222674273/write-code-that-is-easy-to-delete-not-easy-to

slide-112
SLIDE 112

112/110

Deletable Code

“Write code that is easy to delete, not easy to extend”

– Step 0: Don’t write code – Step 1: Copy-paste code – Step 2: Don’t copy paste code – Step 3: Write more boilerplate – Step 4: Don’t write boilerplate – Step 5: Write a big lump of code – Step 6: Break your code into pieces

https://programmingisterrible.com/post/139222674273/write-code-that-is-easy-to-delete-not-easy-to

slide-113
SLIDE 113

113/110

Deletable Code

“Write code that is easy to delete, not easy to extend”

– Step 0: Don’t write code – Step 1: Copy-paste code – Step 2: Don’t copy paste code – Step 3: Write more boilerplate – Step 4: Don’t write boilerplate – Step 5: Write a big lump of code – Step 6: Break your code into pieces – Step 7: Keep writing code

https://programmingisterrible.com/post/139222674273/write-code-that-is-easy-to-delete-not-easy-to

slide-114
SLIDE 114

114/110

Deletable Code

 Step 0: Don’t write code

– The more lines of code, the more

  • Time
  • Effort
  • Difficulty to replace

– But, saving one line of code is not worth the trouble… relatively speaking…

slide-115
SLIDE 115

115/110

Deletable Code

 Step 1: Copy-paste code

– “Building reusable code is something that’s easier to do in hindsight with a couple of examples of use in the code base…” – “Once you make something a shared API, you make it harder to change.” – “It’s simpler to delete the code inside a function than it is to delete a function.”

slide-116
SLIDE 116

116/110

Deletable Code

 Step 2: Don’t copy paste code

– “The stuff that ends up in a file called util.” – “Make a util directory and keep different utilities in different files.” – “… we are trying to keep the hard-to-delete parts as far away as possible from the easy-to-delete parts.”

slide-117
SLIDE 117

117/110

Deletable Code

 Step 3: Write more boilerplate

– “Like with copy paste, we are duplicating parts of code to avoid introducing dependencies, gain flexibility, and pay for it in verbosity.” – “Minimising the dependencies or responsibilities

  • f library code, even if we have to write

boilerplate to use it.”

slide-118
SLIDE 118

118/110

Deletable Code

 Step 4: Don’t write boilerplate

– “Building simple-to-use APIs is about turning your boilerplate into a library.” – “… we are separating concerns: requests is about popular http adventures, urllib3 is about [choosing] your own adventure.” – “It’s often good to wrap third party libraries too…” – “Good APIs are designed […] for the programmers [..] layering is realising we can’t please everyone at once.”

slide-119
SLIDE 119

119/110

Deletable Code

 Step 5: Write a big lump of code

– “… write a substantial amount of trashy code to hold the rest together.” – “… don’t write a web framework before writing an application.” – “Perlis: “Everything should be built top-down, except the first time”.” – “Becoming a professional software developer is accumulating a back-catalogue of regrets and mistakes.”

https://cpsc.yale.edu/epigrams-programming

slide-120
SLIDE 120

120/110

Deletable Code

 Step 6: Break your code into pieces

– “We isolate the most frustrating parts to write, maintain, or delete away from each other.” – “A system where you can delete parts without rewriting others is often called loosely coupled, but it’s a lot easier to explain what one looks like rather than how to build it in the first place.”

slide-121
SLIDE 121

121/110

Deletable Code

 Step 7: Keep writing code

– “Feature flags are one way to change your mind later.” – “The strategies I’ve talked about—layering, isolation, common interfaces, composition—are not about writing good software, but how to build software that can change over time.”

slide-122
SLIDE 122

122/110

Principles

 Summary

– SOLID – Do not reinvent the wheel – Beware of assumptions – Deletable code – Others…

More in the following classes

slide-123
SLIDE 123

123/110

Disciplined

 Rigorous

– Laws

  • Lehman’s Laws
  • Brooks’ Law

– Principles

  • SOLID
  • Do not reinvent the wheel
  • Beware of assumptions
  • Deletable code

– Best practices

  • Design patterns
  • Anti-patterns

– Code conventions

slide-124
SLIDE 124

124/110

Outline

 Definition

– Development – Operation – Maintenance – Systematic

  • Agile
  • TDD
  • Oracles

– Disciplined

  • Sub-disciplines
  • Laws
  • Principles
  • Best practices

– Quantifiable

 Conclusion

slide-125
SLIDE 125

125/110

Definition

“A best practice is a method or technique that has consistently shown results superior to those achieved with other means” —Wikipedia

slide-126
SLIDE 126

126/110

Best Practices

 Design patterns

– A reusable solution to a recurring problem within a given context in software design

 Anti-patterns

– A reused solution to a recurring problem within a given context in software design, which is known unsuccessful (and the correct solution)

slide-127
SLIDE 127

127/110

Best Practices

 Design patterns  Anti-patterns  Others…

More in the following classes

slide-128
SLIDE 128

128/110

Disciplined

 Rigorous

– Laws

  • Lehman’s Laws
  • Brooks’ Law

– Principles

  • SOLID
  • Do not reinvent the wheel
  • Beware of assumptions
  • Deletable code

– Best practices

  • Design patterns
  • Anti-patterns

– Code conventions

slide-129
SLIDE 129

129/110

Disciplined

slide-130
SLIDE 130

130/110

Disciplined

slide-131
SLIDE 131

131/110

Disciplined

slide-132
SLIDE 132

132/110

Disciplined

slide-133
SLIDE 133

133/110

Disciplined

slide-134
SLIDE 134

134/110

Disciplined

slide-135
SLIDE 135

135/110

Disciplined

slide-136
SLIDE 136

136/110

Disciplined

slide-137
SLIDE 137

137/110

Disciplined

slide-138
SLIDE 138

138/110

Disciplined

slide-139
SLIDE 139

139/110

Disciplined

slide-140
SLIDE 140

140/110

Disciplined

slide-141
SLIDE 141

141/110

Disciplined

slide-142
SLIDE 142

142/110

Disciplined

slide-143
SLIDE 143

143/110

Disciplined

slide-144
SLIDE 144

144/110

Disciplined

slide-145
SLIDE 145

145/110

Outline

 Definition

– Development – Operation – Maintenance – Systematic

  • Agile
  • TDD
  • Oracles

– Disciplined

  • Sub-disciplines
  • Laws
  • Principles
  • Best practices

– Quantifiable

 Conclusion

slide-146
SLIDE 146

146/110

Definition

 Software engineering (SE) is the application

  • f a systematic, disciplined, quantifiable

approach to the design, development,

  • peration, and maintenance of software

 SE is also the study of these approaches  SE is the application of engineering to

software

slide-147
SLIDE 147

147/110

Quantifiable

“Whose quantity can be determined” —WordReference.com

slide-148
SLIDE 148

148/110

Quantifiable

“Whose quantity can be determined” —WordReference.com

Problem: how to measure success? Solution: use explicit, repeatable criteria

slide-149
SLIDE 149

149/110

Quantifiable

 Metrics

– A measure of some property of a piece of software or its specifications

 Quality models

– A defined set of characteristics, and their relationships, which provides a framework for specifying quality requirements and evaluating quality (ISO/IEC 25010:2011)

slide-150
SLIDE 150

150/110

Quantifiable

 Metrics  Quality models

More in the following classes

slide-151
SLIDE 151

151/110

Definition

 Software engineering (SE) is the application

  • f a systematic, disciplined, quantifiable

approach to the design, development,

  • peration, and maintenance of software

 SE is also the study of these approaches  SE is the application of engineering to

software

slide-152
SLIDE 152

152/110

Definition

 Software engineering (SE) is the application

  • f a systematic, disciplined, quantifiable

approach to the design, development,

  • peration, and maintenance of software

 SE is also the study of these approaches  SE is the application of engineering to

software

slide-153
SLIDE 153

153/110

Conclusion (1/2)

“I’d recommend three things: learn how to abstract, learn how to work as part of a team, and study the code of others.” —Grady Booch in Masterminds of Programming

slide-154
SLIDE 154

154/110

Conclusion (2/2)

 Remember

– Software engineering is the application of a systematic, disciplined, quantifiable approach to the design, development, operation, and maintenance of software – Problem solving – Information hiding – Agile – TDD – Lehman’s Laws – Brooks’ Law – SOLID – DRY, WET – Beware of assumptions – Deletable code