Good Practices

Debugging

  1. Even if it's seemed bad, often a Printf is quicker than a debugging tool
  2. Logging data is important: a debug mode should always be available for medium to big programs.
  3. git-diff is a good friend, that the first step to debugging

Fix issues

  1. When debugging docker run issues, if something vanishes, looking at the volumes is a really nice practice.
  2. Take your time before reaching conclusions. Having a reproduce state of the bug is important.

Coding style

  1. The style is often subjective. However, it matters to stay consistent.

Coding methods

  1. Pencils and papers are your friends, feel free to fill a lot of them with notes, graphs or anything relevant: it frees your mind.
  2. A good way to design a good API is actually to try to explain it with documentation ie. always start by a .mli, give a few hints on the general idea behind the API and give a few explanations on how users are supposed to use it. Writing a few examples is always a good way to find the right function and types names and the proper API to compose them (quote @samoht).

Adding new features

  • It is better to write some code, even bad one, to make a feature working than not writing anything. Start with a functional version and then clean the code. At least, you would have a functional version to compare against.
  • It can be easier to add the code at the top of the function call list than at the bottom. Refine later to get the functionality closer to what you need.
  • The goal is to have a working feature. Thus, focus on this! The code is the means, not the end goal.

Understanding code

  • By adding functionalities, fixing bug or breaking the code, you will construct a mental model of the project. Don't be afraid to break things to understand the behavior (not in production, of course).

DevOps

  1. NEVER DEPLOY on Fridays, NEVER.
  2. If the code you deploy writes in the file system, try with a subset to make sure it has the correct rights.

Don't be a dummy

  1. Ensure you call the correct executable or library.
  2. Check if the features you want to test are activated.

Resources