CSC/ECE 517 Fall 2009/wiki1a 4 srhi4: Difference between revisions
Line 8: | Line 8: | ||
The below diagram gives a quick overview of a source code management system managing multiple codebases | The below diagram gives a quick overview of a source code management system managing multiple codebases | ||
[[Image:Version_Control.jpeg|thumb|center|alt=An example of version control]] | [[Image:Version_Control.jpeg|thumb|center|500px|alt=An example of version control]] | ||
==Terminology == | ==Terminology == |
Revision as of 05:24, 7 September 2009
Best Practices for Source Code Management with Version Control
Introduction
Source Code Management (also called Revision Control) is a technique used to manage and monitor the codebase of any software in order to track the changes made to the code. It plays an important role in a setup where there are many people (software developers) have to modify / work on the same code. In such a scenario, merging different versions of the same code and availability of the latest version of the code becomes a critical factor, SCM helps in doing that.
The below diagram gives a quick overview of a source code management system managing multiple codebases
Terminology
• Code Check-out - Downloading a file or a set of files from the codebase to a workspace in order to run / modify the code
• Code Check-in - Uploading new / modified files to a codebase from a workspace
• Branching - A technique used to aid the concurrent development of software. Simply put, it allows for development of code simultaneously by creating multiple paths for development.A branch is for a single logical change in the code
• Codeline - A codeline is similar to a branch but can support multiple logical changes to the code. Often, branch and codeline are used interchangeably
• Merging - Process of integrating the changes in the code with the codeline. For example, if A branches out from a codeline, development continues on the codeline. A would then have to merge his / her changes with the codeline to keep the versioning most recent.
Motivation for Source code management (SCM)
In a development environment, a single project can simultaneously be in multiple phases. One team would be working on building new features into the product. A second team would be working on fixing bugs (Tech support) while a third team concentrates on prototypes for future development. Different lines are created for each of these items – Functional line, development line, maintenance line, release line, integration line and so on. In such an environment, management of the codebase becomes critical for the following reasons
— Allow simultaneous / parallel development of software. — Integrate code changes from different teams / developers — Propagate bug fixes to future versions of the software — Isolate, coordinate and tidily separate work item units — Track and revert to older versions — Keep related projects in sync with one another
Efficient Source Code Management (SCM)
There are a lot of challenges associated with SCM. There is no standard way for source code management. Each project uses a different way of SCM depending on development cycles, releases, bug fixes, size of the project etc. However, there a few common guidelines and patterns that allow for efficient management. The following section describes a few common guidelines in a typical scenario
1. Have a main line from which all the code is derived 2. The main line sets up the base of the project. Typically, when some code is being developed for two different platforms, say,
Windows and Linux, common modules are placed in the main line. The two codelines for Linux and Windows are then taken
from the main line to create parallel development lines. 3. Have parallel maintenance and development lines 4. Product development and maintenance (eg: bug fixes) happen simultaneously. For this reason, we need two parallel lines and
these lines should interact closely and integrate / merge frequently to stay up-to-date with the fixes 5. Have one codeline per release 6. Separation / Isolation of the codeline for a specific release becomes important since parallel work goes on on the previous
version of the software(maintenance). Thus a new codeline should be drawn whenever a release for the product is planned 7. Create policies for each codeline 8. Policies for a codeline define the stability and maintainability of a source code management system. The policy for the
development line could encourage late merges while those for bug fixes encourage merging often. 9. Merge early and often 10. As far as possible, developers must be working with the latest copy of the code. Thus, merging often becomes important.
Early merges help in having common bases for further development since the early parts of the code are most critical. Frequent
merging also helps in avoiding large merges later in the cycle which could lead to incosistent code. It is the best way to keep
all developers in sync with the product code.. 11. Do not isolate too much, 12. Isolation could be beneficial in case of large projects. However, creating many codelines / branches is inadvisable. The
cost for merging could become high. 13. Analyse and realign 14. The versioning tree could grow out of bounds and become wider and wider. Wider the tree, the more codelines / branches it
has and the more difficult it is to manage. SCM systems must be checked often for such widening trees and action for merging
codelines must be taken appropriately to sync up versions 15. Have an owner for every codeline 16. All the developers using the version control tool should be able to know who and how many are using the same code which
makes it easier to decide whether or not he wants to work on the current version or wait for the newer one, once others check
in their modifications.
Ownership is a key term used in source code management. Every codeline is assigned an owner who is responsible for the codeline. The owner's typical tasks would be to assist in code integration and changes in his codeline, clarify ambiguous code policies, decide when to freeze and unfreeze code, co-ordinate across teams to make successful merges.
Example
IBM Rational ClearCase is a widely used version control software with a secure version management and easy to follow interface. It follows the guidelines of the best practices for source code management with version control. It centralizes the code, making it accessible to anyone in the software development team for a particular development. The ClearCase software supports parallel development and easy merging techniques. One of the most useful features of IBM Rational ClearCase is the views. It provides two different views, SnapShot and Dynamic. SnapShot views help to create local copy of the code from the codebase while the dynamic one is used when the codebase has to be modified (during merge). This feature helps to maintain the version of the code by allowing the developer to choose the level of access required for the code.
The details of the tool can be found in the IBM publication cited in the references section of this page.
Conclusion
Source Code Management or Revision Control is a way of helping the software development for faster and efficient delivery and reduce the amount of rework or manual code maintenance. In a typical development team setup, it becomes a critical tool which is used by every team member. Hence it becomes very important for the version control systems to be accurate and user friendly. Not only does it need to be simple to understand, but it also has to be reliable and transparent without any conflicts.
References
• For Beginners
http://www.perforce.com/perforce/papers/bestpractices.html
Gives a high level overview of SCM best practices.
• For Advanced Readers
http://hillside.net/plop/plop98/final_submissions/P37.pdf
Gives an in-depth view of source code management using different patterns. It helps in organizing related lines of development intoappropriately diverging and converging streams of source code changes.
http://www.redbooks.ibm.com/abstracts/sg246399.html?Open&S_TACT=105AGX15&S_CMP=LP
This is the product redbook released by IBM about its Rational ClearCase. It explains the different features of their Version Control tool which follow the best practices discussed in this page.
• For Developers
https://publib.boulder.ibm.com/infocenter/cchelp/v7r1m0/index.jsp?topic=/com.ibm.rational.clearcase.books.cc_build_windows.doc/cc_build.htm
This is the IBM Rational ClearCase Version Control tool document for those who wish to use the ClearCase tool for software development. It contains tutorials and examples that are easy to follow.