Programming C#

O’Reilly have an enviable reputation in the field of technical publishing. For a large number of programmers, sysadmins, network engineers and other geeks in need of documentation in dead tree format, an O’Reilly will be their first port of call. And for good reason, too – ORA books are written by techies, for techies; the information in them is generally detailed, well presented, accurate and useful. You’d be hard pressed to find, say, a Perl programmer who doesn’t own at least one, and probably several, of O’Reilly’s Perl books. O’Reilly books form about 50% of my technical bookshelf, and I’ve always been thoroughly impressed by their quality, depth and simplicity of presentation. Naturally, then, when I decided to learn C#, my first port of call was O’Reilly, and in particular, Programming C#.

Programming C# follows the standard format of any ORA ‘Programming…’ book – the first section starts with with an overview of the language, its reason for being, and a walkthrough of ‘Hello World’ implemented in C#; this is followed by a detailed description of the language fundamentals – types, expressions, variables, statements, operators, etc – and then several chapters on the powerful OO features of C# – classes, objects, inheritance, interfaces, delegates and so on. The second section focuses on practical applications of C# – Windows applications, data access, web services and building solutions. The third and final section covers the CLR and .NET framework in some detail – this is where reflection, file IO, threads, marshalling and integration with unmanaged components are dealt with. So, all well and good, so far.

Problems begin to arise, though, in the way this information is presented. The first few chapters on language fundamentals are largely okay; however, as soon as OO concepts are introduced, things start to go wrong. Complex concepts are not dealth with in a simple way, and you often feel like the author is circling around a topic, as if they are not totally sure how to approach it correctly. This isn’t helped by the use of some badly chosen examples; complex concepts are often illustrated with inadequate (and sometimes inaccurate) code snippets, but simpler ideas are laboured, with several pages are taken up with unnecessary examples and discussion. In several places, the example code given doesn’t actually match up with the discussion in the text, and often variable and method names are badly chosen. Opening and closing braces are sometimes missing and, in one or two instances, entire function or class headers have been left out – basically, the examples feel like they have been put together quickly and without much care and attention to detail. In fact, this general feeling of rushedness pervades many of the more complex topics; the reader gets the feeling that the author doesn’t want to (or cannot) explain a certain topic in detail, and so it gets rushed over in a confusing manner.

A good example of the problems I encountered is in the chapter on Polymorphism and Inheritance. C# offers two ways of redeclaring a base class method in a derived class – virtual/override and new; the difference between the two is not complex (override replaces the base method entirely; new keeps the old method, but hides it, as with variable shadowing in Java) but the book manages to avoid making this simple distinction clear, instead leaving the reader confused as to the difference; however, it talks great length about the benefits the arrangement offers in terms of interface versioning. In the end, I had to go online and find out the difference from MSDN.

The thing is, all the information you need is actually in there – you can perfectly well learn C# from this book; it’s just not especially well presented or furnished with good examples. The whole book needs a thorough proof-reading and technical review, preferably by someone who is unfamiliar with C# and will therefore notice when something is confusing or inadequately explained. It’s adequate, but could be a lot, lot better, and is certainly well below the usual excellent standards I’ve come to expect from O’Reilly.

Comments are closed.