1. C# / Говнокод #1210

    +134.2

    1. 1
    2. 2
    3. 3
    4. 4
    public void OnObjectException(EventArgs e, Exception ex)
    {
       throw ex;
    }

    Индусятина!

    guest, 16 Июня 2009

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

    +138.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
    [DataContract]
        public class MyDataContract {
            string lASTNAME = "";
            string nAMESUFFIX = "";
            string mIDDLENAME = "";
            string fIRSTNAME = "";
            [DataMember]
            public string LASTNAME {
                get { return lASTNAME; }
                set { lASTNAME = value; }
            }
            [DataMember]
            public string FIRSTNAME {
                get { return fIRSTNAME; }
                set { fIRSTNAME = value; }
            }
            [DataMember]
            public string MIDDLENAME {
                get { return mIDDLENAME; }
                set { mIDDLENAME = value; }
            }
            [DataMember]
            public string NAMESUFFIX {
                get { return nAMESUFFIX; }
                set { nAMESUFFIX = value; }
            }
        }

    Акуенная конвенция именования переменных

    guest, 16 Июня 2009

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

    +140

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    void f(bool b)
    {
      if(b.ToString().Length() == 4)
        ; // типа true
      else if(b.ToString().Length() == 5)
        ; // типа false
    }

    Сравнение

    guest, 09 Июня 2009

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

    +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
    try
    {
          GetRecentOrdersList();
    }
    catch (XmlFileHasWrongFormatException)
    {
          wrongClientSettingsXmlFormat = true;
    }
    if (wrongClientSettingsXmlFormat == true)
    {
          IList<RecentDocumentInfo> fakeList = new List<RecentDocumentInfo>();
          SetRecentOrdersList(fakeList);
          wrongClientSettingsXmlFormat = false;
    }

    Как правильно обрабатывать исключения

    guest, 07 Июня 2009

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

    +133.9

    1. 1
    2. 2
    3. 3
    4. 4
    void FF_MouseEnter(object sender, MouseEventArgs e)
    {
        itForSelected.IsSelected = !new bool();
    }

    ппц)

    guest, 03 Июня 2009

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

    +145.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
    try
    			{	
    				if (SQL_SUCCESS == SQLAllocHandle(SQL_HANDLE_ENV, m_environmentHandle, out m_environmentHandle))
    				{
    					if (SQL_SUCCESS == SQLSetEnvAttr(m_environmentHandle,SQL_ATTR_ODBC_VERSION,(IntPtr)SQL_OV_ODBC3,0))
    					{
    						if (SQL_SUCCESS == SQLAllocHandle(SQL_HANDLE_DBC, m_environmentHandle, out m_connectionHandle))
    						{
    							if (SQL_NEED_DATA == SQLBrowseConnect(m_connectionHandle, inConnection, stringLength, outConnection, DEFAULT_RESULT_SIZE, out stringLength2Ptr))
    							{
    								if (SQL_NEED_DATA != SQLBrowseConnect(m_connectionHandle, inConnection, stringLength, outConnection, DEFAULT_RESULT_SIZE, out stringLength2Ptr))
    								{
    									throw new ApplicationException("No Data Returned.");
    								}
    							}
    						}	
    					}
    				}
    			}
    						
    			catch (Exception ex)
    			{			
    				throw new ApplicationException("Cannot Locate SQL Server.");
    			}

    Увидел на codeguru. Аффтар импортирует функции WinAPI для работы с SQL в C#. Работа с исключениями также доставляет.

    guest, 03 Июня 2009

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

    +145.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
    public void newMessageTrySafe(Message message)
    {
        if (SeparateThread.Wait(100, 5, new ExitWaitDelegate(this.)))
        {
            try
            {
                this.newMessage(message);
            }
            catch (Exception exception)
            {
                Utils.log("DataCache.newMessage() error: " + exception.Message, new object[0]);
            }
            try
            {
                Monitor.Exit(this.FRecalcSynchronizer);
                return;
            }
            catch (SynchronizationLockException)
            {
                return;
            }
        }
        Utils.log("newMessageTrySafe(): Deadlock! Unable to call newMessage bacause it's locked by this thread", new object[0]);
    }

    Решение проблемы дедлоков в многопоточной программе.

    guest, 29 Мая 2009

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

    +134.6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    private bool _isProcessingThreadExited = false;
    
    public bool IsShutDownComplete() 
    {
       if (!_isProcessingThreadExited) 
       {
           // a thread hasnt exited yet
           return false;
       }
    
       return true;
    }

    ... осталось еще bool на true проверить через ToString().Length > 4 - и это будет верх говнокодерства...

    guest, 27 Мая 2009

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

    +128.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
    15. 15
    public static string ValidateEmail(string Email)
            {
                try
                {
                    if (Email.Trim() == string.Empty)
                    {
                        return "Empty Parameter - Email";
                    }
                }
                catch
                {
                    return "Empty Parameter - Email";
                }
                return null;
            }

    guest, 26 Мая 2009

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

    +143.7

    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
    /*Hide deleted button*/
       if (((UF.FileTypeID == FP.FileType1) && (FP.FileType1Edit == 1))
     || ((UF.FileTypeID == FP.FileType2) && (FP.FileType2Edit == 1))
     || ((UF.FileTypeID == FP.FileType3) && (FP.FileType3Edit == 1))
     || ((UF.FileTypeID == FP.FileType4) && (FP.FileType4Edit == 1))
     || ((UF.FileTypeID == FP.FileType5) && (FP.FileType5Edit == 1))
     || ((UF.FileTypeID == FP.FileType6) && (FP.FileType6Edit == 1)) 
    || ((UF.FileTypeID == FP.FileType7) && (FP.FileType7Edit == 1)) 
    || ((UF.FileTypeID == FP.FileType8) && (FP.FileType8Edit == 1)) 
    || ((UF.FileTypeID == FP.FileType9) && (FP.FileType9Edit == 1)) 
    || ((UF.FileTypeID == FP.FileType10) && (FP.FileType10Edit == 1))
     || ((UF.FileTypeID == FP.FileType11) && (FP.FileType11Edit == 1)))
       {
                 if (CBL.GetListOfButtons(CPF.ID, 1) == true)
                                {
                                            bool ButtonVisible = true;
                                            String BText = "";
                                            foreach (ConfirmButtons CB in CBL.Items)
                                            {
                                                BText = "";
                                                if ((CB.ActionID > 0)&&(aAction.GetActionInfo(CB.ActionID) == true))
                                                {
                                                    if (DTS.isStepAllowed(CB.ActionID, sysUser.GetID(), UserRoleID, aRequest.ID) == true)
                                                    {
                                                        ButtonVisible = true;
                                                        #region Exeptions
                                                        if (CB.TypeName == "Confirm")
                                                        {
                                                            /*----------Check parallel process status--------------*/
                                                            if (aRequest.IsParent == 1)
                                                            {
                                                                if (CheckBP.CheckParallelBP(aRequest.ID, aRequest.aReqStatus.ID) == true)
                                                                {
                                                                    if ((CheckBP.IsNecessary == 1) || ((CheckBP.ChildID > 0) && (CheckBP.ChildCurState > 0)))
                                                                    {
                                                                        if (((CheckBP.IsNecessary == 1) && ((CheckBP.ChildID == 0))) || ((CheckBP.PositiveEndState != CheckBP.ChildCurState) && (CheckBP.NegativeEndState != CheckBP.ChildCurState)))
                                                                        {
                                                                            ButtonVisible = false;
                                                                            CFTitleText.Text = "В данный момент вы не можете cогласовать заявку. Незавершен параллельный процесс: '" + CheckBP.Name.ToString() + "'!";
                                                                        }
                                                                    }
                                                                }
                                                            }

    Кусок, начиная со строки 881(из 1307) метода Page_Load. Мастурбация мозга..

    guest, 20 Мая 2009

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