Personal tools
You are here: Home User Group Association Program Book Reviews reviews_2005 Programming C#, 4th Edition
Document Actions

Programming C#, 4th Edition

by Tony Cappellini last modified 2006-11-05 02:15

review by Arien Malec, April 2005

progcsharp4.gif
 
 
The C# programming language is a fairly decent example of what one might now call, with tongue partway in cheek, the Java family of programming languages. This family is defined partly by shared syntax (a C-inspired more or less pure object oriented language), and partly by a shared attitude to programming—workmanlike and stolid. These are not programmers' programming languages, they are the programming languages for development shops (to be fair, C# was significantly less painful than Java as of the 1.1 and 1.4 versions, respectively; the 2.0 and 1.5 versions are a great deal less painful). Alas, development shops often have the jobs, and a Python programmer may well need to pick up C#; the IronPython port of Python to the .Net CLR may also provide another incentive to pick up C#.
 
Programming C# is a reasonably complete overview of the C# programming language, at least insofar as concerns the Microsoft C# ecosystem. It stays true to its target language, for all the good and bad that entails. Its target audience is the experienced programmer who needs to pick up the basics of the language quickly, but does not need a slow and gentle introduction to programming. That being said, Programming C# is not a concise book. It takes all of 324 pages to present the core of the language, without exploring much of the reasonably extensive .Net library. This makes the book somewhat slow slogging, particularly as the book makes no attempt to separate the important language feature from the rare case (if Programming C# were an algorithm, it would be a depth-first tree traversal). On the other hand, coverage is complete and accurate—no stone in the specification is left unturned.
 
I found some of the more useful corners of C# to be somewhat cursorily treated, however. Delegates (first class functions) are treated mainly as a tool to work with GUI event-driven applications, rather than a core, highly useful language feature. This is perhaps because other uses of delegates are considered somewhat obscure, even though one can create powerful code with first class functions (C# 2.0 makes this even more powerful by allowing anonymous definition of delegates, which previously had to be defined first as object members). Generics (another new feature of C# 2.0, which partially implement the parametric polymorphism of languages such as those in the ML family), are mainly treated from the point of view of the library consumer, using the collection classes, rather than the point of view of the library designer (although there are a few examples of creating new generic objects).
 
The best programming language books satisfy three objectives:
  1. They teach the syntax and semantics of the programing language
  2. They teach the correct and common idioms of the programming language
  3. They teach how to program.
 
Programming C# satisfies the first objective rather well, but is much weaker on the second and third objectives. One does not get much of a sense of how to construct well-programmed and well-architected systems in C#. Most of the programming examples are throwaways (some with goofy references to Ayn Rand books), and are both useless as actual programs, and useless as examples of how to program. For instance, objects will contain calls to System.Console throughout, even when the programming example is ostensibly creating a general purpose object. The discussion of out parameter attributes uses an example that screams instead for a return of a utility object or stuct. Also, most of the examples have extraneous using directives for libraries that are not actually used in the example programs. These directives were presumably placed there by the IDE; it is sloppy style to leave them in the finished programs, as they assert something about the code that is not true. I would much prefer to see a complete useful example or set of examples to illustrate both the core language syntax, and how one program in C#, and emphasis on strong programming style throughout (even in toy programs, unless explicitly designed as experiments to probe odd corners of the language).
 
One odd aspect of Programming C# is the refusal to describe aspects of the language that are not part of the Microsoft toolchain. For instance, Mono is mentioned only once, and Windows is otherwise assumed as the underlying operating system. There is likewise no treatment of alternate IDEs, such as SharpDevelop. These omissions pale, however, to the lack of coverage for two tools that are, or should be, indispensable to the C# programmer: NUnit and NAnt. In particular, it strikes me as almost unprofessional to cover a language without covering the standard unit testing environment for that language.
 
The second part is an introduction to GUI and web programming in C#. This section is rather brief, and continues the exposure to poor style. For instance, the GUI example makes no distinction between model and view, and the ASP.NET example embeds SQL in the Web Form. These practices are both sufficiently common among C# programmers that they ought to be specifically warned against, not reinforced. This section was likely introduced as marketing filler: it may persuade a prospective purchaser that this one book will both provide an introduction to C# and to forms or web programming. Alas, this section is mostly wasted dead trees. Oddly, documentation of XML code comments is placed in this section, rather than the core language reference.

 
The third part covers core library functions, including reflection, threading, and I/O, which is introduced starting on page 525(!). Why one has to wait until the end of the book to learn how to read and write to the filesystem, console or network is rather beyond me. As with everything else in the book (with the exception of the second part), coverage is correct and complete, but presented without much of an attempt to emphasize the important.
In general, Programming C# satisfies its goal of being a reasonably comprehensive introduction to C# for the experienced programmer. It would be, however, a much better book had it moved a bit faster, provided better examples of programming style, emphasized the key language features, and omitted the mostly useless GUI and web programming examples.
 
 
 
 
 

« November 2008 »
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
 

Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: