How To Write Unmaintainable Code (The code won't understand except You & Compiler)


Save Your Job, Nothing Wrong in this !!!! 

Learn to properly Misuse your talent.
The longer it takes for a bug to surface, the harder it is to find, even hardest to resolve.

Doctors are also known for bad writing. For a competitive programmer, in the same way, his typing is his handwriting. The more brilliant the coder(in terms of speed), the less crappier the code.


Following tricks will help you to write code in such a way that, It will be very difficult to understand your code to others. The aim of this article is, make your code complex to read and understand So, It will be very hard to maintain others. 


Variable Naming:-   Variable naming should be in tricky way.

1) Naming of function and variables.  "choose it to mean - neither more nor less."
use A.C.R.O.N.Y.M.S. and be Abstract. Do not use regular words like add,print. Find there synonyms in dictionary(google it) and use it.

2) Reuse Names of variables. Try to keep variable names same for global and local.
The goal is to force the maintenance programmer to carefully examine the scope of every instance.

3) Mix Languages Randomly intersperse two languages (human or computer).
e.g. replace "co-process" by "siblings"

5) In loops do not use variable names "i" and ''n'.
C'mon, from college time we know i is for start and n is stop.

6) Lower Case l Looks a Lot Like the Digit 1.
e.g.
int sum1;   ==> its sum1(ONE)
int suml ;   ==> its suml(L)

7) Long Similar Variable Names:
e.g.
doCalculationForData1()
doCalculationForData()

8) Similar-Sounding Similar-Looking Variable Names.
 xy_Z, xy__z, _xy_z, _xyz, XY_Z, xY_z, and Xy_z

Function Writing:

9)  Write code in Small Small functions and make call to these functions from  each other.
So, no One can understand your code in one shot. He has to go through every line.

10) use function Overloading:

void addnums(int a, int b);
void addnums(int a,int b,int c)

11) Make sure that every method does a little bit more (or less) than its name suggest.

12) do complex operation in return or call  another function in return.
e.g. below is my java code to find max from three nums

int  find(int a, int b,int c){
return  (a > b) && (a > c)? a:((b > a) && (b > c)? b:(c > a) && (c > b)? c:0 ) ;
}
}

int findMax(int a,int b,int c ){
return find(a,b,c);
}

13) call function in if condition:

if(isValid()){
// statements
}

boolean isValid(){
// statements
return true; // write complex return function
}

14) Java specific example:
String color = "green";
if  ( color!=null && color.equals("red") ) {
 System.out.println("yes");
}

Replace Above if block like: (no need to check for null)

if  ( "red".equals(color) ) {
  System.out.println("yes");
}

Few points are taken from Reference 1, remainings from my own experience.