Archive for the 'Reviews' Category

Book Review: the CLR via C#

clr_via_c#_bookAs promised, here’s my review of the January book, the CLR via C# by Jeffrey Richter, from my 2010 tech book reading list.

Rating - star_sm star_smstar_sm(3 out of 5 stars)

Prerequisites

  1. IL Tutorial – Although most of the samples in the book are in C#, there are several key code samples in IL and the book doesn’t provide much help for the uninitiated. I think I got a few hundred pages into the book before I relented and took a 100 page reading detour through the first couple of chapters of Advanced .NET Programming so that I could get a better grasp of the basic IL instructions and concepts. My reading sessions went much more smoothly after I did that.

The Good

  1. Illustrative scenarios with diagrams – I’ve read about value and reference types, the stack and the heap, boxing and unboxing, and the generational algorithm for garbage collection several times before, but I felt like this was the first time that I moved beyond a superficial conceptualclrviac#_med understanding. This is primarily due to Jeffrey Richter’s approach of providing concrete code-based examples interspersed with helpful state diagrams. The picture to the right from his “How Things Relate at Runtime Section” in Chapter 4 shows the contents of the thread stack and heap as of a certain line in a simple code sample. His diagrams showing the contents of the heap, the finalization list, and the freachable queue as of each line in the sample code from his chapter on automatic memory management were also incredibly helpful in understanding how garbage collection works.
  2. Critical Analysis – The author periodically presents some strong and sometimes unexpected opinions on various topics through the book. Despite disagreeing with him on several points, such as sealing classes by default or avoiding the use of properties, I always felt like I gained new insights from reading his arguments. For example, I never knew that switching from unsealed to sealed breaks backward compatibility or that the JIT compiler produces more efficient code for sealed classes because it can call it non-virtually. Neither argument was enough to outweigh the testability issue in my mind, but it did give me a better mental hook to assimilate the knowledge than just reading a bunch of random facts in the style of a reference book would have.
  3. Novel Perspective – A few years ago I probably would have dismissed the book based on the title and the frequent use of IL as code samples because my focus as a developer was much more on the language than the runtime. Much like with the hardware on my computer, I expected the virtual machine my code was running on to just work for me and preferred to be shielded from what was under the hood whenever possible. However, as new language features rely more and more on the compiler to perform the magic, the potential for gaining insight into the language by moving closer to the runtime and looking at the IL (Intermediate Language) that the compiler generates increases dramatically. For example, rather than having separate chapters on anonymous methods, lambdas, and closures like most C# books, this book simply has sub-sections in the delegate chapter entitled syntactic shortcut # 1, 2,3, and 4. The decision to use that structure alone did more to provide insight into these new features than the vast majority of other C# books that I have read.

The Bad

  1. Lack of editorial discipline – I have to admit that I experienced periodic bouts of boredom with this book because there were sections that read like reference manuals (e.g. tables with API descriptions) or else included excruciating details about edge cases that seemed to be included more for thoroughness than as a way to explore or illustrate an important concept. This was particularly frustrating because I found myself jumping into skim mode or not fully paying attention and thus almost missing the scattered gems. In my opinion, the book could have gone from good to great if an editor had told him to put a disclaimer about not being comprehensive in the Forward and then challenged him to trim at least a 100-150 pages from the book. In order for a book to be great, it has to hold my attention for the majority of the time and this simply didn’t do it.
  2. Outdated coding conventions (nitpicker’s corner) – It was pretty easy to ignore this, but I have to admit that it threw me for a loop to see all the m_ variable prefixes in the code samples. I thought it was especially odd since the book was published from Microsoft Press since Microsoft has officially discouraged Hungarian notation for quite a while.

What’s Missing?

  1. A larger perspective on virtual machines – I would have loved to have read a chapter that explained where the CLR fits into the larger picture of virtual machines. It would have been nice to know a little bit of history as well as some analysis of what is innovative about Microsoft’s runtime and what is lacking in comparison to other execution engines such as the JVM.

