Do you get notified of every email you receive? You don’t find that distracting? I find it very distracting. I remember receiving emails every couple of minutes at my old job. I finally had to turn off the notification alerts because I could not concentrate on work. At my current job, we use Lotus Notes and though the amount of email is great, I don’t get notifications like you do in Outlook. That helps a lot.
I agree with Jeff Atwood completely:
If you want more productivity: turn off automatic email notification. Concentrate on the thing you’re doing and finish it. Then, check your email.
I checked out the entry on Slashdot about the Code Reading book (very good book, BTW). Scrolling down, I came across an interesting discussion about coding style. I found the two entries that I list below very insightful. What’s the point here? Good developers write code that is readable. Good developers know how to tackle complexity: they make hard things seem easy. That’s probably the single most important thing I look when I look at code. If it’s simple, it’s good. I love simplicity.
Toby Haynes on coding style:
Comments also matter. It’s easy to code a couple of thousand lines of fresh code over a weekend if you get in the groove. It is almost impossible to unpick it one year later if you didn’t comment it as you go.
Variable and function names should be expressive. No single letter variable names! No obscure combinations of letters like words with no vowels (fnct could be function or function control, or even Function Numerical Constant Type). And personally I find that reverse Hungarian notation can be more trouble than it’s worth. Annoying!
Build in automatic checks on everything. If a pointer to a function should never be null, check it and stop if it is. If a variable should only have values 1 -> maxIterations, then check it. If you (or anyone else) ever breaks that assumption, the code will flag it for you.
Beyond that, nothing beats good design, especially designs where extending the original work is easy. So many designs end up as tangle knots of conflicts because they ended up trying to solve problems that the original code base never envisaged.
Re: Coding Style by AuMatar
A better rule than size IMHO is the one logical operation rule. A function should do one logical operation (read a file, write a file, run a state machine, calculate something, etc). They should contain all the logic needed to do that operation plus any debug and error handling that makes sense at that level of code. They should be broken up into subfunctions ONLY if those subfunctions themselves follow the logical operation rule, and only if that logical operation makes sense outside of the context of the higher function.
Take the state machine example. If it needs to wait on a semaphore before each iteration, the wait should be its own function- waiting on a semaphore is a logical operation. The logic for each state should NOT be separate functions, they are part of the state machine and make no sense without the whole of the machine for context. Breaking them out results in harder to read code, even if you do lose the nesting. But if in case RUNNING_MOTOR you issue a stop command to the motor that probably makes sense to be its own function- how you actually stop the motor isn’t part of the core logic of the machine.
I guess my point is- lines of code isn’t the enemy, some things are complex and need many lines to do. Nesting isn’t the enemy, some things require many loops/ifs. The enemy is a lack of clear separation of functionality and lack of clear abstraction between parts. If you have separation and abstraction, it tends to hit the optimal readability. If you don’t, it will fail either because you broke it up too much (too little context) or too little (too much context).
I’ve heard many definitions, but the one below, by Kirk Knoernschild, seems closest to my heart.
Quality code is code that:
On a related not, here’s what Robert Martin, a software craftsman, has to say how to write quality code:
Will the team be able to implement it? Is the responsibility uniformly distributed? Is it documented? Is there duplication? High cohesion and low coupling? Is it as simple as possible?
These and the others are part of the Top 10 Elements of Good Software Design by Mr Ed. Very good list.
Programmers at Work: Interviews
by Susan Summers
ISBN 0914845713
Date Read 2/2005
My Rating
It’s an important book, recommended by a lot of people. I bought it mainly because Steve McConnell recommended it. Is it good? Yeah, it’s good. Is it great? No. It’s not great because it’s been published in the 1980′s. When you read some of the interviews, you sense that. On the other hand, it is good because you get to see how great programmers think. I especially liked the interviews with the following four great minds: Butler Lampson, John Warnock, Bill Gates, and John Page. I recommend reading them. (I wrote it for myself on the back of the book to re-read those four interviews.)
Do you program according to specs laid out by designers/architects? If so, you’re a programmer. On the other hand, if you design, if you talk to customers, if you elecit requirements and do other areas of software development, you’re a developer. I like to call them software engineers: you engineer the software from start to finish.
Eric Snow from SourceGear is looking for a developer. Read his explanation of what a developer is and what a programmer is. I like the way he writes. Plus, it’s good stuff.
What is JavaServer Faces? Do you know what Struts is? No? Then you must have been on a vacation for a while, huh? Anyway, Struts and JSF are competing technologies. They’re basically implementations of MVC (you have to know Model View Controller).
I’ve done several examples with Struts and I must say that it’s OK. I’m not a big fan of Struts.
JSF, on the other hand is different. It has the better things out of Struts, it is easier to use, and it’s a standard. Plus, JSF will be included as part of J2EE 1.5 coming out next year. I must say I’m a big fan of JSF and I think it will be big over the next couple of years. Learn it, compare it, and use the better one.
There is a lot of coverage on JSF lately. Here are two articles I really liked that talk about Struts and JSF. One is from the creator of Struts, Craig McClanahan, The Best of Both Worlds: Integrating JSF with Struts in Your J2EE Applications. The second one is probably the best intro to JSF you’ll find, JSF for nonbelievers: Clearing the FUD about JSF by Rick Hightower.
|
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
–Martin Fowler
|
Holub on Patterns: Learning Design Patterns by Looking at Code
by Allen Holub
ISBN 159059388X
Date Read 1/2005
My Rating
It’s OK, not great (My review at Amazon.com — 3/5 stars)
I looked at one other book before purchasing this one, Refactoring to Patterns, but I picked this one because this one had 5/5 average review. I should have picked the other one, though.
This book starts out great, the first 2 chapters (out of 4) give you quite a few tips and rules of thumb. However, once you get to chapters 3 and 4, the chapters on patterns, the author does a so-so job. Quite frankly, I had hard time reading those chapters. I thought that by looking at code you might learn more about patterns. Not true. Especially, when you have to look at GUI code, as is the case with this book. I did not like that.
Maybe that’s only me, but I would recommend the Joshua Kerievsky’s book, Refactoring to Patterns, instead (at least look into it).