I recently looked at an old habit sharing app I had written earlier this year. Even before opening up the repo I did not feel comfortable looking at it. Now that I have it open that feeling hasn’t gone away.
I recall so many places which could have been improved for the
sake of improved dev loop which just weren’t. Little documentation
and TODO
s strewn throughout make me want to throw the whole thing out and redo it.
Given it’s a small project I could but I think as a learning exercise I should probably grit my teeth and get to work cleaning this up.
But why do I feel this way?
Before juggling whether I should throw it all out or not I want to reflect on how the code (and I) got into this situation.
After some deliberation I believe it’s largely a lack of confidence in the code. Here are a couple of places there’s a lack of confidence.
It’s hard to feel confident making changes
Some of the tests I have create and delete files. As someone who’s forgotten how most things works I don’t feel confident “cleaning up” these files. Am I allowed to clean them up? I don’t know!
It’s hard to feel confident committing
I need to make sure I haven’t added
secret files that I shouldn’t commit. These files are muddled at the root of
the repo muddled with a bunch of important project configurations. The
.gitignore
protects me from accidentally committing and publishing secret
keys and files but it isn’t enough.
It’s hard to feel confident running the service locally
You wouldn’t expect this to be a big problem given the web app has very very few dependent services. The problem is running interesting experiments locally. Complex experiments require a sufficient amount of data, data that I don’t have easy access to.
Additionally I don’t have a script that will let me run all unit tests. Also the unit tests don’t cover enough for me to feel comfortable (looking at you past me 🌝).
Fixes for now and future
Here are some of the ideas I intend to implement to fix the above.
Turns out go test ./...
works to run all tests. Need to write that in the
read me. Might even make sense making a script to run it just so future me can
just check those scripts.
There’s a definite need to increase the amount of testing I’ve been doing. If there aren’t enough tests to make future me feel safe there certainly isn’t enough tests for others.
The deal with the random files lying around I think it makes sense to batch all
these into reasonable folders to keep the structure clean. It also helps the
.gitignore
which now just ignores the folder.
I don’t have integration tests and maybe that needs to change. I also feel there needs to be a fast way to populate the database with particular data and interesting structures. These scripts could then be used to simplify the creation of integration tests.