Recommended Sections & Chapters (for lunchtime perusal at the bookstore)

  1. How the Runtime Resolves Type References (Chpt. 3 – pg. 85)
  2. How Things Relate at Runtime (Chpt.  4 – pg. 107)
  3. Reference and Value Types (Chpt. 5 – pg. 123)
  4. Boxing and Unboxing Value Types (Chpt. 5 – pg. 129)
  5. Exceptions (Chpt. 20)
  6. Automatic Memory Management (Chpt. 19)
  7. Threading (Chpt. 23 & 24)

Conclusion – It definitely qualifies as one of the seminal .NET technical books that you should probably try to read it if you’re serious about increasing your depth of knowledge about C# and the CLR. However, if you do find yourself starting to lose interest while reading, then I recommend give simply yourself permission to skim sections that you are already familiar with. There are too many hidden gems in there to let the slow sections derail you from reading it cover to cover.

Popularity: 1% [?]

Newsflash: Killing Zombies Increases your Typing Speed

Here’s a fun productivity enhancing tip that I picked up from JP at the Nothin But Net course I just took.

If you’re much of a gamer, then Typing of the Dead, an old Sega game that was released in 1999, will probably make you wince due to the poor graphics and absurd storyline. In fact, it appears to have won the dubious honor of being runner up in one of PC World’s top 10 worst games list.

Nevertheless, I’m hooked.

blog_typing_game

It could be because I’m one of the only men under 40 that I know who doesn’t own a gaming system and therefore have incredibly low standards when it comes to games. In fact, the last one I remember owning was an Atari back in High School.

It might just be because I have a soft spot in my heart for zombies every since I read World War Z: An Oral History of the Zombie War.

Whatever the reason, I’ve been dismembering hoards of zombies in the last week and hopefully increasing my typing speed in the process.

If you’ve already mastered a tool like ReSharper and are looking to eek out some more productivity by simply increasing your typing speed, then I recommend downloading a copy of the game here and giving it a try. It installs through a simple setup bat file.

It is no longer being sold, so there is no need to worry about pesky copyright laws.

Happy typing.

Popularity: 2% [?]

Random Thoughts on Day 2 of the Nothing But .NET Course

I woke up this morning in a semi-zombie state and just learned that tonight will be our “late night”, which means we’ll go until 2 or 3 am instead of midnight. Nevertheless, I’m still enjoying the course.

Here’s some thoughts about the second day of the course (yesterday).

  1. Actions, Predicates, and Funcs…Oh My - We started the day with a wrap up of all the work we did with delegates from day one. This is when the lightbulb finally went off in my head on the differences between the Actions, Predicates, and Funcs types. They are just convenience wrappers for delegates with different signatures. If you need to pass around a method that returns a bool, then you’ll want to use a Predicate (filtering & matching). If you just need to store a void method, then pick Action. Otherwise, if you’re working with a method that returns a value, then Func is what you’ll need.
  2. Imitate, Assimilate, Innovate – This is a model that represents the stages of learning. I realized that I spend too much time in the imitate stage (adapting googled code) and almost no time in the innovate stage. One of the first goals I selected for myself this week is to spend more time in the innovate stage. A long term goal is to eventually launch an open source project. Kudos to Dru and Rob, two former co-workers, who took this step already.
  3. JP’s BDD framework – This is a fluent interface that replaces test attributes, asserts, and obscure mocking API’s with more a fluent interface that reads more like an English sentence. It disoriented me for a while, but the syntax is starting to grow on me after a few days of using it. Check out this post for a sample of the syntax.
  4. Rewriting frameworks from scratch – The first day we implemented LINQ extension methods from scratch. Yesterday we wrote the routing portion of a basic MVC Framework. Today we’ll be writing an IoC container from scratch. These sound like an inane “reinventing the wheel” tasks, but they are meant to be simple exercises to help us practice good design. Not only did it help increase my conceptual understanding of the lower level infrastructure I’ve been using, but it was also very empowering to temporarily counteract the long term trend of consuming API’s and frameworks at that are higher and higher on the abstraction stack..
  5. Coding Centric Course with no Lab Manuals – Most training courses that I’ve attended or taught have provided students with detailed instruction manuals on how to complete the lab portions of the course. By contrast, JP cuts you loose with minimal direction. It was frustrating at first, but then I saw the value as soon I noticed how focused I was when he finally showed us the solution. It made so much more sense than it would have otherwise once I had some context based on first hand experience.
  6. Using Delegates to Test the Untestable – Probably the most memorable technical epiphany I experienced yesterday was when JP showed us a technique for testing methods that contain static framework methods or concrete framework classes without interfaces, both of which are unmockable when using RhinoMocks. By turning the methods into delegates that are private member variables, we were able to use interaction based testing to verify that the methods were invoked and that all the correct parameters.

