Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I know this is a dumb question, but, how should it be formatted? I mean, I would rather that than a bunch of booleans that eventually go off screen
-
xorith27467y@SpencerBeige Well technically this would have indentation.
To answer your question though, any code that starts to look like this is probably a candidate for refactoring. There's probably far too many concerns being addressed and they should probably be broken out into their own logic.
Next, whenever I see code like this I often see where a number of conditionals could be checked at the same time and provide an early out for the code.
Lastly, and the real punch-line of my rant, is the "return result;" and the fact that it's an integer. The idea of an integer result that has meaning isn't new and has a place, but it's on the programmer to keep things readable. I've seen 100+ line functions that operate like this where result is set to a value because a condition was met half way through the block. When debugging and I want to know why 'someFunc' returned 20 and not 0, I now have to dig through a ton of code.
That was the point of the rant. :)
Related Rants
int someFunc()
{
int result = -1;
// imagine all the fucking ifs in the world...
{
{
{
{
{
{
{
{
{
}
}
}
}
}
}
}
}
}
return result;
}
undefined
wk72