To maintain high-quality and readable code with a longer shelf life in a collaborative environment, writing code to allow a program to run without errors is not enough.
After writing your piece of code, ask a few questions to improve your code quality.
Is the code clean and modular?
* Can I understand the code easily?
* Does it use meaningful names and white space?
* Is there a duplicated piece of code?
* Can you provide another layer of abstraction?
* Is each function and module necessary?
* Is each function or module too long?
Is the code efficient?
* Are there loops or other steps we can vectorize?
* Can we use better data structures to optimize any steps?
* Can we shorten the number of calculations needed for any steps?
* Can we use generators or multiprocessing to optimize any steps?
Is the documentation effective?
* Are in-line comments concise and meaningful?
* Is there a complex piece code that’s missing documentation?
* Do function use effective docstrings?
* Is the necessary project documentation provided?
Is the code well tested?
* Does the code high test coverage?
* Do tests check for interesting cases?
* Are the tests readable?
* Can the tests be made more efficient?
Is the logging effective?
* Are log messages clear, concise, and professional?
* Do they include all relevant and useful information?
* Do they use the appropriate logging level?
These questions will definitely help you think critically about the pieces of code that you wrote, and improve the code if needed.