Thoughts from the office by Ed Ball
Friday, March 28, 2008

The second edition of Programming .NET Components by Juval Löwy was a decent book on .NET techniques, though I found myself unconvinced by much of his advice. In particular, Juval is a big fan of interface-based programming, but doesn’t spend much time explaining the “benefits of interface-based programming” (p. 50). I find myself happy to have left it behind with COM. But perhaps some of this advice works better in “enterprise” situations than it does in client applications?

In any case, most of the value for me with books like this comes from learning things I didn’t know before, so here’s my list of the highlights (and criticisms):

  • p. 30: He seems to claim that the “global namespace” is really just a top-level namespace named “global”, but I don’t find that to be the case.
  • p. 55: He talks about “programming defensively” by checking to see if an interface is supported by an object. “Never assume an object supports an interface.” This advice may hold well with interface-based programming, but when you’re programming with concrete types, it’s better to throw an exception if you expect an interface that isn’t there.
  • p. 56: He doesn’t articulate the “advantages” of using interfaces on structs very well. In particular, he doesn’t mention that casting a struct to an interface causes it to be boxed, in which case you may as well be using a class instead of a struct.
  • p. 96: Here’s something I didn’t know: «using (null)» is legal; it simply does nothing at the end of the using block.
  • p. 98: He has his own “dispose pattern,” but doesn’t seem to know that there’s a standard dispose pattern (or should explain why he doesn’t use it).
  • p. 111: A SolutionInfo.cs file that is shared among all projects of a solution is a great idea that we’re using in our solutions at the office.
  • p. 143: “You should always publish [events] inside a try/catch block” that eats the exceptions. I tend to put that responsibility on the client; ignoring exceptions is never healthy in the long run.
  • p. 149: System.ComponentModel.EventHandlerList is a handy way to support large numbers of events without storing an individual delegate for each of them.
  • p. 181: I didn’t realize that the AsyncWaitHandle of an IAsyncResult may not be released until the handle is garbage collected. I don’t agree with his advice to explicitly close the AsyncWaitHandle, though, because AsyncWaitHandle is often lazy-loaded; if the handle hasn’t been created, you’ll create it just to close it. Better to just leave it alone; some IAsyncResult implementations are smart enough to close the handle automatically when you call EndXxx.
  • p. 198: He advises against setting IsBackground to true on a Thread; I agree. “You shouldn’t count on .NET to kill your background threads for you.”
  • p. 204: I learned about “synchronization domains” (which are nothing like “synchronization contexts”) and “context-bound objects” – it reminds me a lot of COM apartments. Maybe someday I’ll find a use for them.
  • p. 215: He unfortunately encourages the generally discouraged practice of locking “this” for synchronizing instance members and locking “typeof(ThisClass)” for static methods.
  • p. 250: He jumps through a lot of hoops to make sure that raising an event can’t throw a null reference exception; I had never considered the problem of possible inlining. A good reason to avoid thread-safe events altogether, but I’d definitely use the do-nothing delegate trick before using a MethodImpl attribute to suppress inlining.
  • p. 255: I forget that “managed threads” aren’t guaranteed to be actual individual physical threads.
  • p. 263: Events can use ISynchronizeInvoke to raise events on the proper thread for a client with thread affinity.
  • p. 268: I had forgotten about the XxxAsync/XxxCompleted/CancelAsync pattern provided by web service proxy classes.

I stopped reading carefully at this point – the rest of the material escaped my interest. To conclude this review, I’ll not discourage you from reading the book, but there are lots of other .NET books that you should read first.

3/28/2008 7:48:34 AM (Pacific Standard Time, UTC-08:00) | Comments [1] | Books#
Friday, January 11, 2008

For my latest technical blogging, check out http://code.logos.com/blog/. Specifically, check out my introductory post and my first technical post.

1/11/2008 3:20:40 PM (Pacific Standard Time, UTC-08:00) | Comments [0] | Code#
Wednesday, September 19, 2007

I’ve read many “how to program with WPF” books, and already have a year of programming experience in WPF, so I’m really not able to fairly review books like Programming WPF, by Chris Sells and Ian Griffiths, at least from a beginner’s point of view. This book is actually the second edition; I reviewed the first edition way back in October 17, 2005.

I’ll start with my conclusion – there is enough important material unique to this book that it is a must-have for the shelf of a WPF programmer. Despite its girth (835 pages), it isn’t able to explain every facet of WPF in detail – in particular, I noticed that the Border class was given very little reference. I was worried that I wouldn’t find much of anything I didn’t already know, but I was fortunately wrong on that account, and will close the review by summarizing the most interesting bits:

  • p. 59: You can safely use data binding with Settings.
  • p. 136: Explains how focus scope affects command routing.
  • p. 189: Good information on validation, including custom validation.
  • p. 226: Grouping with PropertyGroupDescription.
  • p. 298: Handy table of the template parts used by each control.
  • p. 336: The ValidateBindings method.
  • p. 341: You can navigate a NavigationWindow to a string.
  • p. 379: It’s dangerous to use types as resource keys.
  • ch. 12: Great information on resources.
  • p. 432: Working with bitmaps and bitmap effects.
  • p. 484: Low-level text output.
  • ch. 15: Outstanding information on printing.
  • p. 672: Using attached properties to identify template placeholders.
  • p. 730: Screenshots demonstrating airspace issues with interop.
9/19/2007 8:32:18 AM (Pacific Standard Time, UTC-08:00) | Comments [1] | Books#
Tuesday, July 03, 2007

Pro WPF, by Matthew MacDonald, is quite impressive both in its breadth and in its depth. This tome of nearly 1,000 pages describes seemingly every feature of WPF with enough detail to actually get something done. No book of this size is perfect, but the typos were rare enough to not be distracting, and the writing was easy to read and comprehend. Even the succession of chapters is logical enough to allow sequential reading through the book, despite the varied topics.

