zoukankan      html  css  js  c++  java
  • The Elements of C# Style General Principles

     1. Adhere to the Style of the Original

     Do not introduce a new coding style in a modification ,and do not attempt to rewrite the old software just to make it match the new style.

    2. Adhere to the principle of Least Astonishment

    The Principle of Least Astonishment suggests you should avoid doing things that would surprise other software developers.

    To minimize the changces that anyone would encounter something surprising in your software,you should emphasize the following characteristics in the design,implementation,packaging,and documentation of your software:

    Simplicity  Meet the expectations of your users with simple classes and simple methods

    Charity     Ensure that each class,interface,method,variable,and object has a clear purpose,Explain where ,when ,why ,and how to use each

    Completeness   Provide the minimum functionality that any reasonable user would expect to find and use.Create complete document-action;document all features and functionality.

    Consistency Similar entities should look and behave the same;dissimilar entities should look and behave differently,Create and apply consistent 

    standards whenever possible.

    Robustness Provide predictable,documented behavior in response to errors and exceptions.Do not hide errors and do not force clients to detect errors.

    3 Do It Right the First Time

    Apply these rulse to any code your write,not just code destinde for production.More often than not ,some piece of prototye or experimental code will make its way into a finished product,so you should anticipate this eventuality.

    4.Document Any Deviations

    Before you decide to ignore a rule,you should first make sure you understand why the rule exists and what the consequences are if it is not applied .If you decide you must violate a rule,then document why you have done so.

    This si the prime directice.

    5.Cosinder Using a Code-Checking Tool to Enforce Coding Standards

    For example,FxCop is a popular .NET code analysis tool .

  • 相关阅读:
    Python入门示例系列07 Python注释
    Python入门示例系列09 Python算术运算
    Python入门示例系列10 字符串(初级)
    SQL循环26个字母插入到一个表中
    UBUNTU LINUX中连接ANDROID 小米真机调试
    Ubuntu下包含2种远程桌面的方式:VINOServer以及VNC Server
    一个合格的程序员应该读过哪些书
    linux下如何查看文件编码格式及转换文件编码
    尽量不要使用文本模式
    S.O.L.I.D.类设计原则
  • 原文地址:https://www.cnblogs.com/lufangtao/p/2653208.html
Copyright © 2011-2022 走看看