CLEAN(ER) CODE
TECH ’N‘ DRINKS
ABOUT ME
MARTIN “D4RK” STRAUB
▸ iOS developer @myposter !
▸ Guitar player @kentuckyschreit (ska/pop-punk) 🎸
▸ Husband 💑
▸ Cat 😺
ABOUT ME
MARTIN “D4RK” STRAUB
▸ ...
▸ ...
▸ martin-straub.de
▸ iOS developer @myposter !
▸ Guitar player @kentuckyschreit (ska/pop-punk) 🎸
▸ Husband 💑
▸ Cat 😺
DRY
DON’T REPEAT YOURSELF
EVERY PIECE OF KNOWLEDGE MUST HAVE
A SINGLE, UNAMBIGUOUS, AUTHORITATIVE
REPRESENTATION WITHIN A SYSTEM.
The Pragmatic Programmer
DON’T REPEAT YOURSELF (DRY)
DON’T REPEAT YOURSELF (DRY)
WHAT’S IT ABOUT?
▸ Don’t repeat the knowledge
▸ Avoid contradictions
▸ One source of truth
DON’T REPEAT YOURSELF (DRY)
TYPES OF DUPLICATION
▸ Imposed duplication
▸ Inadvertent duplication
▸ Impatient duplication
▸ Interdeveloper duplication
DUPLICATION IS FAR
CHEAPER THAN THE
WRONG ABSTRACTION.
Sandi Metz
(Teacher, writer, consultant, programmer)
A SYSTEM’S KNOWLEDGE IS FAR
BROADER THAN JUST ITS CODE.
DON’T REPEAT YOURSELF (DRY)
The Pragmatic Programmer
DON’T REPEAT YOURSELF (DRY)
BROADER USAGE
▸ Database schemas
▸ Test plans
▸ Build system
▸ Documentation
KISS
KEEP IT SIMPLE, STUPID
KEEP IT SIMPLE STUPID
Kelly Johnson
(Lead engineer at Lookheed Martin)
KEEP IT SIMPLE, STUPID (KISS)
WHAT’S IT ABOUT?
▸ Most systems work best if they are kept simple
rather than made complicated
▸ Simplicity should be a key goal in design
▸ Unnecessary complexity should be avoided
▸ The end-user doesn’t care how smart you are
▸ If you have to explain the product, it’s too
complicated
MAKE EVERYTHING AS SIMPLE AS
POSSIBLE, BUT NOT SIMPLER
Albert Einstein
KEEP IT SIMPLE, STUPID (KISS)
YAGNI
YOU AIN’T GONNA NEED IT
YOU AIN’T GONNA NEED IT (YAGNI)
WHAT’S IT ABOUT?
▸ 80% of the time spent on a software project is
invested in 20% of the functionality
▸ Prioritize (MoSCoW)
▸ No future coding
▸ No overengineering
MUST HAVE
SHOULD HAVE
COULD HAVE
WON’T HAVE (THIS TIME)
MoSCoW principle
DRY VS. KISS & YAGNI
SUMMARY
▸ DRY strives for abstraction
▸ KISS aims for simplicity
▸ YAGNI doesn’t want to do it at all
▸ Those principles compete with each other
▸ Find the right balance between DRY and KISS/
YAGNI
RCA
ROOT CAUSE ANALYSIS
…USE A BUCKET!
WATER DRIPS FROM THE
CEILING?
…RIGHT?! 🧐
SOLVE PROBLEMS
THERE ARE 2 WAYS TO
ROOT CAUSE ANALYSIS (RCA)
1. REACTIVE MANAGEMENT
▸ React quickly, by treating the symptoms
▸ Goal: Ease the effects of the problem as soon
as possible
ROOT CAUSE ANALYSIS (RCA)
2. PROACTIVE MANAGEMENT
▸ Address the real cause instead of its symptoms
▸ Goal: Prevent problems from (re-)occurring
ROOT CAUSE ANALYSIS (RCA)
ROOT CAUSE ANALYSIS
▸ Identification and description
▸ Chronology
▸ Differentiation
▸ Causal graphing
▸ Next step: Trigger long-term corrective actions
BY REPEATING WHY FIVE TIMES, THE
NATURE OF THE PROBLEM AS WELL AS
ITS SOLUTION BECOMES CLEAR.
Taiichi Ohno
ROOT CAUSE ANALYSIS (RCA)
(“Father” of the Toyota Production System)
ROOT CAUSE ANALYSIS (RCA)
5 WHYS
Example: Ran through a red light. (problem)
▸ Why? - Late for work. (1st why)
▸ Why? - Woke up late. (2nd why)
▸ Why? - Alarm clock didn’t ring. (3rd why)
▸ Why? - Battery was empty. (4th why)
▸ Why? - Forgot to charge it. (5th why and root
cause)
ROOT CAUSE ANALYSIS (RCA)
CONCLUSION
▸ Reactive management: quickly ease the
symptoms
▸ Proactive management: actually fix the issue
▸ Only the latter can lead to a sustainable and
reliable code base
WANT SOME MORE?!
MAKE IT WORK,
MAKE IT RIGHT,
MAKE IT FAST.
Kent Beck
(Software engineer, creator of extreme programming, TDD, …)
IT’S HARDER TO READ
CODE THAN TO WRITE IT.
Joel Spolsky
(Co-founder of Stack Overflow)
BUILD YOUR LOGIC ON
DIRECT RELATIONS, NOT
ON ASSUMPTIONS.
Unknown author
LOGIC DEPENDENCIES
EXAMPLES
▸ App: Does the UI depend on the device’s
orientation?