Even if you’re not of a mind to read the entire book cover to cover as I did, you’ll still want this book as a reference for topics that you won’t find discussed in the other WPF books, including how to build a custom view for a ListView, the many options for implementing printing in your application, how to create and use classes derived directly from Visual, etc. Highly recommended.

7/3/2007 9:26:45 AM (Pacific Standard Time, UTC-08:00) | Comments [0] | Books#
Monday, June 25, 2007

Dreaming in Code, by Scott Rosenberg, is an outstanding look at the software development process from the perspective of a well-funded medium-size open source project that has been in development since 2003. This book is compelling from beginning to end, trying to help even the non-technical reader understand why software development is so hard. The many difficulties faced by this development team were surprisingly (and sometimes disturbingly) familiar. Highly recommended for everyone in software, and anyone else who wants to understand our world a little bit better.

6/25/2007 1:22:51 PM (Pacific Standard Time, UTC-08:00) | Comments [1] | Books#

The Old New Thing, by Raymond Chen, is an entertaining and enlightening collection of articles about Windows technology. It is a must-read, particularly if you're not already an avid reader of his blog of the same name.

I must confess to skipping the 88 pages that comprise chapter 10, "The Inner Workings of the Dialog Manager." It has been nearly a decade since I assembled a classic Windows dialog box, so the subject simply doesn't hold my interest like it once would have. In fact, a lot of the information in this book would have been invaluable 10 years ago...

The most important chapter in this book is "Taxes," which is a great reminder of the little things that a software application should handle properly (fast user switching, high DPI displays, etc.).

The whole book (aside from chapter 10) is a great read. Even in the brave new world of the .NET Framework, WPF, etc., much of this information is still quite relevant. Highly recommended.

6/25/2007 1:21:02 PM (Pacific Standard Time, UTC-08:00) | Comments [0] | Books#

I enjoyed reading (and sometimes skimming) About Face 3: The Essentials of Interaction Design, by Alan Cooper, et al. It is full of “design principles,” all of which are neatly listed in the appendix, and most of which seem right on target. They serve as an excellent reminder of the things to be aiming at when designing a software product.

I must take some issue with the very first guideline, though – “Interaction design is not guesswork.” It is not purely guesswork, of course, but neither is it an exact science. Even with unlimited time, resources, and intelligence, I doubt that we could ever get everything “right,” if there is such a thing. Some of his examples of good interaction design are questionable, in my mind. But it is good to treat design as something that can be done right, if only to keep us from giving up altogether; we should do the best we can.

6/25/2007 1:18:42 PM (Pacific Standard Time, UTC-08:00) | Comments [0] | Books#
Friday, May 11, 2007

The content of Professional WPF Programming is too broad and too shallow, giving only a glimpse of various aspects of WPF and related technologies (Expression Blend, WCF, and .NET Security). If you are completely unfamiliar with these technologies, this book might give you a nice overview, but I don’t expect I’ll be picking this book up again.

5/11/2007 2:22:52 PM (Pacific Standard Time, UTC-08:00) | Comments [0] | Books#

Yet another excellent WPF book is Essential Windows Presentation Foundation by Chris Anderson. Having read a number of WPF books, and already having considerable experience on the platform, it is hard for me to judge how well the book would fare for beginners, but my instinct is that some concepts are introduced without much explanation, which might make things difficult for a newbie.

Being one of the architects of WPF gives Mr. Anderson’s words more authority than other WPF books; even better, he uses his inside knowledge to help us understand some of the deep concepts of WPF. Of course, I found myself wanting more – more depth on the subjects that he did cover, and more breadth to help with the subjects he didn’t cover. I highly recommend this book, though you might wait to read it until you’ve made it through those of Petzold and Nathan.

5/11/2007 2:19:25 PM (Pacific Standard Time, UTC-08:00) | Comments [0] | Books#
Friday, January 26, 2007

Considering how little information there is out there on WPF, it is no surprise that I eagerly read Windows Presentation Foundation Unleashed by Adam Nathan, especially considering how much I appreciated his previous book on .NET/COM interop. I was hoping for more depth and less breadth, but I think I'll have to wait for someone to write "WPF Internals" for that. Otherwise, this book was quite good; I especially enjoyed the full color code samples and screenshots. This book makes a good companion to Petzold's book, since it teaches different things and takes a different approach. I certainly recommend it to all WPF programmers.

1/26/2007 9:10:46 AM (Pacific Standard Time, UTC-08:00) | Comments [0] | Books#

It probably isn't really fair for me to review Why Software Sucks... and What You Can Do About It, by David Platt, since he's not writing this book for programmers, but rather for the users of our software. I didn't enjoy the book as much as I had hoped, partially because it's rather more crass than I would like. Still, the book gives good information -- consumers do need to be convinced that bad user interface isn't their fault, and they need to be encouraged to punish the bad and reward the good with their dollars and feedback.

1/26/2007 9:06:01 AM (Pacific Standard Time, UTC-08:00) | Comments [0] | Books#
Tuesday, December 05, 2006

I am eagerly reading everything I can about WPF, the new application framework from Microsoft, so I looked forward to receiving my copy of Foundations of WPF, by Laurence Moroney. Unfortunately, I was very disappointed in this short book of barely 300 pages. It is merely a brief introduction to WPF, especially considering that more than half of the content consists of trivial source code examples and huge grayscale screenshots. Top it off with the fact that the text was written well before WPF shipped and you'll find yourself much better off reading the other two WPF books again.

12/5/2006 7:55:18 AM (Pacific Standard Time, UTC-08:00) | Comments [0] | Books#
Search
Archive
Links
Categories
Administration
Blogroll