Version control (Versioning) is primarily designed to address the issue of incompatible versions of components. Versions are compatible in the following ways:
Source-level Compatibility: Code that relies on older versions can be compatible with the new version after recompilation.
Binary compatibility: An application that relies on an older version can be compatible with the new version without recompiling.
Most languages do not support binary version compatibility at all, and many of them do not perform as well on compatibility issues with source code levels. In fact, many languages are not able to implement component upgrades without overwriting customer code due to their own flaws.
For example, suppose the author of the base class wrote a class called Base. In the first version, the class base does not contain method F. A class called derived inherits from base and declares a method F. class derived and class base are delivered to customers and configured on many clients and servers.
Author a
namespace a
{public
class Base//version 1
{
}
}
//author B
namespace B
{
class derived:a.base
{public
virtual void F () {
System.Console.WriteLine ("DERIVED.F");
}
}
}
So far, the program has been running normally. The author of the base class then provides a new version that adds a method F to class base.
Author a
namespace a
{public
class Base//version 2
{public
virtual void F () { //added In version 2
System.Console.WriteLine ("Base.F");}}
The new version of Base should maintain source-level compatibility and binary-level compatibility with older versions. Unfortunately, the new method in class base is confused with F in class derived. Should derived be overloaded with F in base? It does not seem to be, because derived has been compiled, and there is not even f! in base, but if the f in derived does not overload F in base, it must conform to the declaration of base class, but the declaration does not exist when the derived class is written. For example, in some cases, the F in base may require overloading.
When solving version problems, C # requires developers to articulate their intentions. In the original code, class base does not include method F, so there is no problem. The F in derived is a new method, not a method in the overloaded base class.
Author a
namespace a
{public
class Base
{
}
}
//author B
namespace b
{
Class Derived:a.base
{public
virtual void F () {
System.Console.WriteLine ("DERIVED.F");
}
}