Coding Horror

programming and human factors

Teach Yourself Programming in 23 Hours

I see that Scott Mitchell has a new book out, Teach Yourself ASP.NET 2.0 in 24 Hours.

Let me preface this post with a disclaimer: Scott Mitchell is a great writer. I've been a fan of his work since his 4 Guys From Rolla days. Anything he writes is bound to be worth reading, especially in this internet era of exploding content, 99.9% of which is crap. Furthermore, what I'm complaining about is determined entirely by the publisher. Not by Scott.

That said, the book's title reminds me of this scene in There's Something About Mary:

HITCHHIKER
Think about it. You walk into a video store and you see Eight-Minute Abs and right next to it you see Seven-Minute Abs – which one you gonna spring for?

TED
I'd go with the seven.

HITCHHIKER
Bingo. Especially since we guarantee you'll get every bit as good a work-out.

TED
How do you guarantee that?

HITCHHIKER
Well it's the company motto: 'If you ain't happy we'll send you the extra minute.'

TED
Huh. That sounds great. (pause) Unless someone else comes out with Six-Minute Abs.

It's a joke, of course, but there's a kernel of truth there. If you can truly learn ASP.NET in 24 hours, what's to stop you from learning it in 23 hours? Or 20 hours? or 12 hours?

Yes, the book title is just marketing hype to drive sales. It isn't meant to be a rational statement of expectactions. The implication that you can learn a giant swath of technology like ASP.NET 2.0 in 24 hours, much less become competent in it, is funny to those of us who know better. That part is obvious. But on a deeper level, it's also offensive. It implies that the field of software development is so shallow that a complete beginner can become competent in 24 hours. Yes, we know better, but not everyone does. And the type of people buying this book most certainly won't know what they're getting themselves into.

As Peter Norvig points out in Teach Yourself Programming in Ten Years, the computer book industry is particularly prone to this weird 24 hour meme:

I did a search for books with the word "days" in the title at Amazon.com and got back 248 hits. The first 78 were computer books (number 79 was Learn Bengali in 30 days). I replaced "days" with "hours" and got remarkably similar results: 253 more books, with 77 computer books followed by Teach Yourself Grammar and Style in 24 Hours at number 78. Out of the top 200 total, 96% were computer books.

The conclusion is that either people are in a big rush to learn about computers, or that computers are somehow fabulously easier to learn than anything else. There are no books on how to learn Beethoven, or Quantum Physics, or even Dog Grooming in a few days.

Like Peter, I humbly submit that books with titles like Teach Yourself ASP.NET 2.0 in 24 Hours cheapen our craft. Any computer book with a length of time in the title – weeks, months, days, hours – is doing its readers a disservice by demoting software development from a craft you spend your life practicing to a mechanical activity that can be learned in a limited time window.

Which is exactly why I'll be publishing Teach Yourself ASP.NET 2.0 in 23 Hours next month. Keep an eye out for it on bookshelves near you!

Discussion

A Fistful of Connectors

Loyd Case recently noted that the standard 3-prong computer power connector is.. not so standard any more:

3-prong-power.jpg

I have yet to see any of these mutant rounded power connectors yet, but I'm surprised that Dell-- a company that built its entire empire around the very concept of beige box PC standardization-- would be cheeky enough to introduce a non-standard power connector. Dell has improved a bit in the design area, but the last thing they need to be redesigning is the standard 3-pin computer power connector.

The 3-pin power connector isn't much to look at, but it's one of the few bright spots in an otherwise hopeless morass of incompatible consumer electronics connectors. Take a look at this fistful of 2-pin power connectors:

2-prong-power.jpg

Given the three zillion different 2-pin power cords out there, it's a miracle that the other end of the cable is standardized. How did we screw that up?

power-cord.jpg

And this is just for computers, mind you. Once we factor in cell phones, PDAs, MP3 players, routers, etcetera, the situation worsens considerably. We moved from North Carolina to California almost a year ago and I still can't find the power adapter for our XM Satellite radio boombox.. among other things.

One possible answer is to pick up a third-party solution like Kensington's 120w mobile power or iGo's 70w Juice.

igo-juice.jpg

These power bricks can power a multitude of devices via interchangeable cord tips. Assuming the correct power tip is available, of course. The best solution would be for manufacturers to standardize on a common set of power connectors. I won't be holding my breath until that happens.

Jef Raskin, in The Humane Interface, points out yet another problem with connectors: sex.

A conventional connector pair is typically built as a male connector with pins and a mating female connector with sockets. This approach results in an inventory of eight kinds of parts that can be used as connectors on equipment or cables:

  • Male connector for equipment
  • Female connector for equipment
  • Male connector for cables
  • Female connector for cables
  • Male-to-female adapters
  • Female-to-male adapters
  • Male-to-male adapters
  • Female-to-female adapters

Jef proposes a hermaphroditic connector:

Jef Raskin's proposed 4-wire hermaphroditic connector

Raskin outlines the advantages of a connector that's both male and female:

If you have two hermaphroditic cables of a given class, you can use the cables either as two seperate cables or joined together into one extended cable. In some cases, the hermaphroditic connector would be no more expensive or complex than a standard, sexed connector. This will not always be true; in many cases, a hermaphroditic connector will be somewhat more complex and more expensive to manufacture. But the added expense is counterbalanced by such factors as:

  • Increased user satisfaction
  • Simpler manuals
  • Fewer manufacturing setups are required
  • Distributors and retailers needing to stock fewer different items