Popularity: 1% [?]

Some Lessons from Day 1 of Nothin But .Net

I’m working on 2 hours of sleep last night thanks to my 17 month old, so I thought I would record some of my thoughts about my first day of training yesterday before they are completely lost in the haze of sleep deprivation and the blur of day two.

  1. Delegates are like onions: there are many layers to peel back and prolonged exposure sometimes makes you want to cry.
  2. Slamming a Mountain Dew at 9:00 PM to help to make it through the last few hours of class seems like a really good idea…until you get home and try to go to sleep.
  3. JP codes hella fast. I really need to make a commitment to go mouseless and dig even deeper into R#.
  4. Internal DSL’s are fun to consume, but creating them is like drinking day old Folgers coffee through your nose.
  5. The branching and merging story in Git is way better than it is SVN, but you’re forked if you rely on everyone in the class being able to pull from GitHub through a hotel network.
  6. Goals are powerful. I think I’ve been aiming way too low lately.
  7. Unlearning is sometimes more difficult than learning.
  8. Training should be as much about getting inspired and having your baseline expectations blown away than about learning specific content.
  9. I wish I had taken JP’s course sooner and will recommend it to everyone I know.

Time to go refill my caffeine IV before class starts.

Popularity: 1% [?]

Technical Book Sequels: A Case Study in Trying to Salvage a Second Edition

In a recent post, I raved about Jon Skeet’s book, C# in Depth. I thought it had all the yummy goodness of a six-shooter and then some.

Soon after I wrote the post, I discovered that Jon is currently working on a second edition to the book that will include new chapters devoted to C# 4.0 features. He wrote this post a few months ago that outlined the proposed content and solicited feedback from readers.

In particular, he seemed curious about what he could do to reach the widest possible audience with his second edition. The three target audiences he identified were 1) novice first time readers, 2) experienced first time readers who are already familiar with C# 2.0 and 3.0 features, and 3) developers who have already read the first edition.

At the risk of being sent a nasty LINQ-based virus by Mr. Jon Skeet, who is probably way too far into the writing process to be able to seriously consider feedback about the structure of his book, I thought I would weigh in on the topic. I have never considered purchasing a second edition of a tech book when I have already read and own a copy of the first edition, so the question of what would make me want to purchase a second edition intrigued me.

Here is what it would take for me to buy a second edition of C# in Depth:

  1. No Effort Is Made to Appeal to Novice Developers – The first edition distinguished itself by purposefully not targeting this audience as a way to stay focused. Any effort made to dumb down the book in hopes of expanding readership will likely only serve to alienate those of us who are already fans of the first edition and ultimately lead to a net loss in readers. Since the tech book market is already oversaturated with books targeting novice developers, it seems like it would be very difficult to capture any significant numbers from this group anyways.
  2. The Book is More of a Second Volume than a Second Edition – There are definitely some chapters that I wouldn’t mind rereading (iterators and expression trees come to mind), but otherwise it is not worth it for me to buy a book that is essentially a duplicate of one that I already have just because a few new chapters have been added to the end and some random revisions have been made. To be honest, it would probably take at least 60% new content before I would be willing to make the purchase. Some of the new content could be on novel uses of 2.0 and 3.0 language features that have emerged since the first edition was written, but mostly I want to read about C# 4.0.
  3. The Book Stays the Same Length – As I mentioned in my last post, I think that four hundred pages is probably a magic number for tech books when it comes to being appropriately focused. If the content is going to be 60% new and it is going to stay the same length, that means that some ruthless editing needs to take place. The goal of the book should definitely not be to be comprehensive, but rather to provide insight into particularly difficult and interesting topics that can’t be gleaned from a simple blog post. If someone wants to know about partial classes, automatic properties, or simplified initialization, they don’t need a book to find out about it. The Chapters on C# 2.0 should be probably be condensed to one chapter and the ones on C# 3.0 should probably be condensed to three chapters at the most.

