SlideShare a Scribd company logo
three
@KevlinHenney
Veni
Vidi
Vici
Sex &
Drugs &
Rock'n'Roll
Liberté · Égalité · Fraternité
There's nothing long-winded about
Maurice Saatchi
Rien n'est plus
dangereux qu'une
idée, quand on n'a
qu'une idée.
Émile-Auguste Chartier
Nothing is more
dangerous than an
idea, when you have
only one idea.
Émile-Auguste Chartier
Nothing is more
dangerous than an
IDE, when you have
only one IDE.
public static String fizzbuzz(int n) {
String result = "";
if (n % 3 == 0) {
result += "Fizz";
}
if (n % 5 == 0) {
result += "Buzz";
}
if (result.isEmpty()) {
result += n;
}
return result;
}
FizzBuzz was invented to
avoid the awkwardness
of realising that nobody
in the room can binary
search an array.
https://twitter.com/richardadalton/status/591534529086693376
fizzbuzz = (
lambda n:
'Fizz' * (n % 3 == 0) +
'Buzz' * (n % 5 == 0) +
str(n) * (n % 3 != 0 and n % 5 != 0))
fizzes = cycle ["", "", "Fizz"]
buzzes = cycle ["", "", "", "", "Buzz"]
words = zipWith (++) fizzes buzzes
numbers = map show [1..]
fizzbuzz = zipWith max words numbers
Nothing is more
dangerous than an
idea, when you have
only one idea.
Émile-Auguste Chartier
When a design decision
can reasonably go one of
two ways, an architect
needs to take a step back.
Instead of trying to decide
between options A and B,
the question becomes
"How do I design so that
the choice between A and
B is less significant?"
The most interesting thing
is not actually the choice
between A and B, but the
fact that there is a choice
between A and B.
Kevlin Henney
"Use Uncertainty As a Driver"
To have one choice is no choice;
to have two choices is a dilemma;
and to have three choices offers
new possibilities.
Virginia Satir
The Rule of Three
If you can’t think of three things
that might go wrong with your
plans, then there’s something
wrong with your thinking.
Jerry Weinberg
If you want to reduce your test
mass, the number one thing you
should do is look at the tests that
have never failed in a year and
consider throwing them away.
They are producing no information
for you — or at least very little
information.
James O Coplien
"Why Most Unit Testing Is Waste"
1. Your tests are not failing because
the code they are testing has not
changed.
2. Your tests are not failing because
they are not running.
3. Your tests are not failing because,
yes, you are that good.
The Rule of Three
Here's a guideline Don Roberts
gave me...
The first time you do something,
you just do it.
The second time you do
something similar, you wince at
the duplication, but you do the
duplicate thing anyway.
The third time you do something
similar, you refactor.
Three strikes and you refactor.
Identity
State
Behaviour
Encapsulation
Inheritance
Polymorphism
Encapsulation
Polymorphism
Inheritance
Encapsulation
Polymorphism
Inheritance
Ignorance
Apathy
Selfishness
S-Programs
P-Programs
E-Programs
Meir M Lehman
"Programs, Life Cycles, and Laws of Software Evolution"
S-Programs
Programs whose function is
formally defined by and derivable
from a specification.
Meir M Lehman
"Programs, Life Cycles, and Laws of Software Evolution"
P-Programs
Despite the fact that the problem
to be solved can be precisely
defined, the acceptability of a
solution is determined by the
environment in which it is
embedded.
Meir M Lehman
"Programs, Life Cycles, and Laws of Software Evolution"
E-Programs
Programs that mechanize a
human or societal activity.
The program has become a part
of the world it models, it is
embedded in it.
Meir M Lehman
"Programs, Life Cycles, and Laws of Software Evolution"
We know that every pattern is an instruction of the general form:
context  conflicting forces  configuration
So we say that a pattern is good, whenever we can show that it
meets the following two empirical conditions:
1. The problem is real. This means that we can express the
problem as a conflict among forces which really do occur
within the stated context, and cannot normally be resolved
within that context. This is an empirical question.
2. The configuration solves the problem. This means that when
the stated arrangement of parts is present in the stated
context, the conflict can be resolved, without any side effects.
This is an empirical question.
context  conflicting forces  configurationcontext  conflicting forces  configuration  consequences
Write down the problem.
Think real hard.
Write down the solution.
The Feynman Problem-Solving Algorithm
Write down the problem.
Think real hard.
Write down the solution.
Check it.
Plan
Establish hypothesis,
goal or work tasks
Do
Carry out plan
Study
Review what has
been done against
plan (a.k.a. Check)
Act
Revise approach
or artefacts based
on study
Deming's PDSA Cycle
Test early.
Test often.
Test automatically.
Andrew Hunt and David Thomas
The Pragmatic Programmer
So who should you be writing the tests
for? For the person trying to
understand your code.
Good tests act as documentation for
the code they are testing. They
describe how the code works. For each
usage scenario, the test(s):
 Describe the context, starting point,
