Ray's playground

 
上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 56 下一页

2011年1月27日

Item 18: Distinguish Between Value Types and Reference Types(Effective C#)

摘要: Build low-level data storage types as value types. Build the behavior ofyour application using reference types. You get the safety of copying datathat gets exported from your class objects. You get the memory usage benefitsthat come with stack-based and inline value storage, and you can utilizestand 阅读全文

posted @ 2011-01-27 23:16 Ray Z 阅读(200) 评论(0) 推荐(0) 编辑

Item 17: Implement the Standard Dispose Pattern(Effective C#)

摘要: The implementation of your IDisposable.Dispose() method is responsiblefor four tasks:  1. Freeing all unmanaged resources.  2. Freeing all managed resources (this includes unhooking events).  3. Setting a state flag to indicate that the object has been disposed. Youneed to check this state and throw 阅读全文

posted @ 2011-01-27 23:10 Ray Z 阅读(158) 评论(0) 推荐(0) 编辑

2011年1月24日

Item 14: Minimize Duplicate Initialization Logic(Effective C#)

摘要: Here is theorder of operations for constructing the first instance of a type:  1. Static variable storage is set to 0.  2. Static variable initializers execute.  3. Static constructors for the base class execute.  4. The static constructor executes.  5. Instance variable storage is set to 0.  6. Ins 阅读全文

posted @ 2011-01-24 22:33 Ray Z 阅读(166) 评论(0) 推荐(0) 编辑

Item 15: Utilize using and try/finally for Resource Cleanup(Effective C#)

摘要: In some ways, resource management can be more difficult in C# than itwas in C++. You can’t rely on deterministic finalization to clean up everyresource you use. But a garbage-collected environment really is much simplerfor you. The vast majority of the types you make use of do not implementIDisposab 阅读全文

posted @ 2011-01-24 21:52 Ray Z 阅读(164) 评论(0) 推荐(0) 编辑

Helper Objects (Chapter 6 of Cocoa Programming for Mac OS X)

摘要: Many objects in the Cocoa framework are extended in much the same way. That is, there is an existing object that needs to be extended for your purpose. Instead of subclassing the table view, you simply supply it with a helper object. For example, when a table view is about to display itself, it 阅读全文

posted @ 2011-01-24 18:23 Ray Z 阅读(216) 评论(0) 推荐(0) 编辑

2011年1月22日

Item 13: Use Proper Initialization for Static Class Members(Effective C#)

摘要: Static initializers and static constructors provide the cleanest, clearest wayto initialize static members of your class. They are easy to read and easy toget correct. They were added to the language to specifically address thedifficulties involved with initializing static members in other languages 阅读全文

posted @ 2011-01-22 11:59 Ray Z 阅读(125) 评论(0) 推荐(0) 编辑

2011年1月21日

Item 12: Prefer Member Initializers to Assignment Statements(Effective C#)

摘要: Member initializers are the simplest way to ensure that the member variablesin your type are initialized regardless of which constructor is called.The initializers are executed before each constructor you make for yourtype. Using this syntax means that you cannot forget to add the properinitializati 阅读全文

posted @ 2011-01-21 23:37 Ray Z 阅读(191) 评论(0) 推荐(0) 编辑

Creating Output(Chapter 4 of XSLT 2nd Edition)

摘要: In XSLT 2.0, xsl:value-of has a separator attribute. If the select attribute is a sequenceof items, those items are output in sequence, with the value of the separatorattribute between them.  There are some changes to the xsl:number element in XSLT 2.0. First of all, three newformats have been a 阅读全文

posted @ 2011-01-21 10:55 Ray Z 阅读(156) 评论(0) 推荐(0) 编辑

2011年1月18日

Item 11: Understand the Attraction of Small Functions(Effective C#)

摘要: Remember that translating your C# code into machine-executable code isa two-step process. The C# compiler generates IL that gets delivered inassemblies. The JIT compiler generates machine code for each method (orgroup of methods, when inlining is involved), as needed. Small functionsmake it much eas 阅读全文

posted @ 2011-01-18 23:29 Ray Z 阅读(208) 评论(0) 推荐(0) 编辑

Item 10: Use Optional Parameters to Minimize Method Overloads(Effective C#)

摘要: Therefore, adding parameters, even if they are optional parameters, is abreaking change at runtime. If they have default values, it’s not a breakingchange at compile time.  Now, after that explanation, the guidance should be clearer. For your initialrelease, use optional and named parameters to crea 阅读全文

posted @ 2011-01-18 21:16 Ray Z 阅读(207) 评论(0) 推荐(0) 编辑

上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 56 下一页

导航