Skip to main content

Some considerations in writing good code is also thinking about how you will comment the code so that you can search the code.

Let's take this for example, you are working on a web application and you want to check the settings of the code that is on the system.


grep -n "_DIR\" /srv/code/webapp/settings/base.py | head -5

Here we are a passing a set of arguments to the system of Bash, because we want to understand what the settings are.

/srv/code/webapp/settings/base.py-17-
/srv/code/webapp/settings/base.py:18:PROJECT_DIR = Path(__file__).resolve().parent.parent
/srv/code/webapp/settings/base.py:19:BASE_DIR = PROJECT_DIR.parent
/srv/code/webapp/settings/base.py-20-
/srv/code/webapp/settings/base.py-21-
/srv/code/webapp/settings/base.py-22-# Quick-start development settings - unsuitable for production
/srv/code/webapp/settings/base.py-23-# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/
/srv/code/webapp/settings/base.py-24-


And what we get in return is what line of code something is on.
And it makes sense to write references to a link, this way you can navigate to that link, from the terminal.

You can then make the change to the line of code, using the tool of choice (IDE, Text editor) and cite your references.
This lets you clearly scope the code you are writing.