Skip to content

.NET Gotchas 75 Ways to Improve Your C# and VB.NET Programs

Spend $50 to get a free DVD!

ISBN-10: 0596009097

ISBN-13: 9780596009090

Edition: 2005

Authors: Venkat Subramaniam

List price: $39.95
Blue ribbon 30 day, 100% satisfaction guarantee!
what's this?
Rush Rewards U
Members Receive:
Carrot Coin icon
XP icon
You have reached 400 XP and carrot coins. That is the daily max!

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,…    
Customers also bought

Book details

List price: $39.95
Copyright year: 2005
Publisher: O'Reilly Media, Incorporated
Publication date: 6/3/2005
Binding: Paperback
Pages: 396
Size: 7.00" wide x 9.00" long x 1.25" tall
Weight: 1.386
Language: English

Dr. Venkat Subramaniam is an award-winning author, founder of Agile Developer, Inc., and an adjunct faculty at the University of Houston. He has trained and mentored thousands of software developers in the US, Canada, Europe, and Asia, and is a regularly invited speaker at several international conferences. He's (co)author of multiple books, including the 2007 Jolt Productivity award winning book Practices of an Agile Developer.

Preface
CLR/Framework Gotchas
Type alias size doesn't match what you're familiar with
struct and class differ in behavior
Returning value types from a method/property is risky
You can't force calls to your value-type constructors
String concatenation is expensive
Exceptions may go unhandled
Uninitialized event handlers aren't treated gracefully
Division operation isn't consistent between types
Typeless ArrayList isn't type-safe
Type.GetType() may not locate all types
Public key reported by sn.exe is inconsistent
Visual Studio and Compiler Gotchas
Compiler warnings may not be benign
Ordering of catch processing isn't consist across languages
Type.GetType() might fail at run-time
rethrow isn't consistent
Default of Option Strict (off) isn't good
Versioning may lead to Serialization headaches
Creating Web apps can be painful
Naming XML documentation for IntelliSense support isn't intuitive
Language and API Gotchas
Singleton isn't guaranteed process-wide
Default performance of Data. ReadXML is poor
enum lacks type-safety
Copy Constructor hampers exensibility
Clone() has limitations
Access to static/Shared members isn't enforced consistently
Details of exception may be hidden
Object initialization sequence isn't consistent
Polymorphism kicks in prematurely
Unit testing private methods is tricky
Language Interoperability Gotchas
Common Language Specification Compliance isn't the default
Optional parameters break interoperability
Mixing case between class members breaks interoperability
Name collision with keywords breaks interoperability
Defining an array isn't consistent
Garbage Collection Gotchas
Writing Finalize() is rarely a good idea
Releasing managed resources in Finalize() can wreak havoc
Rules to invoke base.Finalize() aren't consistent
Depending on Finalize() can tie up critical resources
Using Finalize() on disposed objects is costly
Implementing IDisposable isn't enough
Using the Dispose Design Pattern doesn't guarantee cleanup
Inheritance and Polymorphism Gotchas
Runtime Type Identification can hurt extensibility
Using new/shadows causes "hideous hiding"
Compilers are lenient toward forgotten override/overrides
Compilers lean toward hiding virtual methods
Exception handling can break polymorphism
Signature mismatches can lead to method hiding
Multithreading Gotchas
The Thread class supports some dangerous methods/properties
Foreground threads may prevent a program from terminating
Background threads don't terminate gracefully
Interrupt () kicks in only when a thread is blocked
ThreadAbortException-a hot potato
Environment.Exit() brings down the CLR
ResetAbort() may lead to surprises
Abort() takes time to clean up
Calling Type.GetType() may not return what you expect
Locking on globally visible objects is too sweeping
Threads from the thread pool are scarce
Threads invoked using delegates behave like background threads
Passing parameters to threads is tricky
Exceptions thrown from threads in the pool are lost
Accessing WinForm controls from arbitrary threads is dangerous
Web-service proxy may fail when used for multiple asynchronous calls
Raising events lacks thread-safety
COM-Interop and Enterprise Services Gotchas
Release of COM object is confusing
Using interface pointers after calling ReleaseComObject() will fail
Cross-apartment calls are expensive
Default apartment of main thread is inconsistent across languages
STAThread attribute may have no effect on your methods
Spattering access to COM components makes code hard to maintain
Auto-generating GUID for your classes leads to versioning woes
All but one of the ClassInterface options are ineffective
Simply turning the switch for COM interop is dangerous
ServicedComponents implemented inconsistently on XP and 2003
AutoComplete comes with undesirable side effects
Appendix
Index