views:

367

answers:

6

What are some common practices you have seen used in the design by obfuscation crowd? I find it interesting to be on projects that are not allowed to be rewritten while, that would be the faster and most efficient solution to the problem.

+1  A: 

We had one person we worked with store files in a folder call /kensington in order to "hide" them. It just contained some xml files that he didnt want seen and figured people wouldn't look in there.

Brian
A: 

I worked with a programmer that used to write hugely complex conditions that when met would call a method that simply did a system out. He did this dozens of times throughout the entire app. Still not sure why....

northpole
Side effects, perhaps?
strager
+1  A: 

No or useless comments in the code along with no useful documentation.

Jared
That's not obfuscation, IMO.
strager
I think that depends on the code. I have seen times when adding comments is just clutter. But other times it would of been really nice to know what was going though the devs mind.
Matthew Whited
That is often a problem, when code is changed and the comments no longer match what the code does. makes it hard for the next reader to figure out if the code is wrong or the comments. Better have no comments than wrong comments.
blabla999
+3  A: 

My favorites always revolve around variables...leaving ones in the code that are no longer used, then giving them all meaningless names. Of course, you have to be careful to avoid nearly all convention if you really want to obfuscate. So, a perfect one would be to have two similarly used variables, one named myVar1, and another named myVarOne. Stuff like that...

Another one is to include un-used controls that are only visible within the code. I stared at one ASP.NET site for a good hour trying to figure out why a FormView was dropped into it..(there was no answer to that).

Gus
+2  A: 

I once worked on perl code where the author decided to have most of the subs receive a single hash as a variable and returned that same hash with data added or removed. Basically one global hash used to pass data through the different code paths.

It looked something like this:

my $hash = ();

$hash->{'CUSTID'} = 1001;
$hash = GetAccounts($hash);

if ($hash->{'AccountTotal'} > 100) {
    $hash = getTotals($hash);
    $hash->{'Acct_Sbkt_Marker'} = 'R1';
    $hash->{'Acct_Invr_Marker'} = 'BT';
    $hash = removeInvalidAccount($hash);
}

To this day I can't figure out what design pattern he was trying to implement with this.

I remember the $hash would be lined up nicely.

sal
A: 

And there I was thinking that well designed code should stand up on its own to be read, not deciphered.

I understand that people who care about obfuscation are encouraged to use tools like dotfuscator and its equivalents in other environments. Obfuscation in the sense of making the code harder to decompile though, not just making it a pain to work with.

Why anyone would deliberately design horrible code (except to demonstrate the gotchas) is beyond me.

IanGilham
I don't disagree. Accidental or on purpose "obfuscation by design" can be a real pain. And i am jsut trying to get a feel for other "designs" that people have encounted
Matthew Whited