Software Engineering Best Practices
2 min readJul 20, 2022
- Always refactor your code after you get it working.
- Always group related functions into modules.
- Codes that you are likely to use always, put them in functions and avoid unnecessary repetition.
- Use meaningful variable names and any available inbuilt functions than reinventing the wheel, i.e. your code should observe DRY (don’t repeat yourself) principle.
- Use whitespace properly.
- Organize your code with consistent indentation
- Separate sections with blank lines to make it easier to organize and read.
- Limit your lines to about 79 characters as given in the Product Engineering Process (PEP) 8 style guide.
- Minimize the number of entities like functions, classes and modules i.e. do not over modularize, only modularize what is necessary.
- Make sure each function you write is focused on doing one thing.
- Arbitrary variable names can be more effective in certain functions.
- Try to use fewer than (not more than) three arguments per function.
- Document your codes at inline level (line comments), function or module level (docstrings) and project level(README files).
- Test your codes to catch errors or faulty conclusions.
- Follow the test driven development (TDD) approach, i.e. write your tests and have them fail and code your functions to make your test pass.
- Make your logging messages professional, clear and concise.
- Use normal capitalization in your logging messages.
- Choose the appropriate level of logging. Debug for anything that happens in the program, Error for errors that occur in the program and Info for all actions that are user driven or system specific.
- Ensure your codes are reviewed before pushing to production.
- Ensure that errors are handled gracefully.
- Vectorize as much as possible instead of using loops, i.e. ensure to employ your data structures in problem solving than always looping to achieve the solution.
- Use a code linter like pylint for python (every platform have a code linter for it, e.g. for javascript is ESLINT) to ensure adherence to coding styles and style guides.
Get Opara Febechukwu C.’s stories in your inbox
Join Medium for free to get updates from this writer.





