PyUtrecht: Repos are like children, parenting 101 - Bart Dorlandt

Tags: pun, python

(One of my summaries of the Dutch PyUtrecht meetup in Utrecht, NL).

Parenting and coding: choices have an effect. What is the outcome of your work? How does it turn out? But in the end you want to be proud of the outcome. You want your child/code to turn out right. With code, the effect of your decisions is clear reasonably quickly, with children it takes some more time.

One repo turns into two repos and into three. And more. How do you keep them all the attention they deserve? How do you keep them up to date?

  • Describe your child (=readme).

  • Keep a journal (=changelog).

  • Easy maintenance and easy to work with.

Kids need boundaries. They need to know how to behave! Likewise, your code needs to behave: you need tests to set boundaries.

After a while, your kid is old enough to go to school. Four years old or so. Hurray: you suddenly have more free time! Apparently your code is still alive! Potty training accomplished. Is your child/code ready to be shared with a wider public? But are you ready for others to make changes to your child?

Some things are standard (or should be standard) for most code:

  • Dependency management. requirements.txt, pipfile, uv.

  • Standardisation. Black, ruff, pylance, pyright.

  • Tests: pytest, unittest. (And look at bdd).

  • Pipelines. Gitlab/github, pre-commit, jenkins.

For a good setup, use a template: cookiecutter or copier. You basically start with a ready-made baby of one year old and you skip all the diapers :-)

Children change. Their environment changes. They get new needs (“I want a PS5!”).

  • Renovatebot, dependabot for auto-dating. Basically you can have your kid come to you for an update.

  • You can have your child use several different environments with “nox” and “tox”.

When your child grows older, they need different kinds of attention. And more education. You want them to get a bit more independent. Tests are important to make sure everything works. Perhaps some automated merges can be set up.

In the end, they grow up so quickly! Be an example. Make sure your code is neat. How do you want to be remembered? Through your children. Especially as a freelancer, you want to remembered by your great code. It should be an easy child with clear documentation and clear examples. No surprises. Clean code, tests, no security leaks. Low maintenance.

 
vanrees.org logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):