Table Of Contents

Previous topic

What’s Next?

Next topic


This Page


Why refactoring?

First, what the hell is refactoring? The technical definition is explained nicely by Wikipedia. But in a nutshell, it’s a deliberate process of changing code so that it’s easier to understand and change in the future. Refactoring has a long and rich history and can get quite technical, but we use the term loosely here. We called this git repo/tutorial refactoring101 because it attempts to show how you can apply some basic principles and techniques to manage larger programs. These skills aren’t only useful for changing existing programs. They’re also a handy way of designing larger applications from the outset.

Who is this tutorial for?

We assume you’re already comfortable with basic programming concepts in Python. You understand loops, conditionals, variables, and basic data types (strings, integers, lists, dictionaries, even sets!). You’ve also written a few functions in your day. But you’re in that nether realm where you get the basics, but aren’t quite sure how to write larger programs. Or perhaps like many before you (we’ve all been there), you’ve written a monstrosity of a script that is error-prone, brittle, and hard to decipher. You suspect there must be a better way to craft large programs, but you’re not quite sure how. If you have that itchy feeling, this tutorial is for you.

How should I use this tutorial?

It’s an immersion exercise. This is not a tutorial where we walk through the code, explaining every step. We provide an overview of the code at each stage, and some teasers in the Questions and Exercises sections to nudge you toward new concepts and techniques. But ultimately, it’s up to you to read the code, research language features that are new or fuzzy, and experiment by modifying and running the scripts (and tests). That said, you’re not alone in the deep end. Hit us up on PythonJournos as you work through the tutorial. We’re friendly. We promise :)

Why did we write this?

Because like you, we’ve experienced the thrill of mastering the basics – writing those first few scripts to get things done – and the inevitable frustration of not knowing what comes next. How do I write a bigger program that does more than one thing? How do I know if some part of the program failed? How can I use this bit of code in another script, without having to update the code in both places? We’ve wrung our fists in the air over the same questions. Hopefully this tutorial helps nudge you toward some answers.

Who wrote this tutorial?

Jeremy Bowers and Serdar Tumgoren, nerds from the journalism community. Don’t be shy. Hit us up with questions, pull requests, angry criticisms, etc.

Am I alone?

That’s pretty deep. But we’re inclined to say no.