C # Version control

Source: Internet
Author: User
Tags versions

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");
 }
}
 
  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.