I have been seeking to develop habits / follow a system to increase code quality, both in terms of readability and number of functional issues. I have come up with a few ideas I have listed below but I am curious what other people have been trying out! Have any of the below worked for you? What specific steps do you take to ensure code quality?
+1 for Jonathan's suggestions!
Another thing I do when I write code is think about how future versions of this code could potentially look like. For example, if I'm implementing a new feature that may be extended or modified in the future, how easy would it be for that new change to be made? How could these potential future changes affect the rest of the system (in terms of backwards compatability, performance, readability, etc)? The answer to these questions not only give a lot of information in how my code should be structured, but they can also guide your solution to be as future-proof as possible.
Also, as a general tip, I structure most of my PRs to have these sections:
Explicitly writing these out in a PR description helps make sure I - and everyone reviewing my code - clearly understands the context and thought process behind the code changes.
The general steps I follow are:
The 3 items you have listed are spot-on 👏 . If you implement all of those, you will get promoted from junior to mid-level in no time!
It's so hard sharing new insight on top of what's already in the original question and everyone else's great comments, but I was able to come up with this one: Look at other PRs in the same area and proactively learn from them.
So let's say you're submitting a commit to modify module X:
I recommend these resources as well to learn this concept and the others mentioned here more in-depth:
Melissa and Jonathan already did a great job (I’m especially a fan of small, atomic cl/pr/diff!)
I would add that if your team has an agreed upon style guide or something similar, attempt to apply that onto your cls. If you don’t really know how to do this or your team doesn’t have a style guide, try the following instead:
Look through your past changes and the comments your reviewers left. Do you observe a pattern of similar comments? (Is it… lots of naming adjustments, unit test structure, or something else?) Focus on getting better at a specific set of feedback and ask yourself if your new cl has similar problems to prior ones. In general, try not to have your reviewer point out the same problem 3 times in a row, and past comments are a great source of learning about what kind of mistakes you tend to make.