News for hackers. Stuff that matters.
Re:Signs You're a Crappy Programmer (and don't know it) by edw519 on Friday November 23, 2007 @11:08AM (#82968)
"...obsessing over a few bits of code duplication is often a complete waste of time."

For you, maybe. But what about the guy who applies enhancements 3 years later and has trouble getting through testing because the exact same code was somewhere else and difficult to find because of the 67 mods since then.

Minutes "obsessing" today usually saves hours testing tomorrow.

Re:Signs You're a Crappy Programmer (and don't know it) by nostrademons on Friday November 23, 2007 @12:26PM (#82999)
I usually follow the childhood adage "First time it's funny, second time it's silly, third time's a spanking." Probably better summed up as http://www.c2.com/cgi/wiki?ThreeStrikesAndYouRefactor. Problem is, after 2 repetitions you often don't know what the real abstraction behind the duplicated code is, and so you end up with convoluted objects or closures to swap out parts of behavior, while there's a more natural abstraction just around the corner. If you mercilessly refactor after only the first duplication, you might not see it after the second, because the original code has been abstracted enough that it doesn't look like the third repetition.

This also squares with a lot of IBM's experience in The Mythical Man Month, i.e. code needs at least three clients to really be reusable.

Re:Signs You're a Crappy Programmer (and don't know it) by Goladus on Friday November 23, 2007 @11:18AM (#82972)
"Minutes "obsessing" today usually saves hours testing tomorrow."

True, but the app has to make it to tomorrow for testing to matter at all. It's better to be in the championship trying to figure out how to manage a tired team, than it is to conserve energy during the semifinals and wind up sitting in the bleachers.

Re:Signs You're a Crappy Programmer (and don't know it) by edw519 on Friday November 23, 2007 @11:25AM (#82976)
Where'd you ever get the idea that there is any trade-off between "quick" and "right"?

Doing things according to effective established principles saves a little time today and a lot of time tomorrow.

Quick and dirty usually ends up being neither.

Re:Signs You're a Crappy Programmer (and don't know it) by Goladus on Friday November 23, 2007 @12:13PM (#82994)
Where'd you ever get the idea that there is any trade-off between "quick" and "right"?

I don't have that idea. There is sometimes, though, a tradeoff between current needs and future needs; and that tradeoff can not always be predicted. When that happens, it's logical to give current demands priority.

I can't for example, predict whether a future maintainer of my code would prefer code written with multiple returns, or code that sets temporary values, or code that uses a set of nested ifs, or code that assigns function pointers to a matrix and calls code based on the indices. Each technique has potential drawbackss in terms of future maintainability, likelihood of errors, and speed of immediate implementation. Trying to guess what a future coder (other than myself) will think is just not important in that case.

Effective Principles can only be Established based on a given development environment, and it's the responsibility of those in charge of the environment to make sure the established principles are effective and followed by the developers.

Re:Signs You're a Crappy Programmer (and don't know it) by timr on Friday November 23, 2007 @05:15PM (#83066)
If it were really true that "effective established principles" save time on both the front and the back end, then everyone would be doing them.

The fact is, there's almost always a trade-off between "quick" and "right". That's why so many people choose the former, to the detriment of the latter.