Bad Programming Habits We Secretly Love (infoworld.com)
snydeq writes: Breaking the rules can bring a little thrill — and sometimes produce better, more efficient code. From the article: 'The rules are more often guidelines or stylistic suggestions, not hard-and-fast rules that must be obeyed or code death will follow. Sure, your code might be ridiculed, possibly even publicly, but the fact that you're bucking conventions adds a little bit of the thrill to subverting, even inadvertently, what amounts more often than not to the social mores of pleasant code. To make matters more complex, sometimes it's better to break the rules. (Shhhh!) The code comes out cleaner. It may even be faster and simpler.' What bad programming habits can't you (or won't you) break?
From TFA:
my friend wired together an Eliza-like AI to his editor, and voilà, every function had a few lines of "documentation." The boss wasn't smart enough to understand that the lines meant nothing, so my friend was off the hook. His code was officially documented. I think he even got a promotion!
He should have been shot.
Does it trump the "make the code work" rule?
-- Give me ambiguity or give me something else!
Back during Y2K updates to our code base, we'd occasionally have to deal with code written by an ex-employee, who we'll call John. It was so bad that every time someone opened a file he had worked on you'd hear a loud "FUCK! Another John file!" over the cubical walls.
Ah, the "No True Clean Code" fallacy.
Great minds think alike; fools seldom differ.
"Think of newspaper headlines when commenting. Don't make somebody read the whole article to know what the article is about." You_won_t_believe_the_three_things_this_method_does(), This_method_just_announced_it_was_running_for_the_GOP_presidential_nomination(unsigned int year), Five_ways_to_make_your_integers_long(), ...
I try to keep to 80 rows. A little harder to read, but worth it.
PS: MOOO YOU COW!
It is actually a best practice. What I hate is seeing 'x' used for a discrete variable, or n for a float. Such people without regard for mathematical form should be shot.
Any fool can see that.
When someone says, "Any fool can see
1) Make the code work
2) Make the code readable
4) Make the code flexible.
0) Make the code on time
3) ???
5) Make the code - PROFIT!
I once saw source code for a library, written in Ada that had the following "feature".
Since Ada code is "self documenting", each routine had a block comment documenting said routine. The block comment was LITERALLY a copy of the routine, commented out...
e.g.:
-- procedure body f is
-- begin
--TEXT_IO.PUT_STRING('Hello world');
--TEXT_IO.PUT_LINE;
-- end f;
procedure body f is
begin
TEXT_IO.PUT_STRING('Hello world');
TEXT_IO.PUT_LINE;
end f;
General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
yeah, Knuth is always your go to guy...
“Hello, GOTO. My name is Inigo Montoya. You killed my father. Prepare to die.”
...who we'll call John...
...a contractor I'll call Paul
Right, so who's going to come up with George and Ringo to make up the full set?