or preconditions that must be
satisfied
 Illustrate how the software is
invoked
 Describe the expected results or
postconditions to be verified
Different usage scenarios will have
slightly different versions of each of
these.
Gerard Meszaros
"Write Tests for People"
So who should you be writing the tests
for? For the person trying to
understand your code.
Good tests act as documentation for
the code they are testing. They
describe how the code works. For each
usage scenario, the test(s):
 Describe the context, starting point,
or preconditions that must be
satisfied
 Illustrate how the software is
invoked
 Describe the expected results or
postconditions to be verified
Different usage scenarios will have
slightly different versions of each of
these.
Gerard Meszaros
"Write Tests for People"
Arrange
Act
Assert
So who should you be writing the tests
for? For the person trying to
understand your code.
Good tests act as documentation for
the code they are testing. They
describe how the code works. For each
usage scenario, the test(s):
 Describe the context, starting point,
or preconditions that must be
satisfied
 Illustrate how the software is
invoked
 Describe the expected results or
postconditions to be verified
Different usage scenarios will have
slightly different versions of each of
these.
Gerard Meszaros
"Write Tests for People"
Given
When
Then
{P} S {Q}
assert fizzbuzz(1) == 1
assert fizzbuzz(2) == 2
assert fizzbuzz(3) == 'Fizz'
assert fizzbuzz(4) == 4
assert fizzbuzz(5) == 'Buzz'
assert fizzbuzz(6) == 'Fizz'
assert fizzbuzz(7) == 7
assert fizzbuzz(8) == 8
assert fizzbuzz(9) == 'Fizz'
assert fizzbuzz(10) == 'Buzz'
assert fizzbuzz(11) == 11
assert fizzbuzz(12) == 'Fizz'
assert fizzbuzz(13) == 13
assert fizzbuzz(14) == 14
assert fizzbuzz(15) == 'FizzBuzz'
...
assert fizzbuzz(98) == 98
assert fizzbuzz(99) == 'Fizz'
assert fizzbuzz(100) == 'Buzz'
def fizzbuzz(n):
if n == 1: return 1
if n == 2: return 2
if n == 3: return 'Fizz'
if n == 4: return 4
if n == 5: return 'Buzz'
if n == 6: return 'Fizz'
if n == 7: return 7
if n == 8: return 8
if n == 9: return 'Fizz'
if n == 10: return 'Buzz'
if n == 11: return 11
if n == 12: return 'Fizz'
if n == 13: return 13
if n == 14: return 14
if n == 15: return 'FizzBuzz'
...
if n == 98: return 98
if n == 99: return 'Fizz'
if n == 100: return 'Buzz'
Red
Write a failing test for
a new feature
Green
Write enough code to
pass the test
Refactor
Refine code and tests
Test-First Cycle
Red
Write a failing test for
a new feature
Green
Write enough code to
pass the test
Refactor!
Refine code and tests
Test-First Cycle
Red
Write a failing test for
a new feature
Green
Write enough code to
pass the test
Refactor?
Refine code and tests
Test-First Cycle
Plan
Establish hypothesis,
goal or work tasks
Do
Carry out plan
Study
Review what has
been done against
plan (a.k.a. Check)
Act
Revise approach
or artefacts based
on study
Deming's PDSA Cycle
Write
As the behaviour is
new, the test fails
Realise
Implement so that
the test passes
Reflect
Is there something in
the code or tests that
could be improved?
Refactor
Make it so!
Test-First Cycle
The difficulty in being able to
write a test can be boiled down
to the two broad themes of
complexity and ignorance
Kevlin Henney
"A Test of Knowledge"
http://www.artima.com/weblogs/viewpost.jsp?thread=340839
The difficulty in being able to
write a test can be boiled down
to the two broad themes of
complexity and ignorance,
each manifested in a couple of
different ways...
 The essential complexity of
