Saturday 23 February 2013

The hourly WTF?

Ok so a bit of "cut and paste" code-re-use is one thing, but I think we have a grand-prize-medal winner here ...

public void updateEquipment() {
    try {
        String strResult = "" + (char) 7;
        try {
            strResult += equWorn.wield.name + "\n";
        } catch (Exception e) {
            strResult += "none\n";
        }
        try {
            strResult += equWorn.arms.name + "\n";
        } catch (Exception e) {
            strResult += "none\n";
        }
        try {
            strResult += equWorn.legs.name + "\n";
        } catch (Exception e) {
            strResult += "none\n";
        }
        try {
            strResult += equWorn.torso.name + "\n";
        } catch (Exception e) {
            strResult += "none\n";
        }
        ... repeats a few more times ...

I'm not having a go at the original author - I think it was written a long time ago when he was inexperienced, but it's pretty funny nonetheless.

No comments: