What are the parameters that prove Obfuscated code is better than simple code in java.

246 views Asked by At

I have two programs of java mobile agents. these programs are simple and obfuscated java mobile agents.

**Program 1**
package myfirst;
import com.ibm.aglet.*;
public class MyAglet extends Aglet
{
   public void run()
    {
    int a=1;
         System.out.println("Hello this is the first important part of the program \n");      
         System.out.println("Hello this is the second important part of the program \n");
    }
}

Program 2

package myfirst;
import com.ibm.aglet.*;
public class MyAglet1 extends Aglet
{
   public void run()
    {
    int a=1;
     System.out.println("Hello this is the first important part of the program \n");
        if(a>0)
     System.out.println("Hello this is the second important part of the program \n");      
    else
         {abc();
          System.out.println("Hello this is the second important part of the program \n");
      }
    }
public static void abc()
{
  int x=12,y=123,z=32;
   x=y;
   y=z;
   z=x;
    System.out.println("The part to be printed is "+x+y+z);
}
}

Now what are the factors which can be used to evaluate that obfuscated code is better than normal code .

1

There are 1 answers

1
Elliott Frisch On

I challenge your assertion that obfuscated code is better than simple code. In fact, you should try and write dumb code.

In addition to being easier to maintain, enhance and test simple code is often faster. Because of the dynamic nature of JVM hosted languages, the JIT, the optimizing compiler, and even modern CPU design (branch stalls, cache locality, and out-of-order execution) it is not trivial to optimize for speed.

Even the venerable XFree86 saw performance improvements by removing Duff's Device optimizations. That's real world, obfuscated and lower level then Java and "dumb" code was still better.