the problem being solved
 The accidental complexity
of the problem being solved
 Uncertainty over what the
code should actually do
 Lack of testing know-how
Kevlin Henney
"A Test of Knowledge"
http://www.artima.com/weblogs/viewpost.jsp?thread=340839
and fours and…
Good things
come in threes
and fours

More Related Content

Viewers also liked

ללמוד כיצד לרתום את הכח של מתודולוגיית אדיג\'ס- הזמנה ליום העיון
ללמוד כיצד לרתום את הכח של מתודולוגיית אדיג\'ס- הזמנה ליום העיוןללמוד כיצד לרתום את הכח של מתודולוגיית אדיג\'ס- הזמנה ליום העיון
ללמוד כיצד לרתום את הכח של מתודולוגיית אדיג\'ס- הזמנה ליום העיון
PeterShtrom
 
Guía de aplicación sistema nervioso
Guía  de  aplicación   sistema  nerviosoGuía  de  aplicación   sistema  nervioso
Guía de aplicación sistema nervioso
Giuliana Tinoco
 
Leadership howard county 03 28 12 jenn lim delivering happiness
Leadership howard county 03 28 12 jenn lim delivering happinessLeadership howard county 03 28 12 jenn lim delivering happiness
Leadership howard county 03 28 12 jenn lim delivering happiness
Delivering Happiness
 

Viewers also liked (20)

SOLID Deconstruction
SOLID DeconstructionSOLID Deconstruction
SOLID Deconstruction
 
A System Is Not a Tree
A System Is Not a TreeA System Is Not a Tree
A System Is Not a Tree
 
Modernsalafism saidfoudah
Modernsalafism saidfoudahModernsalafism saidfoudah
Modernsalafism saidfoudah
 
Functional C++
Functional C++Functional C++
Functional C++
 
Worse Is Better, for Better or for Worse
Worse Is Better, for Better or for WorseWorse Is Better, for Better or for Worse
Worse Is Better, for Better or for Worse
 
Declarative Thinking, Declarative Practice
Declarative Thinking, Declarative PracticeDeclarative Thinking, Declarative Practice
Declarative Thinking, Declarative Practice
 
Serializing Value Objects-Ara Hacopian
Serializing Value Objects-Ara HacopianSerializing Value Objects-Ara Hacopian
Serializing Value Objects-Ara Hacopian
 
FizzBuzz Trek
FizzBuzz TrekFizzBuzz Trek
FizzBuzz Trek
 
The Architecture of Uncertainty
The Architecture of UncertaintyThe Architecture of Uncertainty
The Architecture of Uncertainty
 
Object? You Keep Using that Word
Object? You Keep Using that WordObject? You Keep Using that Word
Object? You Keep Using that Word
 
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
 
Python Advanced – Building on the foundation
Python Advanced – Building on the foundationPython Advanced – Building on the foundation
Python Advanced – Building on the foundation
 