... or on parent view changes?
▸ Do you grab yourself a new beer every 15
minutes?

… or every time the bottle’s empty?
SUMMARY
CLEAN(ER) CODE
CLEAN(ER) CODE
SUMMARY
▸ Play the principle game
▸ BUT:
▸ Principles are not rules
▸ Find the right balance
▸ Always use common sense
▸ Don’t get paralysed by overthinking things
SOURCES
CLEAN(ER) CODE
SOURCES
TITLE & ABOUT ME
▸ https://twitter.com/ColucciLaw/status/1010920761043939328
▸ martin-straub.de
▸ https://www.instagram.com/maezikatzi
SOURCES
DON’T REPEAT YOURSELF (DRY)
▸ https://pragprog.com/book/tpp/the-pragmatic-programmer
▸ https://thevaluable.dev/dry-principle-explained
▸ http://verraes.net/2014/08/dry-is-about-knowledge
▸ https://www.sandimetz.com/blog/2016/1/20/the-wrong-abstraction
SOURCES
DRY (IMAGES)
▸ https://www.flickr.com/photos/liveoncelivewild/32686776783
▸ https://medium.com/startup-grind/even-smart-vcs-invest-in-cross-industry-
clones-6a3c63f830e4
▸ https://www.engadget.com/2016/07/27/dolly-sheep-clones-are-healthy
▸ https://www.writermag.com/writing-inspiration/the-writing-life/declutter-
hoarded-story-ideas
SOURCES
KEEP IT SIMPLE, STUPID (KISS)
▸ https://en.wikipedia.org/wiki/Kelly_Johnson_(engineer)
▸ https://www.interaction-design.org/literature/article/kiss-keep-it-simple-stupid-
a-design-principle
▸ https://championingscience.com/2019/03/15/everything-should-be-made-as-
simple-as-possible-but-no-simpler
SOURCES
KISS (IMAGES)
▸ https://archive.triblive.com/aande/music/kiss-makeup-has-changed-but-their-
impact-remains-strong
▸ https://mannerofspeaking.org/2018/03/11/simplicity-is-the-key-to-brilliance
▸ https://mostlyme-certainothers.com/2015/07/16/no-frills/simplicity-01
SOURCES
YOU AIN’T GONNA NEED IT (YAGNI)
▸ https://ronjeffries.com/articles/019-01ff/iter-yagni-skimp
▸ https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it
▸ https://en.wikipedia.org/wiki/MoSCoW_method
SOURCES
YAGNI (IMAGES)
▸ https://www.monkeyuser.com/2019/yagni
▸ https://www.developgoodhabits.com/80-20-rule
▸ http://www.thebluediamondgallery.com/wooden-tile/p/priority.html
▸ https://xkcd.com/974
SOURCES
ROOT CAUSE ANALYSIS (RCA)
▸ https://en.wikipedia.org/wiki/Root_cause_analysis
▸ https://en.wikipedia.org/wiki/5_Whys
▸ https://en.wikipedia.org/wiki/Taiichi_Ohno
▸ https://kanbanize.com/lean-management/improvement/5-whys-analysis-tool
SOURCES
RCA (IMAGES)
▸ https://twitter.com/moksony/status/809695818223681536
▸ https://www.sueddeutsche.de/muenchen/nahverkehr-darum-tropft-es-beim-s-
bahn-gleis-am-marienplatz-1.3330650
▸ https://www.br.de/nachrichten/bayern/s-bahn-chaos-in-muenchen-stoerung-
nach-wassereintritt-dauert-an,RYNZ6Kw
▸ https://twitter.com/sabbiafilms/status/912692514519502849
▸ https://www.monkeyuser.com/2018/final-patch
SOURCES
RCA (IMAGES) 2
▸ https://www.jaguarforums.com/forum/x-type-x400-14/multiple-codes-read-
puter-106645
▸ https://psychologyhumor.tumblr.com/post/165200208492/express-
psychotherapy
▸ https://michaelwtravels.boardingarea.com/2015/06/airline-fix-plane-duct-
tape-uses/travelnews-111
▸ https://www.solarwindsmsp.com/blog/results-show-controlnow-can-make-
department-proactive
SOURCES
RCA (IMAGES) 3
▸ https://www.monkeyuser.com/2018/root-cause
▸ https://medium.com/@m.azeem111/why-statement-c2a5b1f8b0fa
▸ https://brightpast.com/how-to-use-social-media-for-proactive-reputation-
management
SOURCES
MAKE IT WORK, MAKE IT RIGHT, MAKE IT FAST.
▸ https://www.thetombomb.com/2018/05/17/make-it-work-make-it-right-make-
it-fast
▸ http://engineerspro.blogspot.com/2016/06/career-information-regarding-
mechanical.html
▸ https://www.pixwords.solutions/tl/solution/pagliko
▸ https://www.donanimhaber.com/spacex-falcon-roketine-ait-parcanin-dunya-ya-
dustugu-anin-videosunu-yayinladi--115810
SOURCES
IT’S HARDER TO READ CODE THAN TO WRITE IT.
▸ https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-
part-i
SOURCES
BUILD YOUR LOGIC ON DIRECT RELATIONS, NOT ON ASSUMPTIONS.
▸ https://www2.le.ac.uk/institution/lias/images/Fellows%203.jpg/view
▸ https://medium.com/@CodementorIO/good-developers-vs-bad-developers-
fe9d2d6b582b
SOURCES
SUMMARY & SOURCES
▸ https://code.tutsplus.com/tutorials/3-key-software-principles-you-must-
understand--net-25161
▸ https://en.wikipedia.org/wiki/Analysis_paralysis
▸ https://www.mr-maid.com/blog/hiring-bad-cleaning-service
▸ https://www.acadoo.de/woran-erkenne-ich-serioese-quellen.html
▸ https://en.wikipedia.org/wiki/LOLCODE
KTHXBYE
CLEAN(ER) CODE