Unfortunately, hermaphroditic connectors haven't caught on, at least for consumer electronics. And I still have about a fifty percent chance of plugging a USB cable in right side up on any given day.

Discussion

Menus and Toolbars Don't Scale

I've witnessed the death of the main menu. And toolbars are on their last legs, too. This screenshot* clinches it for me:

Firefox with dozens of add-ins

Granted, very few people would install this many Firefox extensions. But between this and the Office 2003 debacle, it's patently obvious that the whole menu-and-toolbar paradigm doesn't scale. At all.

[..] many of today's UI paradigms attributed to Apple were introduced well before the Lisa or the Macintosh. Regardless of who gets credit for them, they're good paradigms. There's nothing wrong with menu and toolbar based UI for certain applications. These paradigms served Office well for a number of releases.

It's not that menus and toolbars are bad or that the people who created them weren't smart. The problem is that Office has outgrown them. There's a point beyond which menus and toolbars cease to scale well. A flat menu with 8 well-organized commands on it works just great; a three-level hierarchical menu containing 35 loosely-related commands can be a bit of a disaster.

I'm now starting to question whether traditional menus and toolbars are even appropriate for small applications any more. Web applications tend to be small by design-- and you never see drop-down menus or tiny 16x16 draggable toolbar icons. And they're better without these things.

* via Google Blogoscoped

Discussion

Code Elegance, Code Balance

I've been reading a great book of interviews with programmers circa 1989. One of the most fascinating interviews is with Wayne Ratliff, the author of dBase. Wayne's description of balance in programming really resonated with me:

Interviewer: Can you elaborate on this feeling for balance and elegance?

Balance takes many forms. The code should be crisp and concise. You should be able to explain any module in one sentence, and things should be in alphabetical order, if possible. Just from a visual view of indentation, it shouldn't go off the edge of the paper at any point. It shouldn't have one "if" that's huge and an "else" that's small. Everything should be balanced everywhere. Balance is the key word.

Interviewer: When you write code, does it come out balanced the first time, or does it need a lot of changes?

I do a lot of changing. I like to make an analogy between writing code and sculpting a clay figure. You start with a lump of clay and then you scrape away, add more clay, then scrape away again. And every now and then you decide that a leg doesn't look right, so you tear it off and put a new one on. There's a lot of interaction.

The ideal module should be a page long. If it grows beyond a page, I have to decide, now what is it I'm doing here? How many seperate things am I working on? Should they be broken down into seperate modules? Part of the elegance, and the balance, is that a certain level, in this layer-cake hierarchy of a program, all the modules should be about the same weight, same size, same duty, and same functionality.

Interviewer: How does balance help a program?

The program becomes maintainable. When you have a good balance, it's as if you've discovered some basic physical underlying principle and implemented it. When things get really out of balance, you know something is wrong. There's probably some inherent fault that makes it out of balance. Generally, when I get this feeling that something's out of whack or one module is just too big, I think about what I'm doing, and I reorient or juggle the pieces.

I think you could sum up reams of programming advice with that one concept: balance. We're striving for balance between complexity and simplicity. And we're constantly evaluating and re-evaluating the tradeoffs we have to make to get there.

Balance also applies to the way you physically lay out your code. There's a great visual device in Code Complete's layout chapter where the actual characters of code are replaced with black bars. Like well-designed web pages in other languages, you should be able to understand the general flow of the code even if you can't read any of it:

abstract blocks of code

The aesthetics of your code is purely an internal implementation detail. How you place your squigglies won't affect users in the slightest. But attention to internal code layout details implies that you're equally attentive to the external details. If you're structuring your code to be accurate, consistent, readable, and maintainable, your application will work better-- because it's balanced.

Discussion

The 2GB Windows XP Hibernation Problem

If you ..

  • use Windows XP SP2 of any flavor
  • have 1+ gigabytes or more of system memory
  • use hibernate functionality

.. you may have experienced this error at some point when attempting to hibernate:

Windows - System Error: Insufficient system resources exist to complete the API.

I know I have. It drives me nuts, because my system fails to hibernate after I've already initiated the hibernation process and walked away from it. This is on my desktop*. You can imagine how catastrophic this could be on a laptop; you'd be putting a laptop in your bag that was still fully on!

To avoid the error, install this Microsoft hotfix, which is graciously hosted by Owen Cutajar. It's from Microsoft KB909095, which also explains the problem in a bit more detail:

To prepare the computer to hibernate, the Windows kernel power manager requires a block of contiguous memory. The size of this contiguous memory is proportional to the number of physical memory regions that the computer is using. A computer that uses lots of RAM is likely to use more physical memory regions when the computer prepares to hibernate. Therefore, a larger amount of contiguous memory is required to prepare the computer to hibernate.

Additionally, the number of physical memory regions varies according to the programs, services, and device drivers that the computer uses. Therefore, the hibernate feature occasionally fails.

When the Windows kernel power manager detects that the hibernate feature has failed, the hibernate feature remains disabled until you restart the computer.

I originally researched this back in December, but the problem wasn't happening with enough frequency to make me call Microsoft support and dig up a hotfix. Now it is. And people have mirrored the patch so we don't have to go through the busywork exercise of calling Microsoft support to obtain a necessary hotfix. What a ridiculous policy.

* I would use sleep, but the motherboard I use isn't smart enough to restore the correct overclocked CPU speed. I get bumped down to stock CPU speeds every time I resume from a sleep state.

Discussion