E book - Hiring tool kit for Smart Recruiters
E book - Hiring tool kit for Smart RecruitersE book - Hiring tool kit for Smart Recruiters
E book - Hiring tool kit for Smart Recruiters
 
ללמוד כיצד לרתום את הכח של מתודולוגיית אדיג\'ס- הזמנה ליום העיון
ללמוד כיצד לרתום את הכח של מתודולוגיית אדיג\'ס- הזמנה ליום העיוןללמוד כיצד לרתום את הכח של מתודולוגיית אדיג\'ס- הזמנה ליום העיון
ללמוד כיצד לרתום את הכח של מתודולוגיית אדיג\'ס- הזמנה ליום העיון
 
Google Analytics aplicado al Email Marketing
Google Analytics aplicado al Email MarketingGoogle Analytics aplicado al Email Marketing
Google Analytics aplicado al Email Marketing
 
Aloittelevan kunnallispoliitikon tunnustukset vuodelta 1997
Aloittelevan kunnallispoliitikon tunnustukset vuodelta 1997Aloittelevan kunnallispoliitikon tunnustukset vuodelta 1997
Aloittelevan kunnallispoliitikon tunnustukset vuodelta 1997
 
Guía de aplicación sistema nervioso
Guía  de  aplicación   sistema  nerviosoGuía  de  aplicación   sistema  nervioso
Guía de aplicación sistema nervioso
 
For men of understanding 1. honey bees, salmons, monarch butterflies and drag...
For men of understanding 1. honey bees, salmons, monarch butterflies and drag...For men of understanding 1. honey bees, salmons, monarch butterflies and drag...
For men of understanding 1. honey bees, salmons, monarch butterflies and drag...
 
Leadership howard county 03 28 12 jenn lim delivering happiness
Leadership howard county 03 28 12 jenn lim delivering happinessLeadership howard county 03 28 12 jenn lim delivering happiness
Leadership howard county 03 28 12 jenn lim delivering happiness
 
The 7 Essential Secrets of the Tech Job Search
The 7 Essential Secrets of the Tech Job SearchThe 7 Essential Secrets of the Tech Job Search
The 7 Essential Secrets of the Tech Job Search
 

Similar to The Rule of Three

lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
butest
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
butest
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
butest
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
butest
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
butest
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
butest
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
butest
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
butest
 
Experimental design
Experimental designExperimental design
Experimental design
Dan Toma
 
Slides(ppt)
Slides(ppt)Slides(ppt)
Slides(ppt)
butest
 
When Tdd Goes Awry (IAD 2013)
When Tdd Goes Awry (IAD 2013)When Tdd Goes Awry (IAD 2013)
When Tdd Goes Awry (IAD 2013)
Uberto Barbini
 
Becoming a software testing expert
Becoming a software testing expertBecoming a software testing expert
Becoming a software testing expert
moosix
 

Similar to The Rule of Three (20)

Dan Toma Presentation on IWMC 2015
Dan Toma Presentation on IWMC 2015Dan Toma Presentation on IWMC 2015
Dan Toma Presentation on IWMC 2015
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
 
lec21.ppt
lec21.pptlec21.ppt
lec21.ppt
 
Experimental design
Experimental designExperimental design
Experimental design
 
Test Design For Everyone
Test Design For EveryoneTest Design For Everyone
Test Design For Everyone
 
Test-Driven Development
 Test-Driven Development  Test-Driven Development
Test-Driven Development
 
Slides(ppt)
Slides(ppt)Slides(ppt)
Slides(ppt)
 
Introducción práctica a Test-Driven Development (TDD)
Introducción práctica a Test-Driven Development (TDD)Introducción práctica a Test-Driven Development (TDD)
Introducción práctica a Test-Driven Development (TDD)
 
Introducción práctica a TDD
Introducción práctica a TDDIntroducción práctica a TDD
Introducción práctica a TDD
 
