Re:Top Surprises When Starting Out as a Software Developer
by trekkin on Sunday August 26, 2012 @07:51AM
(#4434912)
So you suggest that instead of several if/then/elses a clever recursive function call should be used, right? And the function should take its arguments by value, and have zero side-effects?
[ Parent
| on HN ]
Re:Top Surprises When Starting Out as a Software Developer
by icebraining on Sunday August 26, 2012 @08:03AM
(#4434928)
Why would you need a recursive function? It's just a matter of decomposing your functions into smaller parts.
Re:Top Surprises When Starting Out as a Software Developer
by damncabbage on Sunday August 26, 2012 @08:21AM
(#4434947)
I think trekkin was being snarky about people preaching Functional techniques. (I don't think said snark was warranted, for the record.)
Re:Top Surprises When Starting Out as a Software Developer
by trekkin on Sunday August 26, 2012 @08:27AM
(#4434956)
:)
I'm not against functional languages/approaches. I just think that everything has its place, and that procedural code and nested if/then/elses are appropriate in many circumstances.
Re:Top Surprises When Starting Out as a Software Developer
by icebraining on Sunday August 26, 2012 @12:45PM
(#4435450)
When exactly are four levels or more of nesting appropriate? This has nothing to do with functional programming, it's a matter of readability. I mean, Linux is a completely procedural codebase (with some manual OO), but even its style guide says
If you need more than 3 levels of indentation, you're screwed anyway,
and should fix your program.
Re:Top Surprises When Starting Out as a Software Developer
by lttlrck on Sunday August 26, 2012 @01:43PM
(#4435631)
Why four, or three. Why not one or five... what a silly question/statement. It's completely subjective and as far as "a matter of readability" it's far far from the worst offense.
Re:Top Surprises When Starting Out as a Software Developer
by icebraining on Sunday August 26, 2012 @05:25PM
(#4436267)
It's not completely subjective. McConnell in Code Complete mentions studies by Chomsky and others that suggest that few people can understand more than three levels of nested ifs.
As for being far from the wort offense, well, I try to set my goals a little higher than "not the worst".
Re:Top Surprises When Starting Out as a Software Developer
by mquander on Sunday August 26, 2012 @08:08PM
(#4436759)
No, it's not that far from the worst offense. The hardest code I have ever had to read has always been code with ten+ levels of nesting in a big function, where I had to keep a big mental stack of what was necessarily true to be in the branch I was looking at. There is no situation on Earth where four levels of nesting couldn't be broken up into something more understandable; the only reason not to might be for the purposes of microoptimization.
As far as I know, the only worse offenses to readability are jumps or formatting your program like an IOCCC entry.
Do you actually disagree, or are you just going on? If the former, then please give an example of the right "circumstances."
Re:Top Surprises When Starting Out as a Software Developer
by tzaman on Sunday August 26, 2012 @10:49AM
(#4435205)
I would suggest you see some of Uncle Bob's talks/videos (starting with http://www.cleancoders.com/)