1. Лучший говнокод

    В номинации:
    За время:
  2. Java / Говнокод #16718

    +76

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    function returnUserId() {
        if (document.getElementById('userstap') != null )  {
            var obj = document.getElementById('userstap');
            <% if ((sUserIdForPrint != null) && !sUserIdForPrint.equals("")) {%>
            if (obj.options[obj.selectedIndex].value == 0) {
                return "<%=sUserIdForPrint%>";
            <% } %>
            <% if (((sAccGrpUserIdForPrint != null) && !sAccGrpUserIdForPrint.equals("")) && ((sUserIdForPrint != null) && !sUserIdForPrint.equals(""))) {%>
            } else if (obj.options[obj.selectedIndex].value == 1 ) {
                return "<%=sAccGrpUserIdForPrint%>";
            <% } else if ((sAccGrpUserIdForPrint != null) && !sAccGrpUserIdForPrint.equals("")){%>
            if (obj.options[obj.selectedIndex].value == 1 ) {
                return "<%=sAccGrpUserIdForPrint%>";
            <% } %>
            <% if (((sAccGrpUserIdForPrint != null) && !sAccGrpUserIdForPrint.equals("")) || ((sUserIdForPrint != null) && !sUserIdForPrint.equals(""))) {%>
            } else if (obj.options[obj.selectedIndex].value == 2) {
                return "<%=userId%>";
            }
            <% } else {%>
            if (obj.options[obj.selectedIndex].value == 2) {
                return "<%=userId%>";
            }
            <% } %>
        } else {
            return "<%=userId%>";
        }
    }

    Любите ли вы JSP так, как люблю его я?

    codingHorror, 18 Сентября 2014

    Комментарии (14)
  3. Java / Говнокод #16590

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    private Boolean active = false;
    ...
    synchronized (active) {
    ...
    }

    Чудо синхронизации. Блокируется раз и навсегда.

    borka, 25 Августа 2014

    Комментарии (16)
  4. Java / Говнокод #16363

    +76

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    private void setLock(boolean lock) {
            if (lock) {
                view1.setEnabled(false);
                view2.setEnabled(false);
                view3.setEnabled(false);
                view4.setEnabled(false);
                view5.setEnabled(false);
                view6.setEnabled(false);
            } else {
                view1.setEnabled(true);
                view2.setEnabled(true);
                view3.setEnabled(true);
                view4.setEnabled(true);
                view5.setEnabled(true);
                view6.setEnabled(true);
            }
        }

    Copy & Paste наше всё.
    P.S. Названия переменных изменены, не пугайтесь.

    ilsy, 17 Июля 2014

    Комментарии (15)
  5. Java / Говнокод #16275

    +76

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    String str = "";
               str  = str.concat(
                            ((code1.length() == 0 || code1.startsWith("00")) ? "77" : (code1.length() == 1) ? "0".concat(code1) : code1)
                    ).concat(
                            ((code2.length() == 0) ? "000" : (code2.length() == 1) ? "00".concat(code2) : (code2.length() == 2) ? "0" : code2
                    ).concat(
                            ((code3.length() == 0) ? "000" : (code3.length() == 1) ? "00".concat(code3) : (code3.length() == 2) ? "0".concat(code3) : code3)
                    ).concat(
                            ((code4.length() == 0) ? "000" : (code4.length() == 1) ? "00".concat(code4) : (code4.length() == 2) ? "0".concat(code4) :code4)
                    ).concat(
                            ((code5.length() == 0) ? "0000" : (code5.length() == 1) ? "000".concat(code5) : (code5.length() == 2) ? "00".concat(code5) : (code5.length() == 3) ? "0".concat(code5) : code5)
                    ).concat("00")
                );

    Форматирования 5 чисел по заданному шаблону. А если бы нужно было догнать до 100 нулей?)

    timmson666, 03 Июля 2014

    Комментарии (9)
  6. Java / Говнокод #16255

    +76

    1. 1
    return new Double(Math.ceil(weight)).intValue();

    И снова autoboxing не в почете

    kostoprav, 30 Июня 2014

    Комментарии (52)
  7. Java / Говнокод #16014

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    class Matrix {
        ArrayList<ArrayList<Double>> arrayList = new ArrayList<ArrayList<Double>>();
        ...
    }

    Вот такая у нас реализация sparsed-матриц.

    kostoprav, 19 Мая 2014

    Комментарии (3)
  8. C++ / Говнокод #14454

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    try {
        IntToStr(pageid);
    }
    catch (...) {
        pageid = 0;
    }

    А вдруг?

    bormand, 31 Января 2014

    Комментарии (30)
  9. Java / Говнокод #14446

    +76

    1. 1
    2. 2
    3. 3
    public static boolean isNodePresent(String nodeName, String tree, boolean waitForNotNullCondition) {
        return (waitForNotNullCondition) ? getTreeItemId(tree, nodeName) != null : getTreeItemId(tree, nodeName) == null;
    }

    Actine, 30 Января 2014

    Комментарии (9)
  10. Pascal / Говнокод #14368

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if mas[i-1,j-1]=true then begin neib[m]:=true; inc(m); end; //считаем соседей
    if mas[i-1,j]=true then begin neib[m]:=true; inc(m); end;
    if mas[i-1,j+1]=true then begin neib[m]:=true; inc(m); end;
    if mas[i,j-1]=true then begin neib[m]:=true; inc(m); end;
    if mas[i,j+1]=true then begin neib[m]:=true; inc(m); end;
    if mas[i+1,j-1]=true then begin neib[m]:=true; inc(m); end;
    if mas[i+1,j]=true then begin neib[m]:=true; inc(m); end;
    if mas[i+1,j+1]=true then begin neib[m]:=true; inc(m); end;

    Знакомый человек реализовывал «Жизнь» на делфях...

    POPSuL, 15 Января 2014

    Комментарии (75)
  11. Pascal / Говнокод #14168

    +76

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    SetCurrentDir(ExtractFileDir(Application.ExeName)); 
    try
    ADOConnection1.Connected:=true;
    if ADOConnection1.Connected=true then
    begin
      ADOTable1.Active:=True;
    end;
    except
      MessageDLG('Îøèáêà ïîäêëþ÷åíèÿ ÁÄ',mtError,[mbOk],0);
    end;

    SetCurrentDir(ExtractFileDir(Application .ExeName));
    Не знаю, откуда ты, но знаю, куда тебе дальше.

    Stertor, 03 Декабря 2013

    Комментарии (250)