Perhaps spending a few weeks every 2-3 years trimming material that is blatantly no longer relevant in order to produce a new edition might be worth the effort if they are just trying to capture a few straggling new readers, but anything beyond that seems like a hopeless exercise for the author and publisher who hope to sell any significant number of books.

It seems like a much better approach would be to consider this an essentially new book project (hence the volume 2 comment) and try to minimize the overlap in content between the two books.

Are my expectations unrealistic? Does anyone else see any true value in traditional second edition approach of adding a few new chapters and making a few minor revisions?

Since I liked the first book so much I will definitely follow Jon’s efforts and seriously consider his new edition.

However, based on my prior experience with second editions, Jon has an uphill battle ahead of him.

Popularity: 1% [?]

On C# in Depth and the State of Old School Technical Publishing

I recently downsized my technical library and got rid of about 20 brick-sized technical books.

Some of the books covered obsolete technologies, but I got rid of most of them simply because I’d rather access the information that they covered through a search engine on an as needed basis rather than by slogging through a 1000 pages of obscure corner cases up front that I probably will never need or else will forget by the time I actually do need to know it.

If I no longer consider the traditional technical books that I spent obscene amounts of money on as little as 4-5 years ago as even being worthy of collecting dust in my basement, just imagine how reluctant I am to actually spend money on those types of books today and in the foreseeable future.

As far as I can tell, I am not the only one who feels this way. Indeed, I often feel like an out-of-touch old-timer every time I’m greeted with a long silence after asking potential candidates on phone interviews which technical books they have read recently.

Does that mean that the end is near for technical book publishers?

Although it is certainly possible that publishing companies will eventually go the way of many developer magazines like Dr. Dobs, I tend to take the more optimistic viewpoint that the technical publishing landscape will simply shift to more fertile grounds.

Instead of continuing to churn out books that are little more than glorified reference materials, I believe that savvy publishers will start seeking out authors who are able to tell a story and convey a deeper understanding of the underlying principals and technologies in a such a way that the knowledge will not be rendered obsolete as soon the next version comes out, the API changes, or an additional layer of abstraction is added.

I think Jon Skeet’s book, C# in Depth: What you need to master C# 2 and 3, is a perfect example of this new breed of book that will thrive despite the ubiquity of search engines, twitter streams, blog rants, and exhaustive online documentation..

Here are some fundamental aspects of the book that Jon got right:

  1. Narrow Scope – I can’t say how pleased I was to NOT have to contend with an additional 800 pages of basic information on conditional statements and inheritance just to get to the part of the book that I most cared about, the 2.0 and 3.0 features of the language. Just like a large LOC (Lines of Code) count in methods and classes are code smells that indicate a need for refactoring, an excessive number of pages in a book is a clear indication that the book is trying to do too much. I simply won’t consider buying a book that is over 400 pages anymore and it’s not because I have a short attention span (although I do). If the author doesn’t even know what the essence of the book is, then what hope do I have of gleaning it?
  2. Cohesive Story – Reading a typical Wrox reference style book often feels like reading a dictionary or encyclopedia because the content is organized along more or less meaningless categories. By contrast, this book is organized along several story-like themes. First Jon  chose to order the book chronologically and take pains to describe the perceived shortcomings of earlier versions of the language, thus giving a sense for how and why the language evolved. For example, Generics were added in 2.0 to address the performance implications (boxing and unboxing) and type safety issues of using Object as a universal type for methods or collections that dealt with multiple different types. The book also provides a nice cognitive framework for understanding the hodgepodge of 3.0 features by explaining how they are necessary in laying the groundwork for LINQ. Now when I look at a LINQ query, what I really see is a combination of extension methods, lambda expressions, and anonymous types.
  3. Why Over How– When I first looked at some of the 3.0 syntax, I had trouble even recognizing it as C#. The foreign feeling of the syntax eventually disappeared after repeated use, but the underlying sense of it being some inexplicable magic remained. This book helps dispel that feeling by explaining the underlying mechanics for all the syntactic sugar. For example, Jon shows output from Reflector to demonstrate how the C# compiler translates LINQ queries into the method calls against the new IList extension methods or how it turns anonymous types and anonymous delegates into concrete types with compiler generated names. It’s amazing how much more comfortable I suddenly felt with the syntax once I had a better understanding of what was actually happening behind the scenes.
  4. Code Samples As Supporting Evidence – If the thesis is that new syntax represents a fundamental improvement in the language, then there is no proof more persuasive than code. Jon does this particularly effectively by taking the time to implement his samples first in 1.1, then in 2.0, and finally in 3.5 so you can easily see how code grows progressively more concise, readable, and expressive with each iteration. This was particularly helpful in the case of delegates, anonymous methods, and lamdas since they all essentially do the same thing but are expressed in vastly different ways. I was never fully sold on lamdas until I saw how many more lines of code was required to do the exact same thing using good old fashioned delegates.

