"Go" writing high-quality Code 157 recommendations for improving C # programs--Recommendation 136: Prioritize using suffixes to represent new versions of existing types

Source: Internet
Author: User

Recommendation 136: Prioritize using suffixes to indicate new versions of existing types

Adding suffixes in some cases is a very strange form, and we are unwilling to see a type like OrderProcessor2. However, it is still necessary to do so at some point. The most typical is the two types of x509certificate and X509Certificate2 in the FCL about digital certificate operations.

The X509Certificate type was first seen in the FCL 1.0/1.1 version, and later in the FCL2.0 version, a subsequent version: Type X509Certificate2. This subsequent version is not a subclass of a previous version, but instead appears as an alternative version.

Remember that when you have to have a new version of a type, you should add a suffix instead of a prefix. This is not just a habit problem, it also helps intelligence discover this new version of the class.

The new version of the improper naming method is as follows:

class sampleclass{    // omit }class  sampleclassnew{    //  omitted }

We might know from the name that SampleClass is a previous version, and Sampleclassnew is a new version, but it's hard to name a new version if it comes up again in the future.

The use of numbers as suffixes effectively avoids the occurrence of this condition. Subsequent versions of SampleClass can be named SampleClass2, SAMPLECLASS3, and so on.

Turn from: 157 recommendations for writing high-quality code to improve C # programs Minjia

"Go" writing high-quality Code 157 recommendations for improving C # programs--Recommendation 136: Prioritize using suffixes to represent new versions of existing types

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.