Book description
Like most complex tasks, .NET programming is fraught with potential costly, and time-consuming hazards. The millions of Microsoft developers worldwide who create applications for the .NET platform can attest to that. Thankfully there's now a book that shows you how to avoid such costly and time-consuming mistakes. It's called .NET Gotchas.The ultimate guide for efficient, pain-free coding, .NET Gotchas from O'Reilly contains 75 common .NET programming pitfalls--and advice on how to work around them. It will help you steer away from those mistakes that cause application performance problems, or so taint code that it just doesn't work right.The book is organized into nine chapters, each focusing on those features and constructs of the .NET platform that consistently baffle developers. Within each chapter are several "gotchas," with detailed examples, discussions, and guidelines for avoiding them. No doubt about it, when applied, these concise presentations of best practices will help you lead a more productive, stress-free existence.What's more, because code examples are written in both VB.NET and C#, .NET Gotchas is of interest to more than 75 percent of the growing numbers of .NET programmers. So if you're a .NET developer who's mired in the trenches and yearning for a better way, this book is most definitely for you.
Table of contents
- .NET Gotchas
- Dedication
- A Note Regarding Supplemental Files
- Preface
-
1. CLR/Framework Gotchas
- GOTCHA #1 Type alias size doesn’t match what you’re familiar with
- GOTCHA #2 struct and class differ in behavior
- GOTCHA #3 Returning value types from a method/property is risky
- GOTCHA #4 You can’t force calls to your value-type constructors
- GOTCHA #5 String concatenation is expensive
- GOTCHA #6 Exceptions may go unhandled
- GOTCHA #7 Uninitialized event handlers aren’t treated gracefully
- GOTCHA #8 Division operation isn’t consistent between types
- GOTCHA #9 Typeless ArrayList isn’t type-safe
- GOTCHA #10 Type.GetType() may not locate all types
- GOTCHA #11 Public key reported by sn.exe is inconsistent
-
2. Visual Studio and Compiler Gotchas
- GOTCHA #12 Compiler warnings may not be benign
- GOTCHA #13 Ordering of catch processing isn’t consist across languages
- GOTCHA #14 Type.GetType() might fail at run-time
- GOTCHA #15 rethrow isn’t consistent
- GOTCHA #16 Default of Option Strict (off) isn’t good
- GOTCHA #17 Versioning may lead to Serialization headaches
- GOTCHA #18 Creating Web apps can be painful
- GOTCHA #19 Naming XML documentation for IntelliSense support isn’t intuitive
-
3. Language and API Gotchas
- GOTCHA #20 Singleton isn’t guaranteed process-wide
- GOTCHA #21 Default performance of Data.ReadXMLData.ReadXML
- GOTCHA #22 enum lacks type-safety
- GOTCHA #23 Copy Constructor hampers exensibility
- GOTCHA #24 Clone() has limitations
- GOTCHA #25 Access to static/Shared members isn’t enforced consistently
- GOTCHA #26 Details of exception may be hidden
- GOTCHA #27 Object initialization sequence isn’t consistent
- GOTCHA #28 Polymorphism kicks in prematurely
- GOTCHA #29 Unit testing private methodstesting private methods
-
4. Language Interoperability Gotchas
- GOTCHA #30 Common Language Specification Compliance isn’t the default
- GOTCHA #31 Optional parameters break interoperability
- GOTCHA #32 Mixing case between class members breaks interoperability
- GOTCHA #33 Name collision with keywords breaks interoperability
- GOTCHA #34 Defining an array isn’t consistent
-
5. Garbage Collection Gotchas
- GOTCHA #35 Writing Finalize() is rarely a good idea
- GOTCHA #36 Releasing managed resources in Finalize() can wreak havoc
- GOTCHA #37 Rules to invoke base.Finalize() aren’t consistent
- GOTCHA #38 Depending on Finalize() can tie up critical resources
- GOTCHA #39 Using Finalize() on disposed objects is costly
- GOTCHA #40 Implementing IDisposable isn’t enough
- GOTCHA #41 Using the Dispose Design Pattern doesn’t guarantee cleanup
-
6. Inheritance and Polymorphism Gotchas
- GOTCHA #42 Runtime Type Identification can hurt extensibility
- GOTCHA #43 Using new/shadows causes “hideous hiding”
- GOTCHA #44 Compilers are lenient toward forgotten override/overrides
- GOTCHA #45 Compilers lean toward hiding virtual methods
- GOTCHA #46 Exception handling can break polymorphism
- GOTCHA #47 Signature mismatches can lead to method hiding
-
7. Multithreading Gotchas
- GOTCHA #48 The Thread classThread class
- GOTCHA #49 Foreground threads may prevent a program from terminating
- GOTCHA #50 Background threads don’t terminate gracefully
- GOTCHA #51 Interrupt () kicks in only when a thread is blocked
- GOTCHA #52 ThreadAbortException—a hot potato
- GOTCHA #53 Environment.Exit() brings down the CLR
- GOTCHA #54 ResetAbort() may lead to surprises
- GOTCHA #55 Abort() takes time to clean up
- GOTCHA #56 Calling Type.GetType() may not return what you expect
- GOTCHA #57 Locking on globally visible objects is too sweeping
- GOTCHA #58 Threads from the thread pool are scarce
- GOTCHA #59 Threads invoked using delegates behave like background threads
- GOTCHA #60 Passing parameters to threads is tricky
- GOTCHA #61 Exceptions thrown from threads in the pool are lost
- GOTCHA #62 Accessing WinForm controls from arbitrary threads is dangerous
- GOTCHA #63 Web-service proxy may fail when used for multiple asynchronous calls
- GOTCHA #64 Raising events lacks thread-safety
-
8. COM-Interop and Enterprise Services Gotchas
- GOTCHA #65 Release of COM object is confusing
- GOTCHA #66 Using interface pointers after calling ReleaseComObject() will fail
- GOTCHA #67 Cross-apartment calls are expensive
- GOTCHA #68 Default apartment of main thread is inconsistent across languages
- GOTCHA #69 STAThread attribute may have no effect on your methods
- GOTCHA #70 Spattering access to COM components makes code hard to maintain
- GOTCHA #71 Auto-generating GUID for your classes leads to versioning woes
- GOTCHA #72 All but one of the ClassInterface options are ineffective
- GOTCHA #73 Simply tur ning the switch for COM interop is dangerous
- GOTCHA #74 ServicedComponents implemented inconsistently on XP and 2003
- GOTCHA #75 AutoComplete comes with undesirable side effects
-
A. Resources
- Bibliography
-
On the Web
- Agile Developer
- CLR Profiler - Managed Code Performance Tool
- Common Object Operations
- Cruise Control .NET
- C# FAQs
- C# Language Specification
- Design Guidelines for Class Library Developers
- Don’t Lock Type Objects!
- Draco.NET
- ECMA-CLI
- Equals vs. ==
- Exploring the Singleton Design Pattern
- FxCop
- Garbage Collection
- Groups @ Google
- Gotdotnet
- Hashcode
- Implementing Finalize and Dispose to Clean Up Unmanaged Resources
- Implementing the Singleton Pattern in C#
- Languages Available in .NET
- MSDN
- MSDN Magazine
- NAnt
- NDoc
- NUnit
- PInvoke.net
- Reflector
- ReleaseComObject() Issues
- Test Driven Development
- Unexpected Errors in Managed Applications
- VB FAQs
- VS.NET Tips and Tricks
- Index
- About the Author
- Colophon
- Copyright
Product information
- Title: .NET Gotchas
- Author(s):
- Release date: May 2005
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596009090
You might also like
book
Learning Algorithms
When it comes to writing efficient code, every software professional needs to have an effective working …
book
Deciphering Data Architectures
Data fabric, data lakehouse, and data mesh have recently appeared as viable alternatives to the modern …
audiobook
The Design of Everyday Things
First, businesses discovered quality as a key competitive edge; next came science. Now, Donald A. Norman, …
book
Modern Software Engineering: Doing What Works to Build Better Software Faster
Improve Your Creativity, Effectiveness, and Ultimately, Your Code In Modern Software Engineering, continuous delivery pioneer David …