Beginner LevelSoftware Engineering Principles
How does Semantic Versioning (MAJOR.MINOR.PATCH) govern library releases?
❓ Interview Prompt: Explain Semantic Versioning (SemVer `v1.2.3`), MAJOR version breaking changes, MINOR features, PATCH fixes, and pre-release tags.
Semantic Versioning (SemVer) uses a 'MAJOR.MINOR.PATCH' format (e.g. '2.4.1') to communicate compatibility across software dependencies:
1
MAJOR (2.0.0): Incremented when making incompatible, breaking API changes.
2
MINOR (1.5.0): Incremented when adding backwards-compatible new functionality.
3
PATCH (1.4.2): Incremented when releasing backwards-compatible bug fixes.
•
Caret ('^1.2.3'): Accepts MINOR and PATCH updates ('1.x.x').
•
Tilde ('~1.2.3'): Accepts PATCH updates ONLY ('1.2.x').
Code Implementation Example
json
{
"name": "my-shared-library",
"version": "2.1.0",
"dependencies": {
"lodash": "^4.17.21"
}
}💡Semantic Versioning declaration in npm package.json.
🎯 Interview Key Takeaway
Follow Semantic Versioning rules so consumers know when updates introduce breaking changes versus backwards-compatible bug fixes.
#SemVer#Versioning#Dependencies#Beginner
Back to all Software Engineering Principles Questions→