the benefit of sneezing code into an editor vs clean code
DESCRIPTION
Balancing technical debt and getting things done is one of the hardest problems we have. When should we write beautiful, elegant, clean code and when should we just hammer away blindly at the keyboard until it's done? This talk goes in to why this balance is so difficult and covers everything from estimations to refactoring and testing, with a focus on real world PHP apps.TRANSCRIPT
![Page 1: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/1.jpg)
The Benefit of Sneezing Code Into an Editor vs Clean Code
#sneezingcodejoind.in/11457
@dave1010Dave Hulbert
![Page 2: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/2.jpg)
@dave1010Dave Hulbert
![Page 3: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/3.jpg)
The Benefit of Sneezing Code Into an Editor vs Clean Code
![Page 4: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/4.jpg)
The Benefit of Sneezing Code Into an Editor vs Clean Code
![Page 5: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/5.jpg)
The Benefit of Sneezing Code Into an Editor vs Clean Code
![Page 6: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/6.jpg)
Balance
![Page 7: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/7.jpg)
Balance
![Page 8: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/8.jpg)
Balance
![Page 9: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/9.jpg)
Balance
![Page 10: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/10.jpg)
Delivering fast is good
![Page 11: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/11.jpg)
Good code is good
![Page 12: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/12.jpg)
Analogy
![Page 13: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/13.jpg)
![Page 14: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/14.jpg)
Aims
● How to run fast (in general)● How to sprint (sneeze)● How to run a marathon (clean code)● Why you should sprint● Why you should run a marathon
![Page 15: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/15.jpg)
How to run fast (in general)
● Developers– Skilled, Passionate, Healthy, Focused, Disciplined– (Relevant) conferences, user groups (hello)– Read books, blogs, code– Write code, Open Source contributions
![Page 16: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/16.jpg)
How to run fast (in general)
● Projects– Good communication– Good specifications / requirements– Fast feedback– Good clients
![Page 17: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/17.jpg)
![Page 18: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/18.jpg)
How to run slow (in general)
● Complexity– Code / System
● Bad / slow / no tests● Bugs● Lack of investment
– Servers / Workstations / Software
![Page 19: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/19.jpg)
How to run slow (in general)
● Interruptions● Being blocked / waiting● Internal processes● Too many meetings
![Page 20: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/20.jpg)
Aims
● How to run fast (in general)● How to sprint (sneeze)● How to run a marathon (clean code)● Why you should sprint● Why you should run a marathon
![Page 21: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/21.jpg)
How to sprint (sneeze)
● What is sprinting?
![Page 22: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/22.jpg)
How to sprint (sneeze)
● Overtime● Ignore everything else● Reduce tests / testing● Reduce planning● Reduce communication● Outsource● Cut corners● Focus; don't improve tools / processes● Outsource
![Page 23: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/23.jpg)
![Page 24: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/24.jpg)
![Page 25: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/25.jpg)
![Page 26: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/26.jpg)
Technical Debt
● What is technical debt?
![Page 27: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/27.jpg)
![Page 28: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/28.jpg)
![Page 29: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/29.jpg)
Causes of technical debt
● Deciding to release before it's ready● Deciding to use a RAD framework● Deciding to skip tests & documentation● Lack of understanding (requirements, code)● Premature optimisation● Software entropy
![Page 30: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/30.jpg)
Consequences of technical debt
● Interest; interest on interest● More time on maintenance● Less time on new features● Harder to estimate new features● Miss deadlines
![Page 31: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/31.jpg)
![Page 32: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/32.jpg)
![Page 33: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/33.jpg)
Aims
● How to run fast (in general)● How to sprint (sneeze)● How to run a marathon (clean code)● Why you should sprint● Why you should run a marathon
![Page 34: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/34.jpg)
How to run a marathon(clean code)
● Non-code speed-ups: time & money investment– Staff training– Tools and processes– Planning / requirements
![Page 35: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/35.jpg)
![Page 36: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/36.jpg)
![Page 37: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/37.jpg)
![Page 38: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/38.jpg)
How to run a marathon(clean code)
● Clean Code (Uncle Bob)– SOLID
● TDD– Run every bit of code that you write, ASAP
● DDD– Model the domain completely in PHP classes that
don't touch the UI, database or framework
![Page 39: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/39.jpg)
![Page 40: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/40.jpg)
![Page 41: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/41.jpg)
![Page 42: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/42.jpg)
Refactoring
![Page 43: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/43.jpg)
Refactoring
● Key to keeping up speed in big projects● Restructuring without changing behaviour● No direct measurable user benefit (not a user
story)● Makes it easier to read, understand, test,
change, add new features to● IDE makes refactoring easier
![Page 44: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/44.jpg)
![Page 45: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/45.jpg)
Refactoring
● Inject dependencies● Decouple (fewer “use” statements)● Create interfaces to type hint to● Extract functions● Rename● Reduce cyclomatic complexity (number of
if/else/for/foreach/while/switch in a method)● Change depth of inheritance
![Page 46: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/46.jpg)
![Page 47: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/47.jpg)
Examples
● Journey Planner● User API
![Page 48: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/48.jpg)
Aims
● How to run fast (in general)● How to sprint (sneeze)● How to run a marathon (clean code)● Why you should sprint● Why you should run a marathon
![Page 49: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/49.jpg)
Why you should sprint
● Help you deliver faster in the short term● Long term strategy● MVP (prove a theory)● Disposable prototype
![Page 50: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/50.jpg)
Why you should sprint
● Treat your servers like cattle, not pets● Sometimes code is similar
![Page 51: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/51.jpg)
![Page 52: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/52.jpg)
Examples
● Laravel– RAD framework– Sacrifices SOLID code (a bit) for ease of use– Static “facades” (instead of using injected
dependencies)– $user->save() (instead of $userRepository-
>persist($user) )
![Page 53: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/53.jpg)
Examples
● WordPress– “5 minute install”– Low barrier to entry– Lots of themes and plugins
![Page 54: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/54.jpg)
Aims
● How to run fast (in general)● How to sprint (sneeze)● How to run a marathon (clean code)● Why you should sprint● Why you should run a marathon
![Page 55: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/55.jpg)
Why you should run a marathon
● Technical debt is a risk– Especially with big projects
● Quality is valuable● Deliver faster in the long term
![Page 56: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/56.jpg)
Aims
● How to run fast (in general)● How to sprint (sneeze)● How to run a marathon (clean code)● Why you should sprint● Why you should run a marathon
![Page 57: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/57.jpg)
Sprint vs Marathon
Sprint (example) Marathon (example)
Peripheral component (logs) Central component (DB)
Trivial (make a CSV) Complex (search algorithm)
Few consequences of bugs (game) Important (nuclear reactor)
Isolated (contact form) Reused (authentication)
Abandonable (migration script) Continued updates
One developer Big team
Time & money to pay technical debt later
Long term delivery
![Page 58: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/58.jpg)
Bonus: estimating
● Estimates for new features need to include refactoring– (if you don't want to increase technical debt)– Refactoring doesn't add perceived value so it's
hard to sell● Technical debt is expensive
– Sprint + paying technical debt interest costs more than running a marathon + continual refactoring
![Page 59: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/59.jpg)
Bonus: Testing
● TDD is about running your code ASAP● Write a test when you fix a bug● Fix bugs before writing new code (The Joel
Test)
![Page 60: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/60.jpg)
Wish list
● A script to track TODOs over time (Jenkins?)● A tool that helps you decide whether to
sprint or run a marathon
![Page 61: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/61.jpg)
Resources
● Books that I've read at least a few chapters of– Mythical Man-Month: Essays on Software Engineering,
Frederick Brooks– Clean Code: A Handbook of Agile Software
Craftsmanship, Robert C Martin– Implementing Domain-Driven Design, Vaughn Vernon– Modernizing Legacy Applications In PHP, Paul M.
Jones– More: http://amzn.to/Y29TAK
![Page 62: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/62.jpg)
Resources
● Refactoring http://refactoring.com/catalog/● Speed in Software Development
http://www.targetprocess.com/articles/speed-in-software-development.html
● Technical debt http://www.construx.com/10x_Software_Development/Technical_Debt/
● Images: HBO, Reddit, XKCD, the Internet
![Page 63: The benefit of sneezing code into an editor vs clean code](https://reader033.vdocument.in/reader033/viewer/2022052907/5593478f1a28ab8a398b4641/html5/thumbnails/63.jpg)
Thanks!
#sneezingcode
joind.in/11457
@dave1010
Dave Hulbert