creative & complex vs simple and readable

Posted by Shirish11 on Programmers See other posts from Programmers or by Shirish11
Published on 2012-03-29T10:52:50Z Indexed on 2012/03/29 11:41 UTC
Read the original article Hit count: 247

Filed under:

Which is a better option?
Its not always that when you have something creative your code is going to look ugly.
But at times it does go a bit ugly.
e.g.

if ( (object1(0)==object2(0) && (object1(1)==object2(1) && (object1(2)==object2(2) && (object1(3)==object2(3)){
    retval = true;
else
    retval = false;

is simple and readable

bool retValue = (object1(0)==object2(0)) && 
                (object1(1)==object2(1)) && 
                (object1(2)==object2(2)) && 
                (object1(3)==object2(3));

but having something like this will make some newbies scratch their heads.

So what do I go for? including simple code everywhere might sometime hamper my performance.
what I could think of was commenting wherever necessary but at times u get too curious to know what is actually happening.

Any suggestions are welcome.

© Programmers or respective owner

Related posts about coding-style