I’m not saying that the book was a perfect piece of literature or that you will walk away from it an instant C# guru. There are definitely some parts on iterators (the yield keyword) and expression trees that I only partially groked (although I think that has more to do with my own limited processing power than any shortcomings in the book).

However, I would definitely highly recommend this book to any .NET developer. In fact, I would classify it as a must-read for any C# developer.

I would also strongly urge any book authors and publishers out there to take some serious notes on the general approach of this book. The rules of the game have changed. I would rather <insert reader comment here> than spend one more dime on another 1000 page dead tree reference.

** Off Topic: Looking for a job in the Kansas City area? Come work with us at StoreFinancial.

Popularity: 9% [?]

Triple Shot Links # 17

Enjoying life after VSS. Next stop, Crucible… and then on to a possible replacement for CruiseControl (TeamCity or Bamboo).

  1. Saving the World via… TDD? – Steve Harman posts the best TDD code sample ever. It not only demonstrates the context/specification style specs but also clearly proves that TDD is our only hope of preventing the machines that look suspiciously like the current California Governor from taking over the world.
  2. A Rant about RAID, with a Bad Metaphor about Eggs, and No Happy Ending – Dylan Beattie shares his misadventures in using SATA RAID to try to protect his dev machine from catastrophe and in the process comes up with the best analogy I’ve seen in a while:
    “SATA RAID is like carefully dividing your eggs into two really good baskets, then tying them together with six feet of wet spaghetti and hanging them off a ceiling fan.”
  3. Visual Studio 2010 == Visual Studio 2008 + ReSharper - James Kovac catches an MS marketing faux-pas that proves that even the Microsoft Devs don’t like using Visual Studio without ReSharper installed.

Popularity: 22% [?]

Triple Shot Links # 16

I’m just relaxing after a long weekend of migrating our source control from VSS to SVN and upgrading our build server. It turned out to be a fairly sizable project due to all of our automated build scripts, so I’m glad it’s done.

So long VSS. Don’t let the door hit you on the ass on the way out!

  1. Windows 7 Download Frustration – Ken Sipe provides a timely rant about MSDN download sites only working on an IE browser. I downloaded several things from MSDN this last week as I prepped a brand-spanking new build\source control server and managed to string together an impressive string of obscenities every up every time I had to switch browsers just to get the download to work. Special Message to Microsoft: Ignoring the realities of cross-browser compatibility on your corporate sites is inane and does not help promote your browser in any way!  On the contrary, it simply undermines my confidence in your ability to write decent, reliable software. Fix it before IE starts dragging otherwise decent software down with it as it continues to sink into the pit of browser failure.
  2. Dvorak Keyboard: Is it Really Faster? – Jaredpar discusses the pros and cons of switching from the traditional QWERTY to the Dvorak keyboard. For several years I’ve heard urban legends about the QWERTY originally being designed to slow typists down because of the limitations of the mechanical type writer and read about programmers who claim to be faster and more accurate typists after making the switch. I even considered making ‘switching to Dvorak’ one of my New Year’s resolutions for 2009. However, after reading this post I am now inclined to postpone this move indefinitely. I’m just not sure I am willing to spend three frustrating months of lower productivity while I fumble around on the keyboard as my fingers relearn the keys. Even more importantly, I really don’t want to deal with the hassles involved in interacting with other people’s computers afterwards (i.e. pairing).
  3. Limiting Code Comments Increases Productivity -  This is another post that I almost didn’t read because the topic has been done to death, however Jeffrey Palermo presents the argument beautifully and even includes before and after code samples to illustrate the point. I’m glad Jeff emphasized that nobody is suggesting that you will improve readability simply by ripping out existing comments. On the other hand, carefully naming and proper method composition always trumps comments. I can’t tell you how many stale comments have actually led me down an erroneous path because they no longer matched what the code actually did.

