About two months ago I started writing some lessons for an Introduction to Programming class I was about to teach. I was using IPython Notebook to write those lessons, so I decided to put the notebooks on GitHub. I worked on the project pretty steadily, and soon passed my old GitHub record of 17 days. From then on, watching those little green boxes pile up got more and more addictive. Is it worthwhile to maintain a streak? I don’t want to keep it going forever, but it has definitely been worthwhile so far.
My main project at this point is Introduction to Python. Introduction to Python is an open resource for students who want to learn Python as their first language, and for teachers who want a free and open curriculum to use with their students. The project is growing steadily, both in terms of content and in terms of features that help students learn Python efficiently.
Improving my git workflow: branching
I have been a hobbyist programmer most of my life, which means I have worked mostly alone on my projects. When I started using git a few years ago, I began the bad habit of pushing all of my commits to master. This habit was great for starting a GitHub streak; it was easy to make a few commits each day, and some days I got to see some really dark green boxes show up. But as my project started to grow and attract some potential contributors, I started to feel really self-conscious about having such a cluttered master branch.
I knew about branches before, but had not practiced using them enough to make them part of my regular workflow. This streak has me using git every day, so it became harder and harder to put off using branches. Most of my commits involve adding content about how Python works, so many of these commits are quite appropriate to push directly to master, especially at this early stage. But one goal was to make the output of all sample code hidden by default, with a pair of show/ hide buttons below the sample code. This is a great learning feature; it allows students to predict the output of a code sample they are looking at, and then click a button to see if their prediction was correct. I am not a front-end guru, but I can find my way around js libraries and css hacks. Some of my commits while working on this feature would make no sense in master; they put buttons on the screen that didn’t do anything yet, and they put buttons on pages that had no output. So I did all this work on a feature branch, and then merged that to master. It was very satisfying to become more comfortable with a workflow I know will work well on a truly collaborative project.
A few other things I learned
I learned about a number of other things through pushing commits each day, and did some things I would not otherwise have gotten to:
- I started writing some of my non-programming curriculum on IPython Notebook, so that I could share it easily with students. I would like to learn to use a Python static site generator such as hyde, pelican, jinja, or nikola, but I didn’t have time to dig into that this month. There’s so much that can be done just using IPython Notebook markdown cells!
- I pushed the content on Introduction to Programming through making basic terminal applications. Now anyone who follows the curriculum starting at Hello World can learn to write simple terminal applications.
- I feel more and more connected to the programming world outside my small town in Alaska, where my students are the only people I know who write any code.
- I started writing tests! I wrote a test to verify that all links in this project are working. The default behavior is to start a SimpleHTTPServer and test the local working copy, but it accepts a flag to test all links on the deployed site. It does not yet test anchor tags, but just being sure that all links between pages and to external sites are not broken makes me more confident in the project overall. I also got to use Requests, which makes me feel like a Real Python Programmer.
- I found that I am much more likely to keep a project going. I started a really cool version of a text-based Adventure game, which starts out with the player standing on the front steps of our high school. Students and staff loved the first day’s progress. In the past I would have copied this to my computer and maybe done something with it. Instead I just threw it up on GitHub, and I have worked on it a couple times since then. The simple act of using GitHub every day makes it easy to keep interesting, nascent projects alive.
- I used Bootstrap 3.0, which I’ve been wanting to use in a project.
I’m going to try to keep this streak going a while longer, as long as it is keeping me productive and improving my professionalism in programming. In the next 30 days, I’d like to:
- Keep using branches. This is a no-brainer, for everything except content that should go directly into the project.
- Consider using pull requests. I know some people don’t merge any of their own branches, they submit all branches as pull requests, even if they are simply going to accept their own PR. I want to do this just to be more comfortable with the process of submitting and accepting PRs.
- Keep adding content to Introduction to Python.
- Finish the basic sections through Functions, Classes, Exceptions, and Testing.
- Complete the first project, a mapping visualization using matplotlib Basemap.
- Add more content around how to write programs. You’ve managed to learn a bunch of syntax, but how do you think through a project’s requirements and figure out how to start writing code?
- Clarify the section about setting up a programming environment: how to install linux on a donated computer, how to troubleshoot non-functioning Python environments, how to find help, etc.
- Do some non-github work. I have one non-open project that I need to make significant progress on. It’s hard to work on closed projects when you’ve been immersed in the open source world, but I have a pretty meaningful project to work on. I aim to balance the two, instead of focusing so much on just the open source work.