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 .

  • 相关阅读:
    最小覆盖点集模板
    NSCache使用常见错误
    stl变易算法(一)
    web.xml(8)_jsp-config
    大话设计模式—中介者模式
    HTML5开发移动web应用——SAP UI5篇(9)
    BZOJ 1588 HNOI2002 营业额统计 裸Treap
    php实现Bloom Filter
    华为上机之四
    【转】我的电脑最近忽然开不了机,启动修复也无法修复,win7系统。开机的时候如果不点启动修复直接正常启动
  • 原文地址:https://www.cnblogs.com/lufangtao/p/2653208.html
Copyright © 2011-2022 走看看