Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nina Zakharenko - Technical Debt - The code monster in everyone's closet

Nina Zakharenko - Technical Debt - The code monster in everyone's closet

Technical debt is the code monster hiding in everyone's closet. If you ignore it, it will terrorize you at night. To banish it and re-gain your productivity, you'll need to face it head on.

https://us.pycon.org/2015/schedule/presentation/424/

PyCon 2015

April 18, 2015
Tweet

More Decks by PyCon 2015

Other Decks in Programming

Transcript

  1. Mistakes I Made Early On Not knowing how to say

    NO to features Not seeing the value in Unit Tests
  2. TIME CRUNCH The project was due yesterday! I’ll take a

    shortcut, and clean up the mess tomorrow.
  3. 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!
  4. CULTURE OF DESPAIR This is already a heap of trash.

    Will anyone really notice if I add something to the top?
  5. POOR DOCUMENTATION class 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'
  6. 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
  7. 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
  8. 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.”
  9. 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.
  10. BUT Rewriting the backend is too expensive. ! It already

    does what we need. ! Let’s leave the mainframe.
  11. 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.
  12. RESULT? The new system was incredibly slow. And error prone.

    ! After months of work, the multi-million dollar rewrite was scrapped.
  13. 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.
  14. THERE WAS A PROBLEM Years 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.
  15. SCOPE CREEP Features that someone thought was a good idea

    one day, stuck around forever. “In case we need them. Later.”
  16. SAD DEVELOPERS That made it feel like your fault. When

    a release was pushed, something was bound to break. There were no working tests.
  17. GRINDING TO A HALT Development time for new features skyrocketed.

    The project was deemed too difficult to maintain. … and cancelled.
  18. Technical Debt is a team-wide problem. Everybody needs to be

    a part of the solution. DON’T POINT FINGERS
  19. 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.
  20. 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
  21. Technical debt frustrates developers. Frustrated developers are more likely to

    leave. THERE’S ANOTHER COST Hiring developers is hard.
  22. Figure out the project tolerance and work with it. Don’t

    be a perfectionist. Some lingering technical debt is inevitable.
  23. “Always code as if the guy who ends up maintaining

    your code will be a violent psychopath who knows where you live.” - Martin Golding @
  24. What is the life expectancy of this project? longer shelf

    life —> higher interest SHELF LIFE
  25. If you don’t have to pay it off, you got

    something for nothing. Technical Debt can be strategic.
  26. Slow and steady wins the race. REFACTORING The end goal

    is to refactor, without breaking existing functionality.
  27. How you make time for refactoring depends on the size

    of your team. MAKING TIME (And the size of your problem)
  28. Devote a week every 6 - 8 weeks. SMALL MEDIUM

    Devote a person per week, rotate. LARGE Everyone devotes 10% of their time.
  29. THE BOY SCOUT RULE The 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."
  30. EXPECT TO BE FRUSTRATED The process of cleaning up days

    / months / years of bad code can be analogous with untangling a ball of yarn. ! Don’t give up.