DEV Community

Discussion on: How I set my Linux computer for coding

Collapse
 
timepieces141 profile image
timepieces141

Well, I am 20 years into this and if there is one thing I could advise beginners, it's to write your unit tests from the very beginning. It's far easier to update a unit test than it is to take time out to write unit tests for an entire code base that is lacking them. And in languages that are interpreted instead of compiled, such as python, it's your quickest and easiest way to catch simple logical errors. And you get syntax and typo checks for free. Add in linting, and you have a simple workflow that produces an incredibly low rate of bugs. Saving time is the name of the game.

As for the virtual envs, I also see this as a way to reduce bugs - specifically dependencies in setup.py. While working, one might determine they need a library, install it, write the code, and move on, forgetting to add it to a requirements file. Creating a new virtual env from scratch to run your unit tests right before you push to git removes the potential for missing dependencies. And you can roll that whole process up into a script. I create an env, run pytest, run pylint, run coverage, run an HTML report, and destroy the env all in a bash script. That, or run it in a fresh docker container.