Semantic Versioning

In the world of software management there exists a dread place called “dependency hell.” The bigger your system grows and the more packages you integrate into your software, the more likely you are to find yourself, one day, in this pit of despair.
In systems with many dependencies, releasing new package versions can quickly become a nightmare. If the dependency specifications are too tight, you are in danger of version lock (the inability to upgrade a package without having to release new versions of every dependent package). If dependencies are specified too loosely, you will inevitably be bitten by version promiscuity (assuming compatibility with more future versions than is reasonable). Dependency hell is where you are when version lock and/or version promiscuity prevent you from easily and safely moving your project forward.
As a solution to this problem, I propose a simple set of rules and requirements that dictate how version numbers are assigned and incremented. For this system to work, you first need to declare a public API. This may consist of documentation or be enforced by the code itself. Regardless, it is important that this API be clear and precise. Once you identify your public API, you communicate changes to it with specific increments to your version number. Consider a version format of X.Y.Z (Major.Minor.Patch). Bug fixes not affecting the API increment the patch version, backwards compatible API additions/changes increment the minor version, and backwards incompatible API changes increment the major version.
I call this system “Semantic Versioning.” Under this scheme, version numbers and the way they change convey meaning about the underlying code and what has been modified from one version to the next.

 

 

With respect to software versioning, patching will upgrade a software’s maintenance version number, and updates upgrade their minor version number.
In most cases, the versioning follows this pattern:

Major.Minor.Maintenance.Build

Where the first three are single digit, the last three or four digit. So a version number 2.1.1.089 is the second major version, first minor revision (so there has been one update), third maintenance build (so three patches), and build 089 (no significance to builds/patches).
In most cases, patches update the third number, the maintenance version. Updates update the minor version number. Furthermore, patches usually fix problems, whereas updates can both fix problems as well as add new features.
The Wikipedia article on software versioning is an interesting read. The reason I specify the M.M.M.B style is that it is commonly used in Visual Studio during application development.
In some cases, however, the last number (build) is omitted – for end users, rarely is this ever needed. It’s mostly for development purposes only.

This entry was posted in Best Practices. Bookmark the permalink.

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s