Popularity: 15% [?]

Triple Shot Links # 15

Trying to recover from an injury that I got while playing WhirlyBall at a company team-building event. Don’t they know that bad things happen when hyper-focused programmers try to do things that require multi-tasking.

  1. Give and Take in the Software Industry – This is the Secret Geek’s version of The Joel Test and The programmer’s bill of rights. I almost didn’t read it because the jfk_asking_the_users_for_feedbacktopic is a little old and tired, but Leon Bambrick reinvigorated it with his own humorous writing style as well as helpful step-ladder approach to each topic that serves as a good reminder that you can always progress further down the road to progress. I particularly like the following excerpt on having companies provide separate dev, QA, and Prod environments for their developers:
    “You can’t afford testers and you just want me to fix it in production, eh? That’s awesome. That’s great. Next time the dentist is drilling out a cavity in your mouth, I’m going to tell him “This is an urgent operation. Let’s not waste time on X-rays. Just start drilling, you’re bound to hit something that’s rotten. And let’s save a few dollars and cut out the anaesthetic altogether.”

    2009 Predictions, 2008 Predictions Revisited – Ted Neward judges the accuracy of his predictions from last year and provides us with a new set of forecasts for the coming year. Ted’s ability to combine insightful critical analysis with just the right amount of cynicism and humor make this a great read. My favorite is #1 of the 2009 predictions:

    “The ‘Cloud’ will become the next ‘ESB’ or ‘SOA’, in that it will be something that everybody will talk about, but few will understand and even fewer will do anything with.”
  2. Hoops & Yoyo’s Decaf Coffee Crisis – It’s about time that someone took a stand against the abomination known as decaf coffee. Here’s a hilarious Hallmark e-card that you can send to your favorite coffee addict.

Popularity: 14% [?]

BabySmash Receives Coveted ‘Da’ Award

Actually, it was more like a 5 Da’s punctuated by a steady stream of drool.

That was the resounding praise that came from Sofia, my little 9 month old hacker princess. She was reviewing BabySmash, Scott Hanselman’s Windows adaptation of the Mac game AlphaBaby.

In case you haven’t seen it, it is a game for toddlers that produces an array of smiling shapes, colorful letters, and silly laughter as your little one indiscriminately bangs upon the keyboard.

Don’t worry, it makes use of the window’s kiosk mode and various keyboard hooks so that there is no accidental formatting of the hard-drive by little fingers that accidentally stumble upon some deadly, archaic hotkey combination.

Here Sofia is brutalizing the keyboard on my home office computer and gleefully watching the results on my modest dual monitor setup (the third monitor is on indefinite hold as lobbyists make feverish pleas to the powerful Spousal Unit Committee of Ways And Means).

DSC00888

She particularly likes it when she inadvertently hits a key that triggers the Scooby-Doo laugh.

DSC00891Best of all, after the little one goes to bed, Papa developers can head over to codeplex and download the source code for the app.

It’s one of those new-fangled WPF apps, which means that if you’re like me you will be totally lost when you first start looking at it.

Luckily, Scott has written a several posts on the various technical aspects of the app. I skipped them the first time around because I had no prospects of using WPF at work or home anytime soon, but now I’m making my way through them out of curiosity about this application.

I’m hoping that WPF includes an ‘OnDrool’ event because I think my daughter would really appreciate it if I could enhance the application in this way.

Thanks to this Jeff Atwood post, I was even inspired to make my first paypal donation ever for free software. The donation button is set up for a very modest $8.00, so it appealed both to my innate cheapness and my new-found desire to directly reward developers who create cool things.

Thanks Scott!

In summary, if you have a (pre)toddler in your life who can’t wait to get their drooly little hands on your keyboard, then go check out BabySmash.

Popularity: 5% [?]

Next Page »