1. Computing & Technology

Discuss in my forum

Fluent C# Book Review

An Unusual Looking Book

About.com Rating 4.5 Star Rating
Be the first to write a review

By , About.com Guide

Fluent C# Cover

Back in the mid 90s there were several games writing books that were a little different looking from normal books. This one is also like that, in Brandywine and Windlass lowercase fonts- which gives it a warmer look (the 8 digit looks like a penguin!), in brown text with almost sepia toned pictures. But different appearence is nothing to be scared of, so long as it's legible which it is.

Physically this is a thick meaty text book though it's only 850 pages long. It's very lavishly illustrated with graphics on nearly every page.

One slightly odd anomaly is that the Contents at the start doesn't mention chapters at all just page numbers, and it just partitions it into blocks which tally with the chapters!

Who Is it Aimed At?

Fair and square at the beginners to programming. It's for someone who knows how to use a computer but may never have programmed in their life. It does not cover WinForms, but sticks to WPF. Even if you know C# and just want to learn WPF I recommend it.

Organization

The book splits in to two functional parts. Learning C# which occupies the first 500 pages and learning WPF in the remaining 350.

Before it starts looking at programming though the author takes the reader through one process of developing software by creating a specification using UML. Then a quick glance at the pros and cons of compiling v interpreting and how the CLR in .NET fits in with it's jit approach to code generation. This is a high level approach to start with, as no code has been introduced yet.

That comes in Chapter two which introduces Visual Studio, the editor and the whole "create a program and build it" ethos. Chapter three takes a step back and explains solutions, projects, plus adding an icon to the project and how to use Visual Studio, rearrange Windows etc.

Some of the screen shots show code, e.g. at the start of chapter four but thankfully aren't typical of program listings as you'd need a magnifying glass. Where code is listed it's perfectly readable.

The first part of this chapter teaches debugging and the rest about deploying and creating setup and ClickOnce projects. Some of this isn't relevant to the Express versions of Visual C# but where that occurs the author generally does mention it.

Learning C# Syntax

The first four chapters have been about learning how to compile, edit and test code and now chapter five starts focusing on the code itself. There is a lot of detail here. This one chapter covers statement syntax,declarations, simple types, identifiers, var for declarations, comments, blocks, XML comments and directives.

Chapter six continues with C# syntax with expressions and equations before delving into boolean and logical expressions plus calling object methods; this is a gentle introduction into the world of objects.

C# language statements for control flow and exception handling are brought in in chapter seven. If, switch the ?: (conditional operator) and for/while/do, goto, break and continue are all covered. Then try, catch, finally and creating exceptions as well as handling them.

Classes in C#

Chapter eight gets quickly into the meat of C# classes, properties, methods and events then jumps into the Visual Studio class example to design a class using the (not in the Express) UML Class designer. It's a shame that this wasn't done in code without the UML editor as it's not hard. The rest of this quite long chapter goes over methods, instances of objects and constructors.

In Chapter nine, some of the other C# features are explained, in the customary beautifully illustrated style. This includes reference and value types, structs, enumerations, interfaces, casts, boxing, and passing by reference.

Class Library

The .NET Framework Class Library (FCL) has a massive number of classes. Chapters ten and eleven delve into the FCL explaining namespaces, how to use them or create your own, and using the Object browser to view the FCL by namespace. Then they veer off into numeric types, why int32 is best for eficiency, and then looks at char, strings, datetimes, and timeoffsets.

Chapter eleven continues with arrays, foreach, and the various collection classes before looking at generics. Chapter twelve is more abstract and concerned with how the various classes in your application fit together in the context of object oriented design principles. There's also details on inheritance as well as preventing it.

Programming Principles

In chapter 13, several design principles are gone into. Single responsibility and cohesion, open/closed, dependency inversion, programming to interfaces, Liskov Subsitution and Law of Demeter. These are good sound principles though possibly a little advanced for someone who has just learned to program!

After that chapter you'd not be surprised to see a mention of design patterns and sure enough that's what chapter fourteen covers. Well a subset, as there are many more in existence than just Strategy, Observer, Architectural and Presentation but they serve as a good intro.

And Now for WPF

We're now roughly two thirds through after 500 pages, the remaining 350 pages is about WPF Programming in chapters 15 through 22. I'll cover these at a quicker pace.

Chapter 15. On XAML, what it is, how WPF components fit together and where the compiled XAML (aka BAML) fits in.

WPF Controls in Chapter 16. An overview plus attached properties, panels and positioning/sizing, docking, grid and gridsplitter, and panel nesting. Then an overview of content controls, the Window, headered content controls, buttons including radio button groups. Next there's items controls, treeview, listbox and combobox, tab controls and finally putting thm all together.

Dependency Properties which affects how changes to one control propagate to another is a complex subject and there are a lot of examples in chapter 17 covering dependency classes and callbacks (validation, coerce value and registering callbacks).

WPF Continued

Chapter 18 is about WPF interactions. Routed events and commands along with handler registration are explained here. How events are routed between the different controls. The FCL has dozens of commands and this chapter shows how to use them, and how to create routed commands.

Graphics are the subject of Chapter 19. How the color model is used, how to work with brushes, gradients, bounding boxes, pens and text decorations, WPF typography and how to use flow controls.

In chapter 20, resources are covered. This includes static and dynamic as well as using styles to cut down on having really verbose text. Next comes Property triggers plus how they work with styles. Event triggers work with routed events and this also touches on WPF animations including storyboards, timeline classes and transformations.

Templates let you customize WPF Controls. Chapter 21 describes how they are used, adding adorners to shapes and then using decorators to enhance them and then using Presenters. Then visual states and visual transitions finish templates off.

Finally the thorny subject of binding is left to the last chapter. How to define bindings in XAML so you don't need to use code to change things. This chapter shows how to create bindings, bind to collections and work with collections. It covers update triggers, binding sources and data contexts, data triggers, using views and filtering.

Conclusion

This is quite a classy book with all the illustrations, however because of the need for the UML editor in Chapter eight which isn't in the Visual C# 2010 Express version, I felt I had to knock half a star of the rating. It could have been a great book but for all that it's still a very good book.

Initially I wasn't that impressed with the C# learning section but the WPF section more than redeemed it. It's an excellent introduction to WPF. The WPF sections although occupying just 1/3rd of the book seemed much denser in content than the first 2/3rds of the book on Learning C#.

©2012 About.com. All rights reserved.

A part of The New York Times Company.