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

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

    +122

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    var product=dataContext.Products.Where(p=>p.Name == "SomeProductName")
    
    if (products.Count() != 0)
                {
                    return new Product
                    {
                        ProductId = products.First().AM_PRODUCT_ID,
                        ProductName = products.First().PRODUCT_NAME,
                        IsActive = products.First().IS_ACTIVE
                    };
                }

    this way of selecting product from table by its name generate 4 queries instead 1 ...

    O_O, 28 Февраля 2011

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

    +122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    catch (TargetInvocationException ex) {
         try {
              throw ex.InnerException;
         }
         catch (EndpointNotFoundException innerEx) {
              factory.Abort();
              throw new InvalidOperationException("Service unreachable", innerEx);
         }
    }

    Обработчик исключений %)

    Guid, 16 Февраля 2011

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

    +122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    /// <summary>
    /// I hate you guys.
    /// You guys are assholes.
    /// Especially author of this class.
    /// I hate him the most.
    /// </summary>
    public partial class ProfileEditor

    Semargl, 11 Января 2011

    Комментарии (5)
  5. C# / Говнокод #5093

    +122

    1. 1
    2. 2
    3. 3
    int valu=...;
    ...
    string vals=""+valu;

    Говногость, 28 Декабря 2010

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

    +122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if (0 == comparer.Compare(s, hash)) 
    { 
        return true; 
    } 
    else 
    { 
        return false; 
    }

    MSDN. Не то чтобы ГК, но как-то странно.

    andrewpey, 11 Декабря 2010

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

    +122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public ActionResult View(string id)
    {
    	// some stupid code
    	return View("Picture");
    }

    Потратил больше часа, пытаясь разобраться, почему глючат роуты.

    andrewpey, 10 Декабря 2010

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

    +122

    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 enum SqlCallType {
    		Text = 1,
    		StoredProcedure = 2
    	}
    
    		private SqlCallType ConvertToSqlCallType(int sqlCallType) {
    			SqlCallType type = (SqlCallType)0;
    			if (sqlCallType == (int)SqlCallType.Text) {
    				type = SqlCallType.Text;
    			}
    			else if (sqlCallType == (int)SqlCallType.StoredProcedure) {
    				type = SqlCallType.StoredProcedure;
    			}
    			return type;

    приведение enum-->int по индусски для enum'а с двумя значениями....

    Unknown_2, 25 Ноября 2010

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

    +122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    Код из нового  курса  Е.Попова по JS и JQuery
    
    var name = "Иваh";
    for (var i = 0; i < name.length; i++) {
        if (name.charCodeAr(i) < 1040 || name.charCodeAt(i) > 1103 {
            document.write("Найден символ: " + name.charAt(i));
        }
    }

    Vasiliy, 28 Октября 2010

    Комментарии (18)
  10. C# / Говнокод #4455

    +122

    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
    public static bool IsConnectedToInternet
    {
        get
        {
            // сервер для пинга
            Uri url = new Uri("www.google.com"); 
            // его перевод в строку
            string pingurl = string.Format("{0}", url.Host); 
            string host = pingurl;
            // возвращаемое значение
            bool result = false; 
            Ping p = new Ping();
            try
            {
                PingReply reply = p.Send(host, 3000);
                if (reply.Status == IPStatus.Success)
                // если все ок, то вернем true                
                   return true;
            }
            catch { }
            // в этом случае возвращается false
            return result;
        }
    }

    Взято с http://msgeeks.ru/?artid=42 - "Пинг сервера на С#".
    Особенно порадовал перевод url.Host в строку))

    inso, 26 Октября 2010

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

    +122

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    List<String> el=parseList();
    		Theme th=new Theme(id);
    
    		th.setScore=Integer.parseInt(el.get(1));
    		th.setComments=Integer.parseInt(el.get(2));
    		th.setAuthor=el.get(3);
    		th.setVisitors=Integer.parseInt(el.get(4));
    		th.setVisitorsLastWeek=Integer.parseInt(el.get(5));
    		th.eMail=el.get(5);
    		return th;

    3.14159265, 12 Октября 2010

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