Three Types of Source Code Modifications

Some random notes I’ve written on the Ilab Simics project mailing list.

There are three types of changes to source code made by programmers during active development.

  1. No new features are added, no bugs are fixed; only renames of functions/variables, splitting/merging of files, adding/removing spaces and formatting etc. This is called refactoring. It is important to periodically restructure code to make it easier to work with it.
  2. No new features are added, but bugs in existing code are fixed instead. That is, changes are made to functionality already present but proved to be incorrect. It is called bug fixing. Typically, it should not be accompanied with renaming, or adding spaces etc — that is, with refactoring activities.
  3. Work is done towards adding new functionality, i.e., to make it do something that it never did before. This is called feature development. As above, it should not include bug fixing or refactoring elements.

The general rule is: a single commit should be either a refactoring, a bug fixing, or a feature development, but not two or three of them. The reason is that these three activities are different by their nature.

Of course, it is impossible to adhere to this rule 100% of the time. But we all should try to limit a single commit to one type of activity. Meanwhile, a single pull request may have many commits of different types.

Update 12.10.2015: improved language (kinda)

Written by Grigory Rechistov in Uncategorized on 22.03.2015. Tags: programming,

Copyright © 2020 Grigory Rechistov