pycon 2015 - technical debt - the monster in your closet
TRANSCRIPT
![Page 1: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/1.jpg)
TECHNICAL DEBT !
THE CODE MONSTER IN YOUR CLOSET
Nina Zakharenko@nnja
![Page 2: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/2.jpg)
WHAT IS TECHNICAL
DEBT?
![Page 3: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/3.jpg)
(BOTH BUSINESS & TECHNICAL)
A SERIES OF BAD DECISIONS
![Page 4: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/4.jpg)
WHICH LEAD TOERROR PRONE CODE
& ARCHITECTURE
![Page 5: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/5.jpg)
… AND USING MORE
TO ACCOMPLISHRESOURCES
LESS
![Page 6: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/6.jpg)
What decisions were made in the past
![Page 7: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/7.jpg)
that prevent me from getting sh** done today?
![Page 8: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/8.jpg)
WHAT CAUSES IT?
![Page 9: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/9.jpg)
ME.AND YOU.
![Page 10: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/10.jpg)
Mistakes I Made Early On
Not knowing how to say NO to features
Not seeing the value in Unit Tests
![Page 11: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/11.jpg)
Mistakes I Made Early On
Overly Optimistic Estimates
Putting releases over good design & reusable code
![Page 12: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/12.jpg)
TIME CRUNCH
The project was due yesterday!
I’ll take a shortcut, and clean up the mess tomorrow.
![Page 13: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/13.jpg)
UNNEEDED COMPLEXITY
Lines of code committed != amount of work accomplished.
![Page 14: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/14.jpg)
Step 1: Have a problem.
Step 2: Look up How to do it on Stack Exchange
LACK OF UNDERSTANDING
Step 3: Copy and Paste it into your codebase
Step 4: ???
Step 5: Bugs!
![Page 15: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/15.jpg)
CULTURE OF DESPAIR
This is already a heap of trash.
Will anyone really notice if I add something to the top?
![Page 16: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/16.jpg)
RED FLAGSHouston, We Have a Problem.
![Page 17: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/17.jpg)
CODE SMELLS?
Not bugs.
An indication of a deeper problem.
![Page 18: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/18.jpg)
CODE SMELLS
• Half implemented features • No or poor documentation
![Page 19: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/19.jpg)
CODE SMELLS
• Commented out code, incorrect comments • No tests or broken tests
![Page 20: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/20.jpg)
POOR DOCUMENTATIONclass OrganicGlutenFreePizzaFactory: def get_dough(self): """ Return amazing, organic, GMO and Gluten Free Dough """ # ran out of organic gluten free, use the other stuff. !
# return 'organic gluten free dough' return 'gmo white pesticide dough'
![Page 21: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/21.jpg)
ARCHITECTURE & DESIGN… SMELLS
• Parts of the code that no one wants to touch • Changing code in one area breaks other parts of the
system • Severe outages caused by frequent & unexpected
bugs
![Page 22: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/22.jpg)
GOOD DESIGNImplementing new features comes easily.
BAD DESIGNShoe-horning new features into the system.
![Page 23: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/23.jpg)
PYTHON SPECIFIC SMELLS
![Page 24: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/24.jpg)
Functionality Changes, Variable names Don’t.
employees = ['John', 'Mary', 'Dale'] !
employees = 'Bob' !
employees[0]
![Page 25: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/25.jpg)
Monkey Patching
def new_init(self): pass !
some_library.SomeClass.__init__ = new_init
![Page 26: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/26.jpg)
What exactly does that decorator do?def decorator_evil(target): return False !
@decorator_evil def target(a,b): return a + b !
>>> target False !
>>> target(1,2) TypeError: 'bool' object is not callable
![Page 27: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/27.jpg)
Circular Dependencies
def some_function(x): from some.module import some_method some_method(x)
![Page 28: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/28.jpg)
CASE STUDIES
![Page 29: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/29.jpg)
IRS CHIEF:
"We Still Have Applications That Were Running When JFK Was President"
![Page 30: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/30.jpg)
50 Year old Technology
"And we continue to use the COBOL programming language, it is extremely difficult to find IT experts who
are versed in this language.”
![Page 31: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/31.jpg)
It’s not just the IRS.
Banks & Financial Insitutions Universities
Air Traffic Control !
… all use COBOL.
![Page 32: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/32.jpg)
STORY TIME
I used to work in finance.
At the time I was there, all of the banking systems were run on mainframes.
The bankers were getting frustrated. They wanted a UI.
![Page 33: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/33.jpg)
IDEA!
Let’s write a fancy new web front end.
It’ll do ALL the things.
![Page 34: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/34.jpg)
BUT
Rewriting the backend is too expensive. !
It already does what we need. !
Let’s leave the mainframe.
![Page 35: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/35.jpg)
CURSORS
The mainframe would output a text screen from a program result, based on a query.
The results would be parsed by reading variables from the screen in certain positions.
![Page 36: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/36.jpg)
RESULT?
The new system was incredibly slow.
And error prone.!
After months of work, the multi-million dollar rewrite was scrapped.
![Page 37: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/37.jpg)
YOU CAN PUT LIPSTICK ON A PIG
![Page 38: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/38.jpg)
THE MVP
(Minimum Viable Product)
Get the product to early customers as soon as possible.
![Page 39: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/39.jpg)
A GREAT IDEA
I worked on a project that was created by a lone developer in a coffee fueled 48 hours.
It was a great success.
![Page 40: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/40.jpg)
THERE WAS A PROBLEMYears went on, but the initial code and design didn’t go
away.Instead, it became the base for an expanding project,
with expanding features.
Worse, there was never any time to refactor.
![Page 41: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/41.jpg)
SCOPE CREEP
Features that someone thought was a good idea one day, stuck around forever.
“In case we need them. Later.”
![Page 42: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/42.jpg)
SAD DEVELOPERS
That made it feel like your fault.
When a release was pushed, something was bound to break.
There were no working tests.
![Page 43: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/43.jpg)
GRINDING TO A HALT
Development time for new features skyrocketed.
The project was deemed too difficult to maintain.
… and cancelled.
![Page 44: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/44.jpg)
SOMETIMES YOU NEED TO BURN IT. WITH FIRE.
![Page 45: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/45.jpg)
BATTLING THE MONSTER
![Page 46: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/46.jpg)
Technical Debt is a team-wide problem.
Everybody needs to be a part of the solution.
DON’T POINT FINGERS
![Page 47: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/47.jpg)
WORK TOGETHER
Code Standards
Pair Programming
Code Reviews
![Page 48: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/48.jpg)
Unless something is on fire, or you’re losing money, unreviewed code should never be merged into master.
![Page 49: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/49.jpg)
STAY ACCOUNTABLEUnit & Integration Tests
Pre-Commit Hooks
Continuous Integration
![Page 50: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/50.jpg)
SELL IT TO MANAGEMENT
By allocating some project time to tackling debt, the end result will be less error prone, easier to maintain,
and easier to add features to.
![Page 51: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/51.jpg)
TIME
COST
Source: https://msdn.microsoft.com/en-us/magazine/ee819135.aspx
NOT BROKEN, WHY FIX IT?
![Page 52: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/52.jpg)
SKI RENTAL PROBLEM
You’re going skiing for an unknown number of days. !
It costs $1 a day to rent, or $10 to buy.
Source: http://en.wikipedia.org/wiki/Ski_rental_problem
![Page 53: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/53.jpg)
Technical debt frustrates developers.
Frustrated developers are more likely to leave.
THERE’S ANOTHER COST
Hiring developers is hard.
![Page 54: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/54.jpg)
Figure out the project tolerance and work with it.
Don’t be a perfectionist.
Some lingering technical debt is inevitable.
![Page 55: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/55.jpg)
Use these arguments to justify the additional time it takes you to do things right.
![Page 56: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/56.jpg)
“Always code as if the guy who ends up maintaining your code will be a violent
psychopath who knows where you live.”
- Martin Golding@
![Page 57: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/57.jpg)
TO WIN THE FIGHT
PAY DOWN YOUR DEBT
![Page 58: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/58.jpg)
PRIORITIZE
What causes the biggest & most frequent pain points for developers?
![Page 59: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/59.jpg)
What is the life expectancy of this project?
longer shelf life —> higher interest
SHELF LIFE
![Page 60: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/60.jpg)
Just like with monetary debt, pay off the high interest loan first.
![Page 61: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/61.jpg)
If you don’t have to pay it off, you got something for nothing.
Technical Debt can be strategic.
![Page 62: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/62.jpg)
Is the single greatest tool in your toolbox.
REFACTORING
![Page 63: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/63.jpg)
Systematically changing the code without changing functionality, while improving design and readability.
WHAT IS IT?
![Page 64: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/64.jpg)
Slow and steady wins the race.
REFACTORING
The end goal is to refactor, without breaking existing functionality.
![Page 65: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/65.jpg)
Replace functions and modules incrementally.
REFACTORING
Test as you go.
Tests are MANDATORY at this step.
![Page 66: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/66.jpg)
How you make time for refactoring depends on the size of your team.
MAKING TIME
(And the size of your problem)
![Page 67: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/67.jpg)
Devote a week every 6 - 8 weeks.SMALL
MEDIUMDevote a person per week, rotate.
LARGEEveryone devotes 10% of their time.
![Page 68: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/68.jpg)
A FEW LAST TIPS
![Page 69: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/69.jpg)
CODE IS FOR HUMANS
Source: http://despairsoftware.blogspot.com/2014/05/engineering-principles-software-best.html
Despite common misconception, code is not for computers.
!
Code is for humans to read.
![Page 70: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/70.jpg)
DON’T REPEAT YOURSELF
Source: http://despairsoftware.blogspot.com/2014/05/engineering-principles-software-best.html
If being DRY requires mind-bending backflips and abstractions, stop.
(BUT)
![Page 71: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/71.jpg)
THE BOY SCOUT RULEThe Boy Scouts have a rule: "Always leave the
campground cleaner than you found it."
Source: http://programmer.97things.oreilly.com/wiki/index.php/The_Boy_Scout_Rule
"Always check a module in cleaner than when you checked it out."
![Page 72: Pycon 2015 - Technical Debt - The Monster in Your Closet](https://reader037.vdocuments.us/reader037/viewer/2022102315/55a53cb01a28ab325e8b45f8/html5/thumbnails/72.jpg)
EXPECT TO BE FRUSTRATEDThe process of cleaning up days / months / years
of bad code can be analogous with untangling a ball of yarn.
!
Don’t give up.