From: Roedy Green on
On Wed, 14 Jul 2010 11:16:45 -0700 (PDT), Sanny
<softtanks22(a)hotmail.com> wrote, quoted or indirectly quoted someone
who said :

>
> if (Str.charAt(50)!='-') xx+=bit;bit++;
> if (Str.charAt(49)!='-') xx+=bit;bit++;

This code does not make sense. Why would you want the sum of the bit
numbers that contained a -? I could see xx++ to count the number of -
chars.

Very rarely do you manually unravel loops now adays. We leave it up
to optimisers which loops to unravel.

That is confusing code. A novice might read it as
if (Str.charAt(50)!='-') {xx+=bit;bit++;}
Visual form should reflect logic. This is a form of obfuscated code.
--
Roedy Green Canadian Mind Products
http://mindprod.com

You encapsulate not just to save typing, but more importantly, to make it easy and safe to change the code later, since you then need change the logic in only one place. Without it, you might fail to change the logic in all the places it occurs.