1. Java / Говнокод #1787

    +75.3

    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
    public static ru.project.subpackage.PersonDTO convertOshPersonDtoToPersonDto(OshPersonDTO person){
            ru.project.subpackage.PersonDTO dto = new ru.project.subpackage.PersonDTO();
            dto.setPersonid(person.getPersonid().longValue());
            dto.setNamelast(person.getNamelast());
            dto.setNamefirst            (person.getNamefirst            ());
            dto.setNamesec              (person.getNamesec              ());
            dto.setInitials             (person.getInitials             ());
            dto.setSex                  (convertSkVocValue(person.getSex()));
            dto.setReason               (person.getReason               ());
            dto.setWorkphone            (person.getWorkphone            ());
            dto.setWorkphonedigit       (person.getWorkphonedigit       ());
            dto.setLocalphone           (person.getLocalphone           ());
            dto.setLocalphonedigit      (person.getLocalphonedigit      ());
            dto.setHomephone            (person.getHomephone            ());
            dto.setHomephonedigit       (person.getHomephonedigit       ());
            dto.setMobilephone          (person.getMobilephone          ());
            dto.setMobilephonedigit     (person.getMobilephonedigit     ());
            dto.setFax                  (person.getFax                  ());
            dto.setFaxdigit             (person.getFaxdigit             ());
            dto.setPager                (person.getPager                ());
            dto.setEmail                (person.getEmail                ());
            dto.setWeb                  (person.getWeb                  ());
            dto.setNamelastdative       (person.getNamelastdative       ());
            dto.setNamefirstdative      (person.getNamefirstdative      ());
            dto.setNamesecdative        (person.getNamesecdative        ());
            dto.setNamelastaccusative   (person.getNamelastaccusative   ());
            dto.setNamefirstaccusative  (person.getNamefirstaccusative  ());
            dto.setNamesecaccusative    (person.getNamesecaccusative    ());
            dto.setNamelastgenitive     (person.getNamelastgenitive     ());
            dto.setNamefirstgenitive    (person.getNamefirstgenitive    ());
            dto.setNamesecgenitive      (person.getNamesecgenitive      ());
            dto.setNamelastinstrumental (person.getNamelastinstrumental ());
            dto.setNamefirstinstrumental(person.getNamefirstinstrumental());
            dto.setNamesecinstrumental  (person.getNamesecinstrumental  ());
            dto.setNamelastprepositional(person.getNamelastprepositional());
            dto.setNamefirstprepositional(person.getNamefirstprepositional());
            dto.setNamesecprepositional (person.getNamesecprepositional ());
            return dto;
        }

    И так далее еще несколько сотен строк. А главное переупаковка из одних объектов в другие и обратно бессмысленна, т.к. можно использовать исходные (они доступны в приложении)

    johnsoft, 07 Сентября 2009

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

    +82.7

    1. 1
    2. 2
    3. 3
    4. 4
    public static boolean isUnix()
        {
            return System.getProperty("file.separator").equals("/");
        }

    johnsoft, 07 Сентября 2009

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

    +71.3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    /**
         * Возбуждает IllegalArgumentException если аргумент null.
         * Формирует сообщение об ошибке с именем условия.
         *
         * @param argument     проверяемый аргумент
         * @param argumentName имя аргумента
         */
        public static void ensureNotNull(Object argument, String argumentName) {
            if (argument == null) {
                throw new IllegalArgumentException("Null '" + argumentName + "' not allowed.");
            }
        }

    johnsoft, 07 Сентября 2009

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

    +83.9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    /**
         * проебразует объект <code>o</code> в объект
         *
         * @param o объект
         * @return объект со значением <code>o</code>
         */
        public static Object toObject(Object o) {
            return o;
        }

    Полное отсутствие знаний основ java

    johnsoft, 07 Сентября 2009

    Комментарии (18)
  5. PHP / Говнокод #1783

    +190.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
    // register.php
    
    // ...
    
    $login = $_POST["login"];
       
    // some checks...
       
    $sql = "CREATE TABLE `$login` (
            `city` TINYINT UNSIGNED NOT NULL ,
            // other fields here...
            );";

    Из модуля регистрации в системе удаленного ввода данных через web. После сохранения информации о новом пользователе для него создается новая таблица для хранения вводимых данных...

    Больше слов нет...

    Andrey_Beletsky, 07 Сентября 2009

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

    +127

    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
    /// <summary>
        ///  Retrieve currency rates from an external site to be sure they are up to date.
        /// In this case just checking the one currency (Australian Dollar) so no need to dynamically parse the site.
        /// </summary>
        /// <returns>currency rates or msg indicating an error</returns>
        private String getCurrencyRates()
        {
            string strURL = @"http://www.x-rates.com/d/JPY/table.html";
            HttpWebRequest txtRequest = (HttpWebRequest)WebRequest.Create(strURL);
    
            txtRequest.Method = "GET";
            txtRequest.ContentType = "application/x-www-form-urlencoded";
            string response;
            using (StreamReader streamReader = new StreamReader(txtRequest.GetResponse().GetResponseStream()))
            {
                response = streamReader.ReadToEnd();
                if (response.IndexOf("Australian Dollar") > 0)
                {
                    //parse the returned page for the two values of the currency rate based on the existing design
                    int ind_jpy = (response.IndexOf("/d/AUD/JPY/graph120.html") + 39);
                    int ind_aud = (response.IndexOf("/d/JPY/AUD/graph120.html") + 39);
                    String jpy_aud = response.Substring(ind_jpy, (response.IndexOf("</a>",ind_jpy) - ind_jpy) );
                    String aud_jpy = response.Substring(ind_aud, (response.IndexOf("</a>", ind_aud) - ind_aud));
                    Session["curr_rate"] = "set";
                    Session["JPY"] = jpy_aud;
                    Session["AUD"] = aud_jpy;
                    return aud_jpy + " / " + jpy_aud;
                }
                //else present msg to user that unable to obtain currency rates
            }
            return "";
        }

    Еще один кандидат

    OlgaWolga, 07 Сентября 2009

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

    +135.2

    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
    public string GetDollarKurs(string input)
    {
        string dol = "[.\\s]*<img height=\"11\" alt=\"Доллар США\" hspace=\"2\" src=\"/images/icon_dollar.gif\" width=\"11\" align=\"left\" vspace=\"2\" border=\"0\">Доллар \r\n\t\t\tСША</td>\r\n\t\t<td></td>\r\n\t\t<td class=\"digit\" align=\"right\">[\\s]*\\d+\\,\\d+[.\\s]*";
        MatchCollection Matches = Regex.Matches(input, dol);
        if (Matches.Count == 1)
        {
            string res = Matches[0].Value;
            res = res.Trim();
            res = res.Substring(res.LastIndexOf('>') + 1);
            return res;
        }
        else
            return "";
    }

    Функция для получения курса доллара, в input подаётся хтмл главной страницы сайта cbr.ru и парсится.
    А web-сервисы пусть кто-нибудь другой изучает... :o)

    Ordos, 06 Сентября 2009

    Комментарии (18)
  8. JavaScript / Говнокод #1780

    +149.8

    1. 1
    2. 2
    3. 3
    4. 4
    //простите меня за эти строки, но просто альтернативный метод swapNode (нативный только в IE)
    //удаляет оригинальный нод и его приходится заново по id искать :(
    document.getElementById(element['drag'].id).style.border = "2px solid gray";
    document.getElementById(element['acce'].id).style.border = "2px solid gray";

    :))))
    каммент жжот

    мой старый JS-быдлокод

    danilissimus, 06 Сентября 2009

    Комментарии (11)
  9. PHP / Говнокод #1779

    +158.5

    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
    $query = mysql_query("SELECT w_id,title FROM bhost_weblogs
                                         WHERE owner='".$user_info['username']."'");
    while($blog = mysql_fetch_assoc($query))
    {
        $stat = mysql_query("SELECT * FROM stat WHERE blog='".$blog['w_id']."' AND user!='' AND
                                          datestamp>='$d2' ORDER BY datestamp DESC");
        $all_users = mysql_result(mysql_query("SELECT Count(blog) FROM stat
                                           WHERE blog='".$blog['w_id']."' AND datestamp>='$d2'"),0);
        $reg_users = mysql_result(mysql_query("SELECT Count(blog) FROM stat
                                           WHERE blog='".$blog['w_id']."' AND user!='' AND datestamp>='$d2'"),0);
         $unreg_users = mysql_result(mysql_query("SELECT Count(blog) FROM stat
                                            WHERE blog='".$blog['w_id']."' AND user='' AND datestamp>='$d2'"),0);
    
         echo "<center>Всего: $all_users<br />
         Зарегистрированных пользователей: $reg_users<br />
         Незарегистрированных пользователей: $unreg_users</center>";
    
         echo "<table  cellpadding='0' cellspacing='0' align='center' class='form'>";
         while($statd = mysql_fetch_assoc($stat))
         {
         echo ...;
         }
         echo "</table><br /><br />";
    }

    Очень правильная работа с базой, подумаешь пара лишних запросов.

    BabyWolf, 06 Сентября 2009

    Комментарии (5)
  10. Куча / Говнокод #1778

    +140.4

    1. 1
    2. 2
    3. 3
    4. 4
    Почему нет раздела по BrainFuck'у? )))
    Почему нет раздела по BrainFuck'у? )))
    Почему нет раздела по BrainFuck'у? )))
    Почему нет раздела по BrainFuck'у? )))

    Почему нет раздела по BrainFuck'у? )))

    Tanger, 06 Сентября 2009

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