Cleverness
-
I abhor reading code which is intentionally clever. Clever code which functions properly is garbage. If you're smart enough to write clever code which works, stop being a jerk and write smart code which works. Please. Clever code requires me to spend time figuring out how some pompous smart person thinks. Smart code allows me to just read it and move on. Agreed?
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
I prefer clever code over cowboy code anyday :)
xacc.ide
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach." -
I abhor reading code which is intentionally clever. Clever code which functions properly is garbage. If you're smart enough to write clever code which works, stop being a jerk and write smart code which works. Please. Clever code requires me to spend time figuring out how some pompous smart person thinks. Smart code allows me to just read it and move on. Agreed?
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
Amen. "Everything should be made as simple as possible, but not simpler." -- A. Einstein And now, allow me to be a jerk:
#define Swap(x, y) (x^=y^=x^=y)
-
Bah! As long as your "cleverness" is well documented, why is it bad? Maybe you can learn some new techniques or ways of thinking from someone else's cleverness. Seems to me programmers these days don't want to think, or don't have time to think. I like a good brainteaser every now and again - keeps me sharp!
- S 50 cups of coffee and you know it's on!
CP is notorious for overvaluing "clever" things. That's probably why lame one-liner posts on the forums always get 5 star votes. Clever coding isn't a technical problem; it's a personality problem.
-
CataclysmicQuantums wrote:
Bit shifting instead of multiplication for instance
I remember those tricks, and they still work well from time to time. ---modified Though it is tough to beat an optimizing compiler these days.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
Paul Conrad wrote:
Though it is tough to beat an optimizing compiler these days.
And hardware optimization.
If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe - but not a personality. - Charlie Brooker My Blog - My Photos - ScrewTurn Wiki
-
I abhor reading code which is intentionally clever. Clever code which functions properly is garbage. If you're smart enough to write clever code which works, stop being a jerk and write smart code which works. Please. Clever code requires me to spend time figuring out how some pompous smart person thinks. Smart code allows me to just read it and move on. Agreed?
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
Somebody (i cant remember who) once said.... Any fool can write code that a computer can understand. Good programmers write code that humans can understand. :) Guy
-
I abhor reading code which is intentionally clever. Clever code which functions properly is garbage. If you're smart enough to write clever code which works, stop being a jerk and write smart code which works. Please. Clever code requires me to spend time figuring out how some pompous smart person thinks. Smart code allows me to just read it and move on. Agreed?
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
Ummmm - define 'clever code' - what your message says to me is that you don't believe you should have to think when reading code - I can't agree with that.
-
I abhor reading code which is intentionally clever. Clever code which functions properly is garbage. If you're smart enough to write clever code which works, stop being a jerk and write smart code which works. Please. Clever code requires me to spend time figuring out how some pompous smart person thinks. Smart code allows me to just read it and move on. Agreed?
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
-
I abhor reading code which is intentionally clever. Clever code which functions properly is garbage. If you're smart enough to write clever code which works, stop being a jerk and write smart code which works. Please. Clever code requires me to spend time figuring out how some pompous smart person thinks. Smart code allows me to just read it and move on. Agreed?
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
-
Josh Smith wrote:
I abhor reading code which is intentionally clever. Clever code which functions properly is garbage. If you're smart enough to write clever code which works, stop being a jerk and write smart code which works. Please.
You mean like: foo.GetType().GetProperty("Bar").SetValue(foo, "fizbin", null); when foo.bar="fizbin" would have worked just fine? Marc
-
Ummmm - define 'clever code' - what your message says to me is that you don't believe you should have to think when reading code - I can't agree with that.
Stuart Dootson wrote:
Ummmm - define 'clever code' - what your message says to me is that you don't believe you should have to think when reading code - I can't agree with that.
Clever code is unabashed geeky-ness. Code which is written for the sake of proving how smart one is, or how knowledgeable one is of abstruse features of a language. I certainly agree that reading code requires thought, but something which can be simple shouldn't require me to sit there and "figure it out." They don't pay us to prove how smart we are by creating little puzzles, they pay us to create working software on time.
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
-
But that takes the fun out of it.
I'd like to take the fun out of it for the clever programmer. Along with his spleen :|.
Software Zen:
delete this;
-
I don't know if that qualifies as clever, just verbose.
MY BLOG
Brady Kelly wrote:
I don't know if that qualifies as clever, just verbose.
Oh, if you want clever and terse, and if I knew about C# lambda and functional programming, I could probably whip somethin up that harkens back to the days of APL. Marc
-
Bah! As long as your "cleverness" is well documented, why is it bad? Maybe you can learn some new techniques or ways of thinking from someone else's cleverness. Seems to me programmers these days don't want to think, or don't have time to think. I like a good brainteaser every now and again - keeps me sharp!
- S 50 cups of coffee and you know it's on!
Too Bad my coworkers are too "clever" to be bothered with documenting. There is not *one page* of documentation! And me, the new guy, is so screwed...
-
I abhor reading code which is intentionally clever. Clever code which functions properly is garbage. If you're smart enough to write clever code which works, stop being a jerk and write smart code which works. Please. Clever code requires me to spend time figuring out how some pompous smart person thinks. Smart code allows me to just read it and move on. Agreed?
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
I'm not quite sure we're on the same wavelength about the whole "clever code" terminology, but nevertheless... if there's a possibility to fit five lines into one, do it. No reason not to. If someone can't read int newInt = myInts[index++] or the likes of it... then he should switch to VB scripts, or learn C[++,#]. Learn it for real, this time.
A buffalo soldier, a dread-like rasta !
-
I'm not quite sure we're on the same wavelength about the whole "clever code" terminology, but nevertheless... if there's a possibility to fit five lines into one, do it. No reason not to. If someone can't read int newInt = myInts[index++] or the likes of it... then he should switch to VB scripts, or learn C[++,#]. Learn it for real, this time.
A buffalo soldier, a dread-like rasta !
rastaVnuce wrote:
int newInt = myInts[index++]
That's not clever. By "clever" I mean things like depending on some abstruse side-effect of a method call with a certain parameter value to make something work, etc.
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
-
rastaVnuce wrote:
int newInt = myInts[index++]
That's not clever. By "clever" I mean things like depending on some abstruse side-effect of a method call with a certain parameter value to make something work, etc.
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
Thank you for the lesson. As a rookie I always thougt that if I write code that confuses others they will regard me as the best in the team, not knowing that that actaul makes things difficult for the next person to maintain that app. I am now going to start writing SMART code not unnecesary Clever code. :-D Thank You.
khuzym
-
Thank you for the lesson. As a rookie I always thougt that if I write code that confuses others they will regard me as the best in the team, not knowing that that actaul makes things difficult for the next person to maintain that app. I am now going to start writing SMART code not unnecesary Clever code. :-D Thank You.
khuzym
khuzwayom wrote:
I am now going to start writing SMART code not unnecesary Clever code.
Good decision.
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
-
I abhor reading code which is intentionally clever. Clever code which functions properly is garbage. If you're smart enough to write clever code which works, stop being a jerk and write smart code which works. Please. Clever code requires me to spend time figuring out how some pompous smart person thinks. Smart code allows me to just read it and move on. Agreed?
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
-
Stuart Dootson wrote:
Ummmm - define 'clever code' - what your message says to me is that you don't believe you should have to think when reading code - I can't agree with that.
Clever code is unabashed geeky-ness. Code which is written for the sake of proving how smart one is, or how knowledgeable one is of abstruse features of a language. I certainly agree that reading code requires thought, but something which can be simple shouldn't require me to sit there and "figure it out." They don't pay us to prove how smart we are by creating little puzzles, they pay us to create working software on time.
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
I guess I just have an issue with blanket rejection of 'clever' code, having written some for a specific reason (performance related, in a resource-limited embedded system) and having it rejected because it was 'clever' and replaced with code that was 2 or 3 times slower. In most desktop situations, I would agree with you - clever code isn't desirable or should be stuck in a library so you don't see the implementation, just the API (e.g. the MS implementations of 'strcpy' and 'strcat' in hte C runtime). Trouble is, 'clever' does have many and varying definitions - for example, I wouldn't call use of the C++ standard library collections and algorithms 'clever', but I know people who would.
-
I abhor reading code which is intentionally clever. Clever code which functions properly is garbage. If you're smart enough to write clever code which works, stop being a jerk and write smart code which works. Please. Clever code requires me to spend time figuring out how some pompous smart person thinks. Smart code allows me to just read it and move on. Agreed?
:josh: My WPF Blog[^] Without a strive for perfection I would be terribly bored.
What about clerverly(:)) simple code? For instance, with the jQuery toolkit for JavaScript there is an array handler called "each" used like this: $(arrayi).each(function(i){ document.write(i) }); I don't normally dig the "clever code", but I love when it is tastefully simple.
ASP.Net meets jQuery... Imagine the possibilities.