creative & complex vs simple and readable
- by Shirish11
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.