Book Review: The C# Helper Top 100
Almost 20 years ago after finishing a training scheme I was hired for my first permanent role. After getting paid for the first time I immediately rushed off to the bookshop to buy myself a programming book. The selection of books in my chosen language of the time (Visual Basic (not .NET!)) wasn't large, but in the end I bought Rod Stephens Custom Controls Library, which still graces my technical bookshelves even now. Since then I've bought many computing books, but I couldn't tell you the circumstances under which I bought most of them. This one however was the first and so I still remember it to this day - and this is also why if I'm asked for a technical book author Rod's name will be the first name that comes to mind. (For the curious, Dan Appleman would be the second, aside from the fact his Win32 book was awesome I'm pretty sure he takes the award for the longest titles in my collection).
Recently Rod announced he'd released a new self-published book, titled The C# Helper Top 100. Unsurprisingly given the title, this is a collection of the most popular posts on the C# Helper website. Although I've mostly given up on buying technical books that I barely read (plus I was fairly certain this book wasn't going to be my cup of tea), I decided I would buy it and review it as I have found some of Rod's posts to be helpful to me in the past. As I don't really enjoy reading these type of books electronically, I bought a paper copy from Amazon. (And also printed by Amazon according to the final page which I found interesting).
Full Disclosure. Unlike my earlier review of one of Rod's books I bought this out of my own pocket on a whim. Everything in this review are my own opinions and interpretations and my own words.
Trotting out old adages
First impressions are generally important and I have to say I really dislike the cover - to me it feels very rough and ill fitting (and what's with all the different shades of green). But it should be all about the content, not the cover and I often have the same thoughts about a great many indie or self published fiction novels I buy and am (usually) nicely surprised by the stories within them.
Book layout and typesetting
Despite being a self published book, Rod has obviously taken some care to lay the book out properly and it compares well against other traditionally published books in my library. The only layout issues I spotted during my read were the odd jarring block of white space when a small paragraph is situated next to a tall image.
Who is the book aimed for
Rod is quite a prolific writer and he has penned many posts over the years, so I was curious as to what the selection of the top 100 would be. While they cover a surprising range of ground, I think most of them fall into the beginner to intermediate category - although there are some much more advanced examples dealing with mathematics and 3D rendering. On the whole though, I think this book would be more suited to beginner or junior developers. I found the book was approachable and easy to read.
Book Outline
The book is divided into a number of categories labelled as parts. Although the list might be daunting, each part is quite small - usually between 10 and 20 pages.
- Serialization
- Graphing
- Text Processing
- DataGridView
- Microsoft Office Integration
- WPF
- Graphics
- Image Processing
- Cryptography
- Dialogs
- Internet
- Miscellaneous Controls
- Geometry
- Algorithms
- Three-Dimensional Programs
- ListView and TreeView
- System Interactions
- Mathematics
- Multimedia
- Interoperability
- Printing
- Miscellany
Chapter Breakdown
This section is a bit long, so if you don't particularly care to read a description of all the contents, you can skip this section.
The first part, Serialization, is comprised of two chapters,
one detailing a basic approach to loading data from CSV and the
second converting objects to and from JSON using the
DataContractJsonSerializer
.
Next up is Graphing. This part includes several chapters on drawing line graphs in WPF, and drawing a histogram in Windows Forms.
Part 3 is Text Processing. The chapters in this section including transforms such as Pascal, Camel and Title case, along with a pair of useful chapters on converting file sizes into more friendly representations. I found some of the chapters in this part to be quite infuriating as they involve techniques such as the use of string concatenation in loops and regular expressions rather than something more efficient. However, eventually I conceded that over-complicating examples was a bad idea and so it was probably better to keep them simple. However, it's fair to say that most of the examples in this section ruffled my feathers.
Following is part 4, a very short part on the DataGridView control. Although the chapters in this section are quite brief, they do give a nice introduction to a control which can be difficult to use. I rarely use this control myself as generally I find it to be clunky.
Then we have part 5 dealing with Microsoft Office
Integration. The chapters here describe reading and writing
data from Excel workbooks, and writing data to Word documents. I
read these chapters out of curiosity, but these days I like to
avoid COM as much as possible and when I need to work with
xlsx
or docx
files, I work with the file data directly and
don't touch Office at all.
Part 6 concerns WPF. Given that many of the examples in the book deal with either WPF or Windows Forms I'm not too certain why this has it's own section but it's another short one. WPF is a technology I've never really used although I have seem some quite clean and nice looking applications written using WPF, as well as some dire ones. One of the chapters dealt with making a label blink and I'm astounded is a popular post - I seriously hope I don't come across an application where the developer is making labels blink.
Graphics is the subject matter for part 7. This part is
comprised of multiple chapters for basic painting, print text
(including aligned and justified text), including getting font
metrics, but by using the Font
object unlike my approach
which used direct P/Invoke. It has another example on drawing
rotated text which uses transforms on a Graphics
object to do
the work and seems an awful lot easier than the way I used to do
it. Most of these examples using System.Drawing
, but there is
also a brief topic on custom rendering with WPF too.
The next part, Image Processing, is another reasonably
chunky chapter. Part 8 starts off by describing how to save JPG
files with custom compression values to compare the output. This
example also details a method of cloning an image without
keeping the source stream around, something that bit
me quite a few
years ago and is possibly worth an article of its own. This is
followed by an example showing one way of making an image grey
scale by manipulating bitmap bits directly, which is much better
than using Bitmap.GetPixel
and Bitmap.SetPixel
. Other
examples include cropping images, scaling images, selecting
parts of images, comparing images and generating a Mandelbrot
set. It then wraps up with a couple of examples on working with
bitmaps in WPF. I was very surprised when I read these examples
as it mentioned a Microsoft Windows Media Photo file format,
a format I hadn't heard of before.
Part 9 is Cryptography. This part is quite small with only a pair of chapters. The first of these details how to encrypt or decrypt a file using AES encryption. The second involves generating cryptographically random numbers. After many of the other more basic examples so far, I was quite pleased to see something like this being highly ranked posts as these are quite advanced topics and rolling your own encryption is generally not a good idea.
Dialogs are the subject matter of part 10. There are two chapters to this part, the first dealing with various ways of allowing a user to select a folder, and the second for building a password dialog. The folder selection chapter starts reasonably enough, describing how .NET only provides access to the old browse for folder dialog instead of the newer one that was added to later versions of Windows. However, its recommendation to eschew using the WindowsAPICodePack NuGet package and instead use Excel via COM interop is a really curious recommendation and not one I agree with in the slightest. I don't see why you'd want to avoid using a third party package which you can distribute with your application and instead rely on a huge, bloated, and slow application which you definitely cannot distribute. This seems to be another quite popular post but I would hope people aren't writing applications that go an ask Excel to display a folder selection dialog. The second chapter is for building a password dialog and is an extremely basic example.
Part 11 is titled Internet. This part includes chapters on
getting stock quotes, weather forecasts, and getting file
attributes from an FTP server. There's also an example on using
the WebBrowser
control with custom HTML.
For some reason there isn't a part 12
Part 13 is named Miscellaneous Controls. This section
includes a few short examples on working with Windows Forms
controls, such as making a checkable group box (in a slightly
odd fashion), finding controls by name, finding ListBox
items
using partial matching and wrapping up with making a
RichTextBox
control fit its contents.
Moving on we have part 14, Geometry. From a personal standpoint I found this to be one of the most useful part of the book as it dealt with topics I'm not hugely competent with and could be useful in some future projects of mine. The chapters include detecting where if two lines are touching, or where they would eventually intersect, finding the distance between lines and points, circle intersection, and a number of chapters on polygons, such as calculating areas, detecting if points are within a polygon and a few more.
As to be expected from Rod, we have part 15 on Algorithms although it is another quite short section. First up is generating all permutations of a set of values, a round robin tournament generator, and finally drawing a family tree. This last example could be reused for any hierarchy diagram really and could be a useful starting point for someone. In fact, while I didn't use this specific example, Rod has a couple of other examples for calculating tree layouts on C# Helper and I did use one of those a few years back as the basis for the sitemap diagrams in WebCopy.
Part 16 deals with Three-Dimensional Programs. This is a reasonably sized part that has a number of chapters dealing with rotation, applying textures, drawing smooth surfaces and drawing wireframes. All of these examples use WPF. While I scanned through the examples, it wasn't a thorough reading - I'm not really interested in trying to write a 3D game or have need for 3D in business applications.
After the trickiness of 3D, we go back to something simpler with
part 17. The ListView and TreeView part has a number of
introductory topics for the ListView
control, detailing how to
use icons, groups and perform custom sorting. This is followed
by slightly more complicated article on printing a ListView
which again I feel could be a very nice starting point for a
reusable component for someones code base. The final chapter
describes how to populate a TreeView
with the contents of an
XML document.
For part 18 Rod shares a number of chapters regarding System
Interactions. Firstly it starts of by describing how to get
detailed printer information using Windows Management
Instrumentation (WMI). I have briefly encountered this in the
past but never really used it so it was an interesting read,
even if I do tend to do that sort of thing the "long way" with
P/Invoke. Next it describes how to combine or resolve relative
paths by using Path.GetFullPath
, followed by an example on
playing system sounds. It wraps up an interesting mix of
chapters by describing how to get the serial number of a hard
drive.
Part 19 is about Mathematics. I only scanned through this section for the usual reason. First up is a complicated looking example on solving a system of equations. This is followed by a pair of chapters on linear/polynomial least squares fit. Next is the Sieve of Eratosthenes and numbering factoring. It finishes of with a nice simple example of converting numbers between bases.
Part 20 deals with Multimedia. Briefly anyway, it's a very
short part. The first example shows how to use animated GIFs by
loading them into other controls like any other image. This
example might have been more interesting if it used the
ImageAnimator
class instead to show how to manually animate an
image (for example if you're doing custom painting in a
ownerdraw control). It is then followed by an interesting
article showing how to play videos using WPF.
Almost at the end is part 21 Interoperability. This is another interesting part which deals with working with other applications. It starts with a chapter on creating a COM DLL for use with Excel, then details how to use drag and drop. The part concludes with a pair of chapters dealing with the Clipboard. Aside from the COM DLL, the knowledge in these chapters should be part of every programmers toolkit as they are very useful techniques to add to applications and it is encouraging to see they are popular.
The penultimate part is 22, Printing. The first chapter
details how to create a tabular report, in a very similar manner
to the ListView
printing example featured earlier in the book.
This is then followed by a chapter demonstrating how to print
multiple pages. Although short, printing support is another
feature which I think can be quite important to have and this
too is good to see as a popular topic.
And finally we have part 23, Miscellany. This starts by
describing how to create a TypeConverter
for use with a
PropertyGrid
control. Although these can be useful things to
create (and I have wrote about them
in the past), I am surprised they are that popular. Next up is a
description of using Unicode symbols in your application (which
sadly also applies to emoji). There is a useful chapter on using
the BackgroundWorker
component, which can be an excellent way
of making your application do background tasks without getting
into the complexity of threads or the TPL. The final chapter of
the book is an article on using the Stopwatch
class.
As you'd often expect with a technical book, the final section is an index, nothing much to add to that!
Getting the source code
The book doesn't come with a CD, but you can download the source directly from the book's web page (click Source Code in the page footer, this is a direct download).
I think it's a shame that there isn't a shortcut to the online versions of the articles, as this would make downloading individual samples easier, as well as being able to view comments or participate in them - sometimes I have found more value in the comments for an article than in the article itself (this is a general comment, not specific to the C# Helper blog), and quite often users post questions to Rod and he always seems to take the time to answer them no matter how inane they are.
Errata
Aside from the missing part 12, I didn't notice any other obvious errors when reading the book until I got to the end. I suspect the final section "Aferward" was probably supposed to be "Afterword", and for some reason all the Index pages are also titled as Afterward.
Closing Words
I found it quite a struggle to see what class of developer I would recommend read a book like this given the diverse subject matter. The random selection of articles within some sections mean I think it's very hit and miss on what people might be interested in. On the other hand, it's not a book focused on any one technology so this is perhaps to be expected.
Any intermediate or above developer is probably going to know everything that is relevant to their field without needing the book, and wouldn't be concerned with the chapters that weren't relevant.
If these really are the top 100 posts then there's some really odd examples. However, the C# Helper Blog has hundreds more posts, and is well worth a look if you're a budding C# developer. In fact, it's worth subscribing to the RSS feed anyway as while I'm not personally interested in many of the articles, something does occasionally pop up now and then to catch my eye. There's very few websites that I've been following for years; many of them disappeared long ago - this is one that has stayed the course.
This is only the second technical book review that I've written and I'm still trying to find my "voice" with them. Comments, feedback and constructive criticism welcome!
Update History
- 2017-10-21 - First published
- 2020-11-22 - Updated formatting
Leave a Comment
While we appreciate comments from our users, please follow our posting guidelines. Have you tried the Cyotek Forums for support from Cyotek and the community?