Effective C# (2nd Edition)

利用Ultra-Edit 32,配合Perl的正则表达式,很方便地把《Effective C#》第二版的目录截出来了,放在这儿随时提醒自己养成良好的习惯吧。书很不错,讲得很精细


Item 1: Use Properties Instead of Accessible Data Members
Item 2: Prefer readonly to const
Item 3: Prefer the is or as Operators to Casts
Item 4: Use Conditional Attributes Instead of #if
Item 5: Always Provide ToString()
Item 6: Understand the Relationships Among the Many Different Concepts of Equality
Item 7: Understand the Pitfalls of GetHashCode()
Item 8: Prefer Query Syntax to Loops
Item 9: Avoid Conversion Operators in Your APIs
Item 10: Use Optional Parameters to Minimize Method Overloads
Item 11: Understand the Attraction of Small Functions
Item 12: Prefer Member Initializers to Assignment Statements
Item 13: Use Proper Initialization for Static Class Members
Item 14: Minimize Duplicate Initialization Logic
Item 15: Utilize using and try/finally for Resource Cleanup
Item 16: Avoid Creating Unnecessary Objects
Item 17: Implement the Standard Dispose Pattern
Item 18: Distinguish Between Value Types and Reference Types
Item 19: Ensure That 0 Is a Valid State for Value Types
Item 20: Prefer Immutable Atomic Value Types
Item 21: Limit Visibility of Your Types
Item 22: Prefer Defining and Implementing Interfaces to Inheritance
Item 23: Understand How Interface Methods Differ from Virtual Methods
Item 24: Express Callbacks with Delegates
Item 25: Implement the Event Pattern for Notifications
Item 26: Avoid Returning References to Internal Class Objects
Item 27: Prefer Making Your Types Serializable
Item 28: Create Large-Grain Internet Service APIs
Item 29: Support Generic Covariance and Contravariance
Item 30: Prefer Overrides to Event Handlers
Item 31: Implement Ordering Relations with IComparable<T> and IComparer<T>
Item 32: Avoid ICloneable
Item 33: Use the new Modifier Only to React to Base Class Updates
Item 34: Avoid Overloading Methods Defined in Base Classes
Item 35: Learn How PLINQ Implements Parallel Algorithms
Item 36: Understand How to Use PLINQ for I/O Bound Operations
Item 37: Construct Parallel Algorithms with Exceptions in Mind
Item 38: Understand the Pros and Cons of Dynamic
Item 39: Use Dynamic to Leverage the Runtime Type of Generic Type Parameters
Item 40: Use Dynamic for Parameters That Receive Anonymous Types
Item 41: Use DynamicObject or IDynamicMetaObjectProvider for Data-Driven Dynamic Types
Item 42: Understand How to Make Use of the Expression API
Item 43: Use Expressions to Transform Late Binding into Early Binding
Item 44: Minimize Dynamic Objects in Public APIs
Item 45: Minimize Boxing and Unboxing
Item 46: Create Complete Application-Specific Exception Classes
Item 47: Prefer the Strong Exception Guarantee
Item 48: Prefer Safe Code
Item 49: Prefer CLS-Compliant Assemblies
Item 50: Prefer Smaller, Cohesive Assemblies


转载于:https://www.cnblogs.com/Abbey/archive/2011/08/01/2123312.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Effective C”是指使用C语言进行编程时,在代码的编写和设计中遵循的一些有效原则和最佳实践。以下是关于如何编写高效的C代码的一些重要原则。 首先,关注代码的可读性和可维护性。良好的代码应该易于阅读和理解,使得其他开发人员能够轻松地理解代码的意图和执行流程。为了提高代码的可读性,应该使用有意义的变量和函数名,并适当地注释代码。 其次,避免过度优化。当编写C代码时,可能会有一种倾向,即过度优化以提高代码的执行速度。然而,这往往会使代码变得复杂和难以维护。在大多数情况下,应该首先写出能正常工作的代码,然后在必要时进行优化。 另外,内存管理是编写高效C代码的关键。正确地分配和释放内存,避免内存泄漏和内存访问错误是至关重要的。可以使用malloc和free函数进行动态内存分配和释放,但是一定要注意释放已经分配的内存,以避免内存泄漏问题。 此外,避免使用过多的全局变量。全局变量的使用可能会导致代码的不可预测性和可维护性的降低。应该尽可能地将变量的作用范围限制在函数内部,并使用参数传递数据。 最后,进行适当的错误处理和异常处理。有效的C代码应该能够处理各种可能的错误情况,并提供适当的错误消息和恢复机制,以保证程序的稳定性和可靠性。 总之,“Effective C”是通过遵循一些有效的编程原则和最佳实践,以提高C代码的质量和效率。这些原则包括关注代码的可读性和可维护性,避免过度优化,正确地进行内存管理,避免过多的全局变量,以及进行适当的错误处理和异常处理。遵循这些原则可以帮助开发人员编写高效、可扩展和可维护的C代码。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值