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 .

  • 相关阅读:
    [原创]SQL经验
    DotNetBar技巧经验集合
    正则表达式的那些小角落
    [转]验证数字的正则表达式集
    项目受源代码管理。向源代码管理注册此项目时出错。建议不要对此项目进行任何更改
    DateGridView的一些技巧
    个人的CodeSmith和.NetTiers的学习心得及经验总结
    常用代码
    mysql 数据库常用命令
    XP2防火墙拒绝网上邻居访问的解决
  • 原文地址:https://www.cnblogs.com/lufangtao/p/2653208.html
Copyright © 2011-2022 走看看