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

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

    +68

    1. 1
    2. 2
    3. 3
    if (url == null) {
     throw new RuntimeException("Error reading resource " + url.getFile());
    }

    ха.
    туториалы jogl

    Lure Of Chaos, 11 Ноября 2010

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

    +68

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    def InvoicedExtra(JobExtra extra) {
       type = extra.type
       clientPrice = extra.price ?: ZERO
       vatPrice = (extra.type.vatBand?.band ?: 0) * extra.price / 100
       grossPrice = vatPrice ?: ZERO + clientPrice ?: ZERO
    }

    Мой код на Groovy. Обратите внимание на строку 5. Это типа хитрый способ суммирования который не бросает NullPointerException. Однако не учтены приоритеты операторов. Оцените красоту выстрела в ногу =)

    tinhol, 03 Июня 2010

    Комментарии (6)
  4. C++ / Говнокод #2041

    +68

    1. 1
    2. 2
    char *GetNumRenderedObjectsString() { char *mString = new char [128]; itoa (mNumRenderedObjects, mString, 10); return mString; };
    char *GetNumDiscardedObjectsString() { char *mString = new char [128]; itoa (mNumDiscardedObjects, mString, 10); return mString; };

    Отличная работа с памятью.

    benin, 25 Октября 2009

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

    +68

    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
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        PortletSettings other = (PortletSettings) obj;
        if (column == null) {
            if (other.column != null)
                    return false;
        } else if (!column.equals(other.column))
            return false;
        if (configurator == null) {
            if (other.configurator != null)
                return false;
        } else if (!configurator.equals(other.configurator))
            return false;
        if (library == null) {
            if (other.library != null)
                return false;
        } else if (!library.equals(other.library))
            return false;
        if (maximize != other.maximize)
            return false;
        if (portletId == null) {
            if (other.portletId != null)
                return false;
        } else if (!portletId.equals(other.portletId))
            return false;
        if (row != other.row)
            return false;
        return true;
    }

    yvu, 30 Сентября 2009

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

    +68

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    // right now. I can't find how to make fucking @DirectLink
    // to necessary book, therefore it'll be a cocksucking crutch.
    // from eveel, with love :)
    writer.attribute("href",
            "?component=%24DirectLink&page=Home&service=direct&session=T&sp=" +
                    i);

    Гоняем Tapestry «на посмотреть».

    Действительно, понять сходу каким образому внутри компонента использовать другой компонент (тот же DirectLink) у меня не получилось. Вообще, вопрос в силе.

    eveel, 30 Августа 2009

    Комментарии (0)
  7. C++ / Говнокод #2452

    +67.9

    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
    char blt=0;
    void WriteBit(bool bit)
    {
    	if(BitCount<9)
    	{
    		if(bit){blt|=(1<<BitCount);BitCount++;}
    		if(!bit){blt&=~(1<<BitCount);BitCount++;}	
    
    	}
    	else
    	{
    		out_file<<blt;
    		BitCount=0;
    		blt=0;
    	}
    }

    че-то типа запись в байт битов))

    fekrado, 19 Января 2010

    Комментарии (28)
  8. Куча / Говнокод #1704

    +67.9

    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
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    #!/bin/bash
    
    ln -s /tomcat/tc1/logs/CR.log /tomcat/logs/tc1.log
    ln -s /tomcat/tc2/logs/CR.log /tomcat/logs/tc2.log
    ln -s /tomcat/tc3/logs/CR.log /tomcat/logs/tc3.log
    ln -s /tomcat/tc4/logs/CR.log /tomcat/logs/tc4.log
    ln -s /tomcat/tc5/logs/CR.log /tomcat/logs/tc5.log
    ln -s /tomcat/tc6/logs/CR.log /tomcat/logs/tc6.log
    ln -s /tomcat/tc7/logs/CR.log /tomcat/logs/tc7.log
    ln -s /tomcat/tc8/logs/CR.log /tomcat/logs/tc8.log
    
    rm -fR /tomcat/webapps
    mv /tomcat/tc1/webapps /tomcat/webapps
    rm -fR /tomcat/tc1/webapps
    rm -fR /tomcat/tc2/webapps
    rm -fR /tomcat/tc3/webapps
    rm -fR /tomcat/tc4/webapps
    rm -fR /tomcat/tc5/webapps
    rm -fR /tomcat/tc6/webapps
    rm -fR /tomcat/tc7/webapps
    rm -fR /tomcat/tc8/webapps
    ln -s /tomcat/webapps /tomcat/tc1/webapps
    ln -s /tomcat/webapps /tomcat/tc2/webapps
    ln -s /tomcat/webapps /tomcat/tc3/webapps
    ln -s /tomcat/webapps /tomcat/tc4/webapps
    ln -s /tomcat/webapps /tomcat/tc5/webapps
    ln -s /tomcat/webapps /tomcat/tc6/webapps
    ln -s /tomcat/webapps /tomcat/tc7/webapps
    ln -s /tomcat/webapps /tomcat/tc8/webapps
    rm -fR /tomcat/tc2/conf/Catalina/localhost
    rm -fR /tomcat/tc3/conf/Catalina/localhost
    rm -fR /tomcat/tc4/conf/Catalina/localhost
    rm -fR /tomcat/tc5/conf/Catalina/localhost
    rm -fR /tomcat/tc6/conf/Catalina/localhost
    rm -fR /tomcat/tc7/conf/Catalina/localhost
    rm -fR /tomcat/tc8/conf/Catalina/localhost
    ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc2/conf/Catalina/localhost
    ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc3/conf/Catalina/localhost
    ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc4/conf/Catalina/localhost
    ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc5/conf/Catalina/localhost
    ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc6/conf/Catalina/localhost
    ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc7/conf/Catalina/localhost
    ln -s /tomcat/tc1/conf/Catalina/localhost /tomcat/tc8/conf/Catalina/localhost
    rm -fR /tomcat/tc2/lib
    rm -fR /tomcat/tc3/lib
    rm -fR /tomcat/tc4/lib
    rm -fR /tomcat/tc5/lib
    rm -fR /tomcat/tc6/lib
    rm -fR /tomcat/tc7/lib
    rm -fR /tomcat/tc8/lib
    ln -s /tomcat/tc1/lib /tomcat/tc2/lib
    ln -s /tomcat/tc1/lib /tomcat/tc3/lib
    ln -s /tomcat/tc1/lib /tomcat/tc4/lib
    ln -s /tomcat/tc1/lib /tomcat/tc5/lib
    ln -s /tomcat/tc1/lib /tomcat/tc6/lib
    ln -s /tomcat/tc1/lib /tomcat/tc7/lib
    ln -s /tomcat/tc1/lib /tomcat/tc8/lib
    rm -fR /tomcat/tc2/common
    rm -fR /tomcat/tc3/common
    rm -fR /tomcat/tc4/common
    rm -fR /tomcat/tc5/common
    rm -fR /tomcat/tc6/common
    rm -fR /tomcat/tc7/common
    rm -fR /tomcat/tc8/common
    ln -s /tomcat/tc1/common /tomcat/tc2/common
    ln -s /tomcat/tc1/common /tomcat/tc3/common
    ln -s /tomcat/tc1/common /tomcat/tc4/common
    ln -s /tomcat/tc1/common /tomcat/tc5/common
    ln -s /tomcat/tc1/common /tomcat/tc6/common
    ln -s /tomcat/tc1/common /tomcat/tc7/common
    ln -s /tomcat/tc1/common /tomcat/tc8/common

    yvu, 27 Августа 2009

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

    +67.7

    1. 1
    for(__=_;__<___;__++) C++;

    Недавно увидел такие имена переменных, очарован, теперь срочно переделываю весь проект!

    PS. Тело цикла сами знаете для кого.

    nil, 27 Января 2010

    Комментарии (38)
  10. Java / Говнокод #2916

    +67.4

    1. 1
    2. 2
    Apache POI
    The apache project has a library which called POI that can read and write the HSSF (Horrible Spread Sheet Format)

    Не говнокод, но официальное название формата доставляет :)

    zlob.jc, 02 Апреля 2010

    Комментарии (17)
  11. C++ / Говнокод #2357

    +67.4

    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
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    // die elemente aufbauen
    // wasserstoff (gruppe 1, Nichtmetalle)
    Element* wasserstoff = new Element(this);
    wasserstoff->setObjectName("wasserstoff");
    wasserstoff->setze_element_namen(tr("Hydrogen"));
    wasserstoff->setze_atomzahl(1);
    wasserstoff->setze_symbol("H");
    wasserstoff->setze_masse("1,00794 u");
    wasserstoff->setze_exakte_masse("1.007825032");
    wasserstoff->setze_ionisation("13,5984 kJ/mol");
    wasserstoff->setze_elektronenaffinitaet("1.007825032");
    wasserstoff->setze_elektronen_negativitaet("2,2");
    wasserstoff->setze_kovalenter("37 pm");
    wasserstoff->setze_van_der_waals_radius("120 pm");
    wasserstoff->setze_schmelzpunkt("13.81");
    wasserstoff->setze_siedepunkt("20.28");
    wasserstoff->setze_familie(tr("nonmetal"));
    wasserstoff->setze_gruppenfarbe(gruppenfarben.at(1));
    wasserstoff->setze_entdeckungsjahr(1766);
    wasserstoff->setze_position(0, 1);
    elementliste.insert(wasserstoff->atomzahl(), wasserstoff);
    wasserstoff->registriere_agrgatzustandsfarben(agregatzustandsfarben);
    wasserstoff->fuege_elektronen_hinzu(1, 1);
    
    // helium (gruppe 18, Edelgase)
    Element* helium = new Element(this);
    helium->setObjectName("helium");
    helium->setze_element_namen(tr("Helium"));
    helium->setze_atomzahl(2);
    helium->setze_symbol("He");
    helium->setze_masse("4,0026 u");
    helium->setze_exakte_masse("4.002603254");
    helium->setze_ionisation("24,5874 kJ/mol");
    helium->setze_elektronenaffinitaet("4.002603254");
    helium->setze_elektronen_negativitaet("-1");
    helium->setze_kovalenter("32 pm");
    helium->setze_van_der_waals_radius("140 pm");
    helium->setze_schmelzpunkt("0.95");
    helium->setze_siedepunkt("4.216");
    helium->setze_familie(tr("noble gases"));
    helium->setze_gruppenfarbe(gruppenfarben.at(18));
    helium->setze_entdeckungsjahr(1868);
    helium->setze_position(17, 1);
    elementliste.insert(helium->atomzahl(), helium);
    helium->fuege_elektronen_hinzu(1, 2);
    
    // lithium (gruppe 1, Alkalimetalle)
    Element* lithium = new Element(this);
    
    
    ...
    
    
    // ununhexium (gruppe 16, Metalle)
    Element* ununhexium = new Element(this);
    ununhexium->setObjectName("ununhexium");
    ununhexium->setze_element_namen(tr("Ununhexium"));
    ununhexium->setze_atomzahl(116);
    ununhexium->setze_symbol("Uuh");
    ununhexium->setze_masse("292 u");
    ununhexium->setze_exakte_masse("292.19979");
    ununhexium->setze_ionisation("-1");
    ununhexium->setze_elektronenaffinitaet("292.19979");
    ununhexium->setze_elektronen_negativitaet("-1");
    ununhexium->setze_kovalenter("-1");
    ununhexium->setze_van_der_waals_radius("-1");
    ununhexium->setze_schmelzpunkt(QString::number(INT_MAX));
    ununhexium->setze_siedepunkt(QString::number(INT_MAX));
    ununhexium->setze_familie(tr("other metal"));
    ununhexium->setze_gruppenfarbe(gruppenfarben.at(16));
    ununhexium->setze_entdeckungsjahr(2000);
    ununhexium->setze_position(15, 7);
    elementliste.insert(ununhexium->atomzahl(), ununhexium);
    ununhexium->fuege_elektronen_hinzu(1, 2);
    ununhexium->fuege_elektronen_hinzu(2, 8);
    ununhexium->fuege_elektronen_hinzu(3, 18);
    ununhexium->fuege_elektronen_hinzu(4, 32);
    ununhexium->fuege_elektronen_hinzu(5, 32);
    ununhexium->fuege_elektronen_hinzu(6, 18);
    ununhexium->fuege_elektronen_hinzu(7, 6);
    
    ЗЫ: итого порядка 3000 строк кода

    http://sourceforge.net/projects/qperiodictable

    3dEyes**, 31 Декабря 2009

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