Clean(er) Code - Tech'n'Drinks @myposter

  • 1.
  • 2.
    ABOUT ME MARTIN “D4RK”STRAUB ▸ iOS developer @myposter ! ▸ Guitar player @kentuckyschreit (ska/pop-punk) 🎸 ▸ Husband 💑 ▸ Cat 😺
  • 7.
    ABOUT ME MARTIN “D4RK”STRAUB ▸ ... ▸ ... ▸ martin-straub.de ▸ iOS developer @myposter ! ▸ Guitar player @kentuckyschreit (ska/pop-punk) 🎸 ▸ Husband 💑 ▸ Cat 😺
  • 8.
  • 9.
    EVERY PIECE OFKNOWLEDGE MUST HAVE A SINGLE, UNAMBIGUOUS, AUTHORITATIVE REPRESENTATION WITHIN A SYSTEM. The Pragmatic Programmer DON’T REPEAT YOURSELF (DRY)
  • 10.
    DON’T REPEAT YOURSELF(DRY) WHAT’S IT ABOUT? ▸ Don’t repeat the knowledge ▸ Avoid contradictions ▸ One source of truth
  • 11.
    DON’T REPEAT YOURSELF(DRY) TYPES OF DUPLICATION ▸ Imposed duplication ▸ Inadvertent duplication ▸ Impatient duplication ▸ Interdeveloper duplication
  • 12.
    DUPLICATION IS FAR CHEAPERTHAN THE WRONG ABSTRACTION. Sandi Metz (Teacher, writer, consultant, programmer)
  • 13.
    A SYSTEM’S KNOWLEDGEIS FAR BROADER THAN JUST ITS CODE. DON’T REPEAT YOURSELF (DRY) The Pragmatic Programmer
  • 14.
    DON’T REPEAT YOURSELF(DRY) BROADER USAGE ▸ Database schemas ▸ Test plans ▸ Build system ▸ Documentation
  • 15.
  • 16.
    KEEP IT SIMPLESTUPID Kelly Johnson (Lead engineer at Lookheed Martin)
  • 17.
    KEEP IT SIMPLE,STUPID (KISS) WHAT’S IT ABOUT? ▸ Most systems work best if they are kept simple rather than made complicated ▸ Simplicity should be a key goal in design ▸ Unnecessary complexity should be avoided ▸ The end-user doesn’t care how smart you are ▸ If you have to explain the product, it’s too complicated
  • 18.
    MAKE EVERYTHING ASSIMPLE AS POSSIBLE, BUT NOT SIMPLER Albert Einstein KEEP IT SIMPLE, STUPID (KISS)
  • 19.
  • 20.
    YOU AIN’T GONNANEED IT (YAGNI) WHAT’S IT ABOUT? ▸ 80% of the time spent on a software project is invested in 20% of the functionality ▸ Prioritize (MoSCoW) ▸ No future coding ▸ No overengineering
  • 21.
    MUST HAVE SHOULD HAVE COULDHAVE WON’T HAVE (THIS TIME) MoSCoW principle
  • 22.
    DRY VS. KISS& YAGNI SUMMARY ▸ DRY strives for abstraction ▸ KISS aims for simplicity ▸ YAGNI doesn’t want to do it at all ▸ Those principles compete with each other ▸ Find the right balance between DRY and KISS/ YAGNI
  • 23.
  • 24.
    …USE A BUCKET! WATERDRIPS FROM THE CEILING?
  • 25.
  • 26.
  • 27.
    ROOT CAUSE ANALYSIS(RCA) 1. REACTIVE MANAGEMENT ▸ React quickly, by treating the symptoms ▸ Goal: Ease the effects of the problem as soon as possible
  • 31.
    ROOT CAUSE ANALYSIS(RCA) 2. PROACTIVE MANAGEMENT ▸ Address the real cause instead of its symptoms ▸ Goal: Prevent problems from (re-)occurring
  • 32.
    ROOT CAUSE ANALYSIS(RCA) ROOT CAUSE ANALYSIS ▸ Identification and description ▸ Chronology ▸ Differentiation ▸ Causal graphing ▸ Next step: Trigger long-term corrective actions
  • 33.
    BY REPEATING WHYFIVE TIMES, THE NATURE OF THE PROBLEM AS WELL AS ITS SOLUTION BECOMES CLEAR. Taiichi Ohno ROOT CAUSE ANALYSIS (RCA) (“Father” of the Toyota Production System)
  • 34.
    ROOT CAUSE ANALYSIS(RCA) 5 WHYS Example: Ran through a red light. (problem) ▸ Why? - Late for work. (1st why) ▸ Why? - Woke up late. (2nd why) ▸ Why? - Alarm clock didn’t ring. (3rd why) ▸ Why? - Battery was empty. (4th why) ▸ Why? - Forgot to charge it. (5th why and root cause)
  • 35.
    ROOT CAUSE ANALYSIS(RCA) CONCLUSION ▸ Reactive management: quickly ease the symptoms ▸ Proactive management: actually fix the issue ▸ Only the latter can lead to a sustainable and reliable code base
  • 36.
  • 37.
    MAKE IT WORK, MAKEIT RIGHT, MAKE IT FAST. Kent Beck (Software engineer, creator of extreme programming, TDD, …)
  • 38.
    IT’S HARDER TOREAD CODE THAN TO WRITE IT. Joel Spolsky (Co-founder of Stack Overflow)
  • 39.
    BUILD YOUR LOGICON DIRECT RELATIONS, NOT ON ASSUMPTIONS. Unknown author
  • 40.
    LOGIC DEPENDENCIES EXAMPLES ▸ App:Does the UI depend on the device’s orientation?
 ... or on parent view changes? ▸ Do you grab yourself a new beer every 15 minutes?
 … or every time the bottle’s empty?
  • 41.
  • 42.
    CLEAN(ER) CODE SUMMARY ▸ Playthe principle game ▸ BUT: ▸ Principles are not rules ▸ Find the right balance ▸ Always use common sense ▸ Don’t get paralysed by overthinking things
  • 43.
  • 44.
    SOURCES TITLE & ABOUTME ▸ https://twitter.com/ColucciLaw/status/1010920761043939328 ▸ martin-straub.de ▸ https://www.instagram.com/maezikatzi
  • 45.
    SOURCES DON’T REPEAT YOURSELF(DRY) ▸ https://pragprog.com/book/tpp/the-pragmatic-programmer ▸ https://thevaluable.dev/dry-principle-explained ▸ http://verraes.net/2014/08/dry-is-about-knowledge ▸ https://www.sandimetz.com/blog/2016/1/20/the-wrong-abstraction
  • 46.
    SOURCES DRY (IMAGES) ▸ https://www.flickr.com/photos/liveoncelivewild/32686776783 ▸https://medium.com/startup-grind/even-smart-vcs-invest-in-cross-industry- clones-6a3c63f830e4 ▸ https://www.engadget.com/2016/07/27/dolly-sheep-clones-are-healthy ▸ https://www.writermag.com/writing-inspiration/the-writing-life/declutter- hoarded-story-ideas
  • 47.
    SOURCES KEEP IT SIMPLE,STUPID (KISS) ▸ https://en.wikipedia.org/wiki/Kelly_Johnson_(engineer) ▸ https://www.interaction-design.org/literature/article/kiss-keep-it-simple-stupid- a-design-principle ▸ https://championingscience.com/2019/03/15/everything-should-be-made-as- simple-as-possible-but-no-simpler
  • 48.
    SOURCES KISS (IMAGES) ▸ https://archive.triblive.com/aande/music/kiss-makeup-has-changed-but-their- impact-remains-strong ▸https://mannerofspeaking.org/2018/03/11/simplicity-is-the-key-to-brilliance ▸ https://mostlyme-certainothers.com/2015/07/16/no-frills/simplicity-01
  • 49.
    SOURCES YOU AIN’T GONNANEED IT (YAGNI) ▸ https://ronjeffries.com/articles/019-01ff/iter-yagni-skimp ▸ https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it ▸ https://en.wikipedia.org/wiki/MoSCoW_method
  • 50.
    SOURCES YAGNI (IMAGES) ▸ https://www.monkeyuser.com/2019/yagni ▸https://www.developgoodhabits.com/80-20-rule ▸ http://www.thebluediamondgallery.com/wooden-tile/p/priority.html ▸ https://xkcd.com/974
  • 51.
    SOURCES ROOT CAUSE ANALYSIS(RCA) ▸ https://en.wikipedia.org/wiki/Root_cause_analysis ▸ https://en.wikipedia.org/wiki/5_Whys ▸ https://en.wikipedia.org/wiki/Taiichi_Ohno ▸ https://kanbanize.com/lean-management/improvement/5-whys-analysis-tool
  • 52.
    SOURCES RCA (IMAGES) ▸ https://twitter.com/moksony/status/809695818223681536 ▸https://www.sueddeutsche.de/muenchen/nahverkehr-darum-tropft-es-beim-s- bahn-gleis-am-marienplatz-1.3330650 ▸ https://www.br.de/nachrichten/bayern/s-bahn-chaos-in-muenchen-stoerung- nach-wassereintritt-dauert-an,RYNZ6Kw ▸ https://twitter.com/sabbiafilms/status/912692514519502849 ▸ https://www.monkeyuser.com/2018/final-patch
  • 53.
    SOURCES RCA (IMAGES) 2 ▸https://www.jaguarforums.com/forum/x-type-x400-14/multiple-codes-read- puter-106645 ▸ https://psychologyhumor.tumblr.com/post/165200208492/express- psychotherapy ▸ https://michaelwtravels.boardingarea.com/2015/06/airline-fix-plane-duct- tape-uses/travelnews-111 ▸ https://www.solarwindsmsp.com/blog/results-show-controlnow-can-make- department-proactive
  • 54.
    SOURCES RCA (IMAGES) 3 ▸https://www.monkeyuser.com/2018/root-cause ▸ https://medium.com/@m.azeem111/why-statement-c2a5b1f8b0fa ▸ https://brightpast.com/how-to-use-social-media-for-proactive-reputation- management
  • 55.
    SOURCES MAKE IT WORK,MAKE IT RIGHT, MAKE IT FAST. ▸ https://www.thetombomb.com/2018/05/17/make-it-work-make-it-right-make- it-fast ▸ http://engineerspro.blogspot.com/2016/06/career-information-regarding- mechanical.html ▸ https://www.pixwords.solutions/tl/solution/pagliko ▸ https://www.donanimhaber.com/spacex-falcon-roketine-ait-parcanin-dunya-ya- dustugu-anin-videosunu-yayinladi--115810
  • 56.
    SOURCES IT’S HARDER TOREAD CODE THAN TO WRITE IT. ▸ https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do- part-i
  • 57.
    SOURCES BUILD YOUR LOGICON DIRECT RELATIONS, NOT ON ASSUMPTIONS. ▸ https://www2.le.ac.uk/institution/lias/images/Fellows%203.jpg/view ▸ https://medium.com/@CodementorIO/good-developers-vs-bad-developers- fe9d2d6b582b
  • 58.
    SOURCES SUMMARY & SOURCES ▸https://code.tutsplus.com/tutorials/3-key-software-principles-you-must- understand--net-25161 ▸ https://en.wikipedia.org/wiki/Analysis_paralysis ▸ https://www.mr-maid.com/blog/hiring-bad-cleaning-service ▸ https://www.acadoo.de/woran-erkenne-ich-serioese-quellen.html ▸ https://en.wikipedia.org/wiki/LOLCODE
  • 59.