CSS Programming Style

Here are a couple of interesting articles on programming style in CSS. Both articles advocate putting all of the properties of a selector on the same line:

h2 {font-size: 18px; font-weight: bold; line-height: 120%;}

Instead of the conventional method:

h2 {
  font-size: 18px;
  font-weight: bold;
  line-height: 120%;

These authors seem to think that it is actually easier to find the actual property you’re trying to edit in a CSS document if all of the properties for each selector are on one line.

Now, I’ve always written my CSS in the conventional method, but after reading these two articles, it got me thinking. I can’t even begin to describe how many times I’ve sat in front of my computer and scrolled up and down a ridiculously long CSS document looking for some stupid selector. The reality is, you’re never just looking for a property. You’re looking for the property (or properties) of a specific selector. It just makes sense to write your code in a way that would make it easiest to find that selector.

Take this example of some links (code example from Monday by Noon):

/* LINKS */
a { text-decoration:none; color:#00f; }
a:hover { text-decoration:underline; }
a:active { color:#f00; }
a:visited { color:#ccc; }

Now, I think that’s just plain pleasant to look at. I’m envisioning an entire CSS document in short blocks just like this that are really easy to see. I just think I might have to try this out.

<ul class="articleLink">
    <li><a href="http://mondaybynoon.com/2006/02/19/write-better-css/" title="Monday by Noon: Write Better CSS">Monday by Noon: Write Better CSS</a></li>
    <li><a href="http://www.brokenkode.com/archives/css-file-structure/" title="Broken Kode: CSS File Structure">Broken Kode: CSS File Structure</a></li>

The Mythical Man-Moth Strikes Again

I’ve stumbled across The Mythical Man-Month yet again. Well, okay, I guess this doesn’t really count since I got the link on Daring Fireball in reference to the previous article (my original Man Moth encounter).

The latest reference comes from Engineering Management Hacks: The BigBook Technique. I really liked this quote:

After failing to win several arguments on this point, the engineers became exasperated and decided to hold an intervention with the CEO. They each bought a copy of Brooks’ book, brought the CEO into a conference room, and stacked up the copies of the book, telling him, It is extremely urgent that you read this book. We’ve bought you many copies so that you might read it faster. They made their point.

The Mythical Coincidence

Earlier this week I was reading More Aperture Dirt on Daring Fireball when I came across the following paragraph:

The single biggest management problem was a “Mythical Man-Month” disaster. “The Mythical Man-Month” is, of course, the title of Fred Brooks’s seminal work on software engineering management, the basic premise of which is that, as Wikipedia says, “Adding manpower to a late software project makes it later.”

This idea did catch my interest, but primarily because of the name “The Mythical Man-Month”. I misread it at first as “The Mythical Man-Moth,” which sounded just bizarre enough to be interesting. As with many other things, I filed the name away and quickly forgot about it.

Only a day later, I found myself reading Greg Linden’s Geeking with Greg blog for the first time. He has an interesting series called “Early Amazon” about his time working for Amazon in its early years. One of Linden’s blogs in this series was about similarities, better known as “Customers who bought this also bought this.” In his discussion about programming similarities and the “Harry Potter” effect, he happened to use “The Mythical Man-Month” as an example.

This kind of similarity is not very useful. If I’m looking at the book “The Psychology of Computer Programming”, telling me that customers are also interested in Harry Potter is not helpful. Recommending “Peopleware” and “The Mythical Man Month”, that is pretty helpful.

That was twice in two days that I read references to the a book that I had never even heard of before. It’s not like this book is new either, it was first published in 1975.

If this were simply a one time phenomenon, it would be unremarkable. The thing is though, this type of thing happens a lot. It happens often enough that I’ve thought extensively about what might be the cause of it. Why is it that you often learn about things in groups?

If I had only come across the reference to “The Mythical Man-Month” in Daring Fireball and not Linden’s blog, I probably would have completely forgotten about it. But now the title is stuck in my head. What is it that makes this happen? Is it that when you’re interested in certain things, you’re prone to coming across the same references over and over again? Or is it that the second reference is only remarkable because the first reference caught your attention? In other words, if I hadn’t accidentally read the title of the book wrong in the first place, would I even have noticed while reading the Amazon series that I was coming across the same book for the second time in two days? Or is this just merely an odd coincidence that I am making a bid deal of?