C# and the .NET Platform

Dr. Dobb's Journal January 2002

By Lou Grinzo

Lou is a freelance programmer and writer. He can be contacted at lgrinzo@stny.rr.com.


C# and the .NET Platform
Andrew Troelsen
Apress, 2002
970 pp., $59.95
ISBN 1-893115-59-0

Truly major platform shifts don't happen that often in the programming world, even if it feels like we have to endure one every six months. By any rational measure, Microsoft's introduction of .NET and C# qualifies as big news, as it marks Redmond's attempt to trigger a massive shift from desktop or client/server programming to loosely coupled network programming. If anything, the fact that this is not the conceptually familiar network computing/Java/thin-client model, but a fat client-plus-software-as-service model, makes it an even bigger adjustment for programmers. (And it also reminds us once again of the oft-quoted observation that Microsoft is no longer the shark in the ocean, but the ocean itself in which we're all swimming.)

Not surprisingly, this large an undertaking from Microsoft has triggered a title wave (pun intended) of new books that's just starting to break. One of the first and definitely the most ambitious to date is Andrew Troelsen's massive C# and the .NET Platform (CNP). In one volume of nearly 1000 pages, Troelsen tackles teaching you about C#, the basics of Windows programming with C#, and web-based application development, including using ADO.NET, the latest incarnation of ADO. Along the way, the author throws in mini-tutorials on HTML, COM, and numerous other goodies. The biggest surprise is that this book isn't 1500 pages long.

Which begs the obvious question: How well can a book cover that much ground in a coherent and usable way? The answer in this case is surprisingly well, thanks to two key things Troelsen does well. First off is his no-nonsense tone. Despite the topic being red hot, Troelsen avoids political comments and sticks to a straight-and-narrow presentation of the technical details. Second, and more subtle, is his avoidance of a problem we see endlessly in computer publishing: The book that tries to tell the reader everything about a given topic, including the Byzantine details that perhaps 5 percent of them will actually need. Instead of using this traditional, depth-first treatment, Troelsen presents the material breadth first and includes material from different disciplines that you will most likely need when picking up .NET and C#. You won't find an exhaustive treatment of much here beyond the C# language and the .NET basics, but the whole package hangs together remarkably well if you have a background in Windows programming.

CNP contains 15 chapters, with one devoted to .NET's philosophy and the rest devoted mostly to C#, the remainder being web programming and .NET. The C# material is particularly well done, although you would be forgiven for getting tired of the same car example that appears in almost every conceivable permutation.

Perhaps the strongest part of CNP is how well it works as both a tutorial and a reference. In particular, Troelsen makes heavy use of well-chosen and well-written examples. It's not hard to imagine most programmers reading this book cover to cover, and then going back to certain Post-It-note-flagged sections repeatedly to check Troelsen's examples related to topics such as calling unmanaged code (raw C in DLLs, for instance), retrieving or updating data from a database, basic GDI+ graphics programming, object serialization/deserialization, creating a web service, or any of the dozens of other topics.

My one criticism of CNP is that it's organized in a somewhat odd way and is slightly out of balance. For example, the first chapter, "The Philosophy of .NET," is 52 pages long and includes a lot of information on VS.NET tools, an explanation of the common datatypes in the Common Language Run-time (CLR), which is shared by all .NET languages, and other decidedly nonphilosophical information. The treatment of web development is a little short and feels rushed in a few places, even though chapters 14 and 15 ("Web Development and ASP.NET" and "Building [and Understanding] Web Services") are combined in 112 pages. Given the amount of ground Troelsen is covering, it's only natural that something somewhere had to get short changed, and in this case it definitely wasn't a major omission or mistreatment of the material. There are also several places throughout the book where he refers you to Microsoft's online help for more detail on some subject. Again, this isn't a serious issue, and if anything we would probably be better off with fewer books that spend dozens or hundreds of pages parroting a vendor's help files instead of focusing on what you really need.

It's worth pointing out that while this book is based on the second beta of the .NET software, the publisher has promised to provide updates on its web site. The source code for the book is also available online (http://www.apress.com/), but make sure you have the book handy and that you're prepared for a nostalgia attack, as the site prompts you for the last word on a (presumably randomly selected) page before letting you start the download.

C# and the .NET Platform isn't the one-stop-shopping volume the author and publisher probably envisioned, and if you'll be working with C# and/or .NET, you'll definitely want other titles in addition to this one on your shelf. But so far, this is the one book on these topics that you not only should have, but will want to keep next to your keyboard.

DDJ