And more!

30 January 2014 Leave a comment
if(canBeMultiplied && renewalOfferMultiplier > 0)
    discount = discount * renewalOfferMultiplier;
    discount = discount;
Categories: WTF

Even more WTF

29 January 2014 2 comments

And I thought that I had seen everything. But I hadn’t yet seen a wrapper to a String!!

public class OneVariableGenericVO implements

  private String varName;

  public OneVariableGenericVO()

  public OneVariableGenericVO(String varName)

  public String getVarName()
  	return this.varName;

  public void setVarName(String varName)
  	this.varName = varName;


SO instead of using a String someone had the brilliant idea to wrap a String into an object and use this instead. What can I say? I am speechless.

Categories: WTF

java.lang.ArrayIndexOutOfBoundsException with EmbeddedLDAP

11 December 2013 1 comment

If you forcefully stop the Weblogic Admin Server you might end up with corrupted LDAP files, and your admin server won’t start up with the following exception

####<Dec 7, 2013 2:45:18 AM BST> <Critical> EmbeddedLDAP <AdminServer> <VDE Replication Thread> <<anonymous>> <> <BEA-000000> <java.lang.ArrayIndexOutOfBoundsException
     at com.octetstring.vde.EntryChanges.readBytes(
     at com.octetstring.vde.EntryChanges.<init>(
     at com.octetstring.vde.replication.BackendChangeLog.getChange(

Before you do anything make sure that you have a copy or you know all the groups and users you have created in your domain.

The solution on Weblogic 7.x was to delete the EmbeddedLDAP.tran file. But with later Weblogic versions this might not work. Another solution is to backup and delete the servers/<admin server>/data/ldap folder. If this still does not work then backup and delete the servers/<admin server>/data folder. This will fix it but once the Admin server is up and running make sure that all the groups and users are still there. If not you will have to recreate all of them manually from the console.

Categories: WebLogic

More WTF!

15 November 2013 Leave a comment
if (true)
    if (externalCreditDeposit == 0)
        creditDeposit = internalCreditDeposit;
        creditDeposit = intWeight * internalCreditDeposit + extWeight * externalCreditDeposit;

Just to make sure that it will always be executed!

// Variable declaration
        String oldMsisdn = "";
        String newMsisdn = "";
        int rows = 0;
        int cols = 0;
        int tmp = 0;
        int listPtr = 0;

Just to make sure that we know there are variable declarations!

if (request.getParameter("hasBlackberyFromTor")!=null && request.getParameter("hasBlackberyFromTor").equals("1")) {
         blackberryExtraPlus  = "-22";

Unnecessary empty if statement.

Categories: Java, WTF

Not tested yet! (WTF)

5 November 2013 1 comment

This is some production code, that fails.

// Do conjunction////NOT TESTED YET???I dont know what will happen : (
startConjunction(customers, application);

Not sure if the author forgot the comment there or it indeed is not tested. But knowing that the code might not work and not fixing it is really WTF!

Categories: Java, WTF

WTF code!

7 October 2013 1 comment

While I was looking at some legacy code I stumbled upon a few wtf! moments. This is code that surprised me and made me laugh. Not that I haven’t written bad code in my life, but this is hilarious.

setPMPLogHistory(new Integer(applicationId).toString());

In the code above, the variable applicationId is already a String! The developer first creates a new Integer instance from a String and then turns this into a String again!


Apart from the obvious refactoring (the “1” should be at the beginning of the comparison in order to avoid a npe) you don’t have upper/lower case digits, so the equalsIgnoreCase is unnecessary.

Categories: Java, WTF

There Will Be Code

30 September 2013 Leave a comment

“One might argue that a book about code is somehow behind the times—that code is no
longer the issue; that we should be concerned about models and requirements instead.
Indeed some have suggested that we are close to the end of code. That soon all code will
be generated instead of written. That programmers simply won’t be needed because business people will generate programs from specifications.

Nonsense! We will never be rid of code, because code represents the details of the
requirements. At some level those details cannot be ignored or abstracted; they have to be
specified. And specifying requirements in such detail that a machine can execute them is
programming. Such a specification is code.

I expect that the level of abstraction of our languages will continue to increase. I
also expect that the number of domain-specific languages will continue to grow. This
will be a good thing. But it will not eliminate code. Indeed, all the specifications written
in these higher level and domain-specific language will be code! It will still need to
be rigorous, accurate, and so formal and detailed that a machine can understand and
execute it.

The folks who think that code will one day disappear are like mathematicians who
hope one day to discover a mathematics that does not have to be formal. They are hoping
that one day we will discover a way to create machines that can do what we want rather
than what we say. These machines will have to be able to understand us so well that they
can translate vaguely specified needs into perfectly executing programs that precisely meet
those needs.

This will never happen. Not even humans, with all their intuition and creativity,
have been able to create successful systems from the vague feelings of their customers.
Indeed, if the discipline of requirements specification has taught us anything, it is that
well-specified requirements are as formal as code and can act as executable tests of that

Remember that code is really the language in which we ultimately express the requirements.
We may create languages that are closer to the requirements. We may create tools
that help us parse and assemble those requirements into formal structures. But we will
never eliminate necessary precision—so there will always be code.”

Robert C. Martin – Clean Code. A Handbook of Agile Software Craftmanship.

Well said Robert. This summarises, in a few paragraphs, how important code is in our every day activities.

Categories: Books, Java Tags: ,