Game of Sprints
Game of SprintsGame of Sprints
Game of Sprints
 
When Tdd Goes Awry (IAD 2013)
When Tdd Goes Awry (IAD 2013)When Tdd Goes Awry (IAD 2013)
When Tdd Goes Awry (IAD 2013)
 
Joy Scharmen - The Virtuous Cycle: Getting Good Things Out of Bad Failures
Joy Scharmen - The Virtuous Cycle: Getting Good Things Out of Bad FailuresJoy Scharmen - The Virtuous Cycle: Getting Good Things Out of Bad Failures
Joy Scharmen - The Virtuous Cycle: Getting Good Things Out of Bad Failures
 
Becoming a software testing expert
Becoming a software testing expertBecoming a software testing expert
Becoming a software testing expert
 
Questions for R language.pdf
Questions for R language.pdfQuestions for R language.pdf
Questions for R language.pdf
 

More from Kevlin Henney

More from Kevlin Henney (20)

Program with GUTs
Program with GUTsProgram with GUTs
Program with GUTs
 
The Case for Technical Excellence
The Case for Technical ExcellenceThe Case for Technical Excellence
The Case for Technical Excellence
 
Empirical Development
Empirical DevelopmentEmpirical Development
Empirical Development
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that Letter
 
Lambda? You Keep Using that Letter
Lambda? You Keep Using that LetterLambda? You Keep Using that Letter
Lambda? You Keep Using that Letter
 
Solid Deconstruction
Solid DeconstructionSolid Deconstruction
Solid Deconstruction
 
Get Kata
Get KataGet Kata
Get Kata
 
Procedural Programming: It’s Back? It Never Went Away
Procedural Programming: It’s Back? It Never Went AwayProcedural Programming: It’s Back? It Never Went Away
Procedural Programming: It’s Back? It Never Went Away
 
Structure and Interpretation of Test Cases
Structure and Interpretation of Test CasesStructure and Interpretation of Test Cases
Structure and Interpretation of Test Cases
 
Agility ≠ Speed
Agility ≠ SpeedAgility ≠ Speed
Agility ≠ Speed
 
Refactoring to Immutability
Refactoring to ImmutabilityRefactoring to Immutability
Refactoring to Immutability
 
Old Is the New New
Old Is the New NewOld Is the New New
Old Is the New New
 
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
 
Thinking Outside the Synchronisation Quadrant
Thinking Outside the Synchronisation QuadrantThinking Outside the Synchronisation Quadrant
Thinking Outside the Synchronisation Quadrant
 
Code as Risk
Code as RiskCode as Risk
Code as Risk
 
Software Is Details
Software Is DetailsSoftware Is Details
Software Is Details
 
Good Code
Good CodeGood Code
Good Code
 
The Error of Our Ways
The Error of Our WaysThe Error of Our Ways
The Error of Our Ways
 
Driven to Tests
Driven to TestsDriven to Tests
Driven to Tests
 
Learning Curve
Learning CurveLearning Curve
Learning Curve
 

Recently uploaded

Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
mbmh111980
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 

Recently uploaded (20)

Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 

