O’Reilly news

".NET Gotchas": The Easy Way to Avoid .NET Programming Pitfalls

June 6, 2005

Sebastopol, CA--Experience is not our only teacher, which is fortunate, because some of life's lessons are agonizing when learned firsthand: for instance, it really is a good idea to look both ways before crossing the street and to pay one's income taxes regularly. For programmers, mistakes can also be an enormous, unnecessary waste of time and source of frustration. Especially when a programmer realizes that the same "gotcha" he or she stumbled over has tripped up many others before. "Experience teaches us what to do and what to avoid," observes Venkat Subramaniam, author of the new .NET Gotchas (O'Reilly, US $39.95). "But in programming, we commonly acquire our knowledge the hard way: by making costly, hard-to-debug, and time-consuming mistakes."

As with many complex tasks, .NET programming presents its share of pitfalls for the unaware--enough to fill a book, in fact. Subramaniam, who has worked with .NET since its Beta 2 release in 2001, documents and explains 75 of these pitfalls, or "gotchas," that frequently trip up even the most experienced C# and VB.NET programmers. Some of these are the inevitable result of expectations programmers bring from other environments; others are oddities of the .NET languages, compilers, or the Framework itself.

"When I speak in conferences and meet clients, I see more and more developers with Java, C++, and VB6 experience beginning to use .NET," says Subramaniam. "I see that these developers are not only interested in learning .NET, but are keen on learning it right."

Coming from a strong background in C++, COM, and Java, Subramaniam draws on the insights gained from various languages and applications, past and present, in writing his new book. Other gotchas, he notes, have emerged from "the questions raised by the hundreds of inquisitive software developers I've had the privilege of training," as well as from the thought-provoking articles and discussions he has come across at symposiums, user-group meetings, the Internet, and the MSDN documentation itself. Among the gotchas he covers are:

  • CLR/Framework: not all types are CLS-compliant or interoperable
  • Visual Studio and compiler: compiler warnings are not necessarily benign
  • Language and API: enums are not type safe
  • Garbage collection: depending on Finalize() can tie up critical resources
  • Inheritance and polymorphism: signature mismatches can lead to method hiding
  • Multithreading: exceptions thrown from threads in the pool are lost
  • COM-interop and enterprise services: default apartment is not consistent across languages
  • Each gotcha is fully explained in the book, using VB.NET and C# examples to reveal how false assumptions can often lead to unexpected results. Complete solutions show programmers how to avoid the most common mistakes, with concise "In a Nutshell" summaries and "See Also" references included to round out each discussion.

    Although painful, hands-on experience is an effective teacher, .NET Gotchas operates on the assumption that sometimes it's easier to learn from the errors of others. As Subramaniam says, "I want developers to learn what to do and what not to do so they can get the best out of .NET in their application development efforts."

    Early praise for .NET Gotchas:

    "This is a brilliant book and awesome reference, because it teaches novices and gurus things they wish they knew, but never had the time nor experience to discover."
    --Chau Nguyen, .NET software developer, founder of .NET Architects, Inc.

    Additional Resources:

    .NET Gotchas
    Venkat Subramaniam
    ISBN: 0-596-00909-7, 372 pages, $39.95 US, $55.95 CA
    order@oreilly.com
    1-800-998-9938; 1-707-827-7000

    About O’Reilly

    O’Reilly Media spreads the knowledge of innovators through its books, online services, magazines, and conferences. Since 1978, O’Reilly Media has been a chronicler and catalyst of cutting-edge development, homing in on the technology trends that really matter and spurring their adoption by amplifying “faint signals” from the alpha geeks who are creating the future. An active participant in the technology community, the company has a long history of advocacy, meme-making, and evangelism.

    Email a link to this press release