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

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

    +118

    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
    private String compileOwnerName() {
    		return Joiner.on(' ').skipNulls().
    		String firstName = ownerFirstName.getValue();
    		String lastName = ownerLastName.getValue();
    		
    		final StringBuilder buffer = new StringBuilder();
    		boolean first = true;
    		
    		if (firstName != null) {
    			firstName = firstName.trim();
    			
    			if (!"".equals(firstName)) {
    				buffer.append(firstName);
    				first = false;
    			}
    		}
    
    		if (lastName != null) {
    			lastName = lastName.trim();
    			
    			if (!"".equals(lastName)) {
    				if (!first) {
    					buffer.append(" ");
    				}
    				
    				buffer.append(lastName);
    			}
    		}
    		
    		return buffer.toString();
    	}

    В итоге заменено однострочником на Perl:

    return Joiner.on(' ').skipNulls().join(Strings.emptyToNull(ownerFirstName.getValue().trim()),
    ownerLastName.getValue().trim()));

    someone, 05 Июля 2012

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

    +118

    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
    for (int Low = 0, Up = 8; (Low <= 72) & (Up <= 80); Low += 12, Up += 12)
                                    if ((i >= Low) & (i <= Up))
                                    {
                                        a = 0;
                                        for (int l = 0; l <= 13 * 3; l += 13)
                                        {
                                            if (labels[i + l].Text == "X")
                                            {
                                                a += 1;
                                                if ((l == 13 * 3) & (a != 4)) a = 0;
                                            }
                                            else a = 0;
                                        }
                                        if (a == 4)
                                        {
                                            if ((i != 8) & (i != 72))
                                            {
                                                if ((i == Low) | ((i >= 0) & (i <= 7)))
                                                    if (labels[i + 13 * 4].Text == "-")
                                                    {
                                                        labels[i + 13 * 4].Text = "O";
                                                        win = true;
                                                        goto End2;
                                                    }
                                                if ((i == Up) | ((i >= 73) & (i <= 80)))
                                                    if (labels[i - 13].Text == "-")
                                                    {
                                                        labels[i - 13].Text = "O";
                                                        win = true;
                                                        goto End2;
                                                    }
                                                if (i == Low)
                                                    if (labels[i + 13 * 4].Text == "-")
                                                    {
                                                        labels[i + 13 * 4].Text = "O";
                                                        win = true;
                                                        goto End2;
                                                    }
                                                if (i == Up)
                                                    if (labels[i - 13].Text == "-")
                                                    {
                                                        labels[i - 13].Text = "O";
                                                        win = true;
                                                        goto End2;
                                                    }
                                                if (((i >= 0) & (i <= 7)) | ((i >= 73) & (i <= 80)) | (i == Low) | (i == Up)) ;
                                                else
                                                {
                                                    if (labels[i + 13 * 4].Text == "O")
                                                        if (labels[i - 13].Text == "-")
                                                        {
                                                            labels[i - 13].Text = "O";
                                                            win = true;
                                                            goto End2;
                                                        }

    Полная версия: http://pastebin.com/gZFjYrtM

    P4R4, 10 Апреля 2012

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

    +118

    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
    protected  override bool    GetGridDT           (out object Dt)
            {
                DataTable   vDt     =   null;
                bool        vResult =   fComposition != 0 ?
                                        Composition.RN.Load(fComposition, out vDt) :
                                        fNType != 0 ?
                                        RN.Load((RNType.RNTypes)fNType, out vDt) :
                                        fRvObjectType != 0 ?
                                        RvObjectType.RN.Load(fRvObjectType, out vDt) :
                                        fRv != 0 ?
                                        Rv.RN.Load(fRv, out vDt) :
                                        fProtocol != 0 ?
                                        Protocol.RN.Load(fProtocol, out vDt) :
                                        RN.Load(out vDt);
                            Dt      =   vDt;
                return      vResult;
            }

    Ну что тут скажешь...)

    gcoder, 30 Марта 2012

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

    +118

    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
    Params.Name                 =   GetControl(pnlName) ? edName.Text : "";                                    
    Params.DateMeasurement      =   TOperation.GetDateValue(edDateTime);            
    Params.HalfYear             =   pnlHalfYear.Tag                        != null &&      
                                                    pnlHalfYear.Tag                        is bool && 
                                                    (bool)pnlHalfYear.Tag                          &&
                                                    edHalfYear.SelectedItem         != null &&
                                                    edHalfYear.SelectedItem.Value   != null &&
                                                    edHalfYear.SelectedItem.Value   is byte ? (byte)
                                                    edHalfYear.SelectedItem.Value   : (byte)0;
    Params.IdDepSource          =   GetControl(pnlDepSource) ? TDataList.GetComboRecId(edDepSource) : 0;          
    Params.IdDepSource2         =   pnlDepSource2.Tag                        != null &&      
                                                    pnlDepSource2.Tag                        is bool && 
                                                    (bool)pnlDepSource2.Tag                          ?
                                                    TDataList.GetComboRecId(edDepSource2) : 0;
    Params.Salt                 =   pnlDepSource2.Tag                        != null &&      
                                                    pnlDepSource2.Tag                        is bool && 
                                                    (bool)pnlDepSource2.Tag                          ?
                                                    getSalt()                               : 0;
    Params.Description          =   edComment.Text;

    ацкий код сохранения параметров. Досталось в наследство. Автор кода естественно имеет в/о факультета компьютерных педиков.

    gcoder, 29 Марта 2012

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

    +118

    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
    private Excel._Application _excel;
    ...
    private void RefreshFormulas(FormulaRefreshOption formulaRefreshOption, object objectToRefresh)
    		{
    			//Где-то в дебрях километрового метода бросилось в глаза
                            ...
    			try
    			{
    				Excel.Range intersection = selection, selection2 = selection;
    				while (selection2 != null)
    				{
    					intersection = _excel.Intersect(selection2, selection2.Dependents,
    						Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    						 Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    						  Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    						   Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    
    
    					System.Windows.Forms.Application.DoEvents();
    					excelUtilities.RecalculateRangeInstance(true, intersection/*_excel.Selection as Excel.Range*/);
    					selection2 = intersection;
    				}
    
    			}
    			catch (Exception) { /*ignore the exception because .Dependents will throw an exception if there aren't any dependents*/}
                            ...
    		}

    fade, 04 Января 2012

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

    +118

    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
    private void увеличитьToolStripMenuItem_Click(object sender, EventArgs e)
            {
                panel1.Height = panel1.Height * 2;
                panel1.Width = panel1.Width * 2;
    
                graph = panel1.CreateGraphics();
                graph.Clear(Color.White);
                if (Setka)
                {
                    DrawSetka();
                }
                foreach (Fig f in figures)
                {
                    f.Masstab = f.Masstab * 2;
                    f.DrawFigure(graph);
                }
                resizeScrollBars();
                
    
            }

    Обратите внимание на название метода

    baddotnet, 09 Декабря 2011

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

    +118

    1. 1
    BuyTickets[i].session.listOfTickets.Add(BuyTickets[i]);

    Веселая объектная модель.

    killerDJO, 21 Ноября 2011

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

    +118

    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
    if (true)
                {
    
                    full_result_list = this.FullTextSearch(list_without_uss, this.CountOfDocs);
                    foreach (SearchResultItem add_item in full_result_list)
                    {
                        SearchResultItem find_item = (SearchResultItem)result_list.Find(it => ((it.DocId == add_item.DocId) && (it.ModId == add_item.ModId)));
                        if (find_item != null)
                        {
                            //                                                    find_item.Relev += add_item.Relev;
                        }
                        else
                        {
                            result_list.Add(add_item);
                        }
                    }
                }

    Просто фейерично!

    f5f3e9, 26 Октября 2011

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

    +118

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if (mainWareHouseId.HasValue && mainWareHouseId.Value.ToString() == this._locationList.SelectedValue)
    {
        return false;
    }
    else
    {
        return location == null ? true : !location.RegionalFulfillment;
    }

    abatishchev, 21 Октября 2011

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

    +118

    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
    private SqlConnection SqlConnection;
    private SqlTransaction SqlTransaction;
    private SqlCommand SqlCommand;
    private SqlDataReader SqlDataReader;
    
    protected void BtnRegister_Click(object sender, EventArgs e)
    {
    using(SqlConnection connection = new SqlConnection())
    {
    if(textBoxUsername != null)
    {
    if(textBoxPassword != null)
    {
    if(textBoxCountry !=null)
    {
    if(textBoxCity !=null)
    {
    SqlCommand.CommandText = "INSERT INTO SiteDB (Username, Password, Email, City, Country)"+
       "VALUES ('textBoxUsername', 'textBoxPassword', 'textBoxCountry', 'textBoxCity')";
    SqlCommand.ExecuteNonQuery;
    }
    }
    }
    }
    }
    }

    Прислали недавно пример кода вместе с резюме на поизицию ASP.NET Developper.

    IJobs, 06 Августа 2011

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