The Rule of Three

  • 2.
  • 3.
  • 6. Liberté · Égalité · Fraternité There's nothing long-winded about Maurice Saatchi
  • 7.
  • 8.
  • 9.
  • 10. Rien n'est plus dangereux qu'une idée, quand on n'a qu'une idée. Émile-Auguste Chartier
  • 11. Nothing is more dangerous than an idea, when you have only one idea. Émile-Auguste Chartier
  • 12. Nothing is more dangerous than an IDE, when you have only one IDE.
  • 13. public static String fizzbuzz(int n) { String result = ""; if (n % 3 == 0) { result += "Fizz"; } if (n % 5 == 0) { result += "Buzz"; } if (result.isEmpty()) { result += n; } return result; }
  • 14. FizzBuzz was invented to avoid the awkwardness of realising that nobody in the room can binary search an array. https://twitter.com/richardadalton/status/591534529086693376
  • 15. fizzbuzz = ( lambda n: 'Fizz' * (n % 3 == 0) + 'Buzz' * (n % 5 == 0) + str(n) * (n % 3 != 0 and n % 5 != 0))
  • 16. fizzes = cycle ["", "", "Fizz"] buzzes = cycle ["", "", "", "", "Buzz"] words = zipWith (++) fizzes buzzes numbers = map show [1..] fizzbuzz = zipWith max words numbers
  • 17. Nothing is more dangerous than an idea, when you have only one idea. Émile-Auguste Chartier
  • 18. When a design decision can reasonably go one of two ways, an architect needs to take a step back. Instead of trying to decide between options A and B, the question becomes "How do I design so that the choice between A and B is less significant?" The most interesting thing is not actually the choice between A and B, but the fact that there is a choice between A and B. Kevlin Henney "Use Uncertainty As a Driver"
  • 19. To have one choice is no choice; to have two choices is a dilemma; and to have three choices offers new possibilities. Virginia Satir
  • 20. The Rule of Three If you can’t think of three things that might go wrong with your plans, then there’s something wrong with your thinking. Jerry Weinberg
  • 21. If you want to reduce your test mass, the number one thing you should do is look at the tests that have never failed in a year and consider throwing them away. They are producing no information for you — or at least very little information. James O Coplien "Why Most Unit Testing Is Waste"
  • 22. 1. Your tests are not failing because the code they are testing has not changed. 2. Your tests are not failing because they are not running. 3. Your tests are not failing because, yes, you are that good.
  • 23.
  • 24. The Rule of Three Here's a guideline Don Roberts gave me...
  • 25. The first time you do something, you just do it. The second time you do something similar, you wince at the duplication, but you do the duplicate thing anyway. The third time you do something similar, you refactor.
  • 26. Three strikes and you refactor.
  • 32. S-Programs P-Programs E-Programs Meir M Lehman "Programs, Life Cycles, and Laws of Software Evolution"
  • 33. S-Programs Programs whose function is formally defined by and derivable from a specification. Meir M Lehman "Programs, Life Cycles, and Laws of Software Evolution"
  • 34. P-Programs Despite the fact that the problem to be solved can be precisely defined, the acceptability of a solution is determined by the environment in which it is embedded. Meir M Lehman "Programs, Life Cycles, and Laws of Software Evolution"
  • 35. E-Programs Programs that mechanize a human or societal activity. The program has become a part of the world it models, it is embedded in it. Meir M Lehman "Programs, Life Cycles, and Laws of Software Evolution"
  • 36.
  • 37. We know that every pattern is an instruction of the general form: context  conflicting forces  configuration So we say that a pattern is good, whenever we can show that it meets the following two empirical conditions: 1. The problem is real. This means that we can express the problem as a conflict among forces which really do occur within the stated context, and cannot normally be resolved within that context. This is an empirical question. 2. The configuration solves the problem. This means that when the stated arrangement of parts is present in the stated context, the conflict can be resolved, without any side effects. This is an empirical question.
  • 38. context  conflicting forces  configurationcontext  conflicting forces  configuration  consequences
  • 39. Write down the problem. Think real hard. Write down the solution. The Feynman Problem-Solving Algorithm
  • 40. Write down the problem. Think real hard. Write down the solution. Check it.
  • 41. Plan Establish hypothesis, goal or work tasks Do Carry out plan Study Review what has been done against plan (a.k.a. Check) Act Revise approach or artefacts based on study Deming's PDSA Cycle
  • 42. Test early. Test often. Test automatically. Andrew Hunt and David Thomas The Pragmatic Programmer
  • 43. So who should you be writing the tests for? For the person trying to understand your code. Good tests act as documentation for the code they are testing. They describe how the code works. For each usage scenario, the test(s):  Describe the context, starting point, or preconditions that must be satisfied  Illustrate how the software is invoked  Describe the expected results or postconditions to be verified Different usage scenarios will have slightly different versions of each of these. Gerard Meszaros "Write Tests for People"
  • 44. So who should you be writing the tests for? For the person trying to understand your code. Good tests act as documentation for the code they are testing. They describe how the code works. For each usage scenario, the test(s):  Describe the context, starting point, or preconditions that must be satisfied  Illustrate how the software is invoked  Describe the expected results or postconditions to be verified Different usage scenarios will have slightly different versions of each of these. Gerard Meszaros "Write Tests for People" Arrange Act Assert
  • 45. So who should you be writing the tests for? For the person trying to understand your code. Good tests act as documentation for the code they are testing. They describe how the code works. For each usage scenario, the test(s):  Describe the context, starting point, or preconditions that must be satisfied  Illustrate how the software is invoked  Describe the expected results or postconditions to be verified Different usage scenarios will have slightly different versions of each of these. Gerard Meszaros "Write Tests for People" Given When Then
  • 46.
  • 48.
  • 49. assert fizzbuzz(1) == 1 assert fizzbuzz(2) == 2 assert fizzbuzz(3) == 'Fizz' assert fizzbuzz(4) == 4 assert fizzbuzz(5) == 'Buzz' assert fizzbuzz(6) == 'Fizz' assert fizzbuzz(7) == 7 assert fizzbuzz(8) == 8 assert fizzbuzz(9) == 'Fizz' assert fizzbuzz(10) == 'Buzz' assert fizzbuzz(11) == 11 assert fizzbuzz(12) == 'Fizz' assert fizzbuzz(13) == 13 assert fizzbuzz(14) == 14 assert fizzbuzz(15) == 'FizzBuzz' ... assert fizzbuzz(98) == 98 assert fizzbuzz(99) == 'Fizz' assert fizzbuzz(100) == 'Buzz' def fizzbuzz(n): if n == 1: return 1 if n == 2: return 2 if n == 3: return 'Fizz' if n == 4: return 4 if n == 5: return 'Buzz' if n == 6: return 'Fizz' if n == 7: return 7 if n == 8: return 8 if n == 9: return 'Fizz' if n == 10: return 'Buzz' if n == 11: return 11 if n == 12: return 'Fizz' if n == 13: return 13 if n == 14: return 14 if n == 15: return 'FizzBuzz' ... if n == 98: return 98 if n == 99: return 'Fizz' if n == 100: return 'Buzz'
  • 50. Red Write a failing test for a new feature Green Write enough code to pass the test Refactor Refine code and tests Test-First Cycle
  • 51. Red Write a failing test for a new feature Green Write enough code to pass the test Refactor! Refine code and tests Test-First Cycle
  • 52. Red Write a failing test for a new feature Green Write enough code to pass the test Refactor? Refine code and tests Test-First Cycle
  • 53. Plan Establish hypothesis, goal or work tasks Do Carry out plan Study Review what has been done against plan (a.k.a. Check) Act Revise approach or artefacts based on study Deming's PDSA Cycle
  • 54. Write As the behaviour is new, the test fails Realise Implement so that the test passes Reflect Is there something in the code or tests that could be improved? Refactor Make it so! Test-First Cycle
  • 55. The difficulty in being able to write a test can be boiled down to the two broad themes of complexity and ignorance Kevlin Henney "A Test of Knowledge" http://www.artima.com/weblogs/viewpost.jsp?thread=340839 The difficulty in being able to write a test can be boiled down to the two broad themes of complexity and ignorance, each manifested in a couple of different ways...
  • 56.  The essential complexity of the problem being solved  The accidental complexity of the problem being solved  Uncertainty over what the code should actually do  Lack of testing know-how Kevlin Henney "A Test of Knowledge" http://www.artima.com/weblogs/viewpost.jsp?thread=340839
  • 57. and fours and… Good things come in threes and fours