Author: Wouter de Kort
Publisher: Microsoft Press
Audience: Those taking the exam, devs with little C# experience or coming from another programming language
Reviewer: Nikos Vaggalis
This book deserves the subtitle “The fat-free guide to C# and the .NET framework” and should not be overlooked just because you have no plans to take the exam
This title cleverly addresses the IT's professional's limited time available to acquire new skills. Nowadays, having knowledge in multiple programming languages, databases, BI, and in other CS fields, is increasingly essential. This book's fast paced approach gets the reader started in C# and the .NET framework in a snap, fulfilling today's demands when working under restricted time requirements.
As such, characterizing the book as just an exam preparation guide does not do it justice, as it is equally useful to people not aiming to take the exam who have some C# experience and are in need of a clear-cut guide on where to head next, or those coming from another language wanting an overview of what the C# and the .NET framework have in store. While it cannot be considered as in depth or in detail, it nevertheless offers a complete overview, pointing the reader to the appropriate references when looking to elaborate.
It groups C#'s language constructs as well as .NET's components into chapters according to functionality:
- Chapter 1 - Manage program flow
- Chapter 2 - Create and use types
- Chapter 3 - Debug applications and implement security
- Chapter 4 - Implement data access
with each chapter broken down into multiple, self-contained objectives.
Programming experience to a certain degree is certainly required, something evident as early as the book's very beginning which, surprisingly, kicks off by talking about multithreading and asynchronous programming!
Chapter 1 begins with a introduction to the principles of threading, and gets practical using both the Thread class and its aspiring descendant, Tasks. The newly introduced async/await keywords, the constructs of Parallel programming , PLINQ, and the framework's thread-safe collections are all covered next. You'll only get the latest manifestations of the framework's async programming facilities, like (continuation) Tasks or async/await, and not how it was done in the 'old' way, otherwise known as the Event-based Asynchronous Pattern with BeginInvoke, Callbacks, etc.
Everything unfolds under a learn-through-coding paradigm, which aims in having the reader working on something useful in the minimum amount of time possible. Theory is covered, but is not expanded upon, typically spanning a few lines, at most a paragraph! This is not necessarily bad, as those few lines of text seem enough for this author to communicate the required information. Instead of going into great (page) lengths, ending up disorienting rather than aiding the reader, (something frequently met in IT titles), the author adopts a more succinct and straightforward style, something that fortunately pertains to the whole book.
In Objective 1.4: Create and implement events and callbacks, we move speedily from delegates' standard definition to lambda expressions as the replacements for anonymous methods, then to Func<>, Action<>, Events, Eventhandler<T> and custom event arguments. The remarkable degree of coherence, and the manner in which things get debunked, like demystifying the 'event' keyword's origin and reason for existence, make everything sound so easy to pick up.
Each objective ends with the Summary, and the Review which is comprised of a set of multiple choice questions based on the deliverables that should have been covered. The answers to each objective, together with the so-called Thought Experiments can be found at the end of each chapter. The thought experiments set problems that require essay-like answers, striking a balance between encouraging connective and critical thinking with the recall and recognize model of multiple choice questions.
Chapter 2 provides an overview of OOP (object -oriented principles), such as Overriding, Overloading or Extending types by means of inheritance. It looks at creating custom types by adding behavior and data, and uses the code examples as means of communicating the theory and not the other way around.
However, although covering OOP, it does not extend to OOD (object -oriented design). A prime example of this is the section on Abstract classes, where it states:
“If you don’t want to allow a base class to be instantiated, you can declare it as an abstract class”.
As to why you would actually like to do this is beyond the book's scope.
The paragraph on interfaces being used as method parameters and as a way of programming against a contract and not an implementation:
void MoveAnimimal(IAnimal animal)
is well set out and gives me opportunity for a personal observation that highlights an important distinction between static and dynamic languages. A dynamic language like Perl would not need to adhere to a contract imposed by an interface, but would work with any object that adheres to " if it looks like a duck and quacks like a duck, it's a duck".
The objective on garbage collection goes through the objects' life-cycle and offers an excellent explanation of IDispose vs Finalize.
Chapter 3's security objective, contains everything the practitioner would ever want to know -validating input; symmetric vs asymmetric encryption; hashing; certificates; securing string data with SecureString - with all the pieces of the puzzle nicely connected and put into place.
Using Parse, TryParse, and Convert, reveals another critical aspect of the book; that is, the great way that it informs the reader of the options available, eliminating confusion about which class does what, thus giving the reader the opportunity to make an educated decision on what to use. An issue like that is very real and pertains naturally to a framework this huge, making the overlapping of functionality between lots of classes inevitable. This hinders the clarification of the classes' purpose as the framework grows mature.
The Manage assemblies objective is about signing assemblies, placing them into the GAC, verifying them, etc. The objective on Debugging is, amongst others, about managing the build configuration, managing program symbols, and Objective 3.5 Implement diagnostics in an application, is about logging, tracing and profiling. All these are treated as they should be, as no brainer tasks with a mechanical execution. There's really no point in overwhelming the reader with information on these kind of procedures.
Chapter 4 does an excellent job at enumerating, explaining and comparing the various options the framework has to offer for working with the file system, serializing, deserializing, consuming web services etc, while the material on XML and the myriad ways of handling it (be it XmlReader, XmlDocument, LINQ to XML, Xdocument, Xelement ) deserves special attention.
The LINQ objective manages to showcase all of LINQ's functionality in a compact way, explaining that in reality it's just a mishmash composed of the combination of various C# language features added to it in version 3.5 of the framework:
- Object initialization syntax
- Lambda expressions
- Extension methods,
- Anonymous types
This section even succeeds in highlighting the differences between the method and query syntax.
Finally, everything gets wrapped up with the absolutely critical Objective 4.5: Store data in and retrieve data from collections - something you need to master as collections crop up so frequently in all frameworks including .NET.
All in all, you would be wrong to see this book as just an exam cheatsheet, despite its ability to make the exam seem not that fearful.
The lightweight but nonetheless serious approach taken by the author, makes it as enjoyable and as easy to follow as a story book. Although not going into depth, or under the covers, it possesses a unique and comprehensible way of explaining both C#'s and the framework's constructs.
If I could coin a term that most closely describes this book, it would be "forward-only-reading", since the flipping of pages back and forth to revisit a topic that was not that well comprehended, is likely to be a rare occurrence.