Tuesday 3:50 p.m.–4:40 p.m.

Inheriting a Sloppy Codebase: A Practical Guide to Wrangling Chaotic Code

Casey Kinsey

Audience level:



In an industry where “lean” has become the mantra and rapidly iterated products imply tight budgets and tighter deadlines, how do you effectively take ownership of someone’s hastily written Django code? In this talk, we’ll dive into a step-by-step process for dicing up legacy projects, short-sighted prototypes, and plain ol’ spaghetti code to turn them into codebases you’ll show off with pride.


Using my own first-hand experiences with project inheritance as a guide, we’ll talk about the causes of sloppy codebases to get an understanding of the events and mentality that lead to a project’s unkempt state. We’ll prepare ourselves and our team by discussing techniques for managing expectations and winning support for a refactoring of the project from stakeholders.

Then, its on to the process:

  • The Tools You’ll Need
    • We’ll cover code introspection tools like PyLint, Coverage.py, debuggers, and IDEs that will be instrumental in your code-wrestling adventure.
  • Test Coverage
    • We’ll discuss test coverage—what you need, what you don’t, and a plan to get there quickly.
  • Preparing The Project
    • There’s some housekeeping to get done before we start getting our hands dirty. We’ll make sure the project is ready for the big refactoring tasks ahead.
  • Dependency Round-up
    • We’ll identify unused, useless, and/or bloated dependencies that can be trimmed, and get our others (including Django) updated to the latest versions.
  • Slaying Monoliths
    • Now its time to start dissecting the codebase itself. We’ll cover the most common problems I’ve found in the wild and discuss tips for correcting them as painlessly as possible. Topics include import woes, migrating models across apps, “signals everywhere!”, and more.
  • Documentation Tips
    • We’ll discuss processes for documenting the codebase as we go both to help in our own refactoring, and for new developers/project owners in the future.
  • Re-writes and Optimization
    • With our monoliths laid to rest and a new, documented structure in place it’s time to review what we’ve found and refactor any major components.

Finally, we’ll talk about ongoing steps to take after the code is under control. We’ll touch briefly on provisioning and auditing deployment environments. Most of all, we’ll review what we’ve learned, and how it can make us stronger developers—whether we own the project, or we’re prototyping one to be passed on to the next guy.