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

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

    +76

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private static List<Character> englishAlphabet;
    
        public static final Integer ENGLISH_ALPHABET_LENGTH = 26;
    
        static {
            englishAlphabet = new ArrayList<Character>();
            englishAlphabet.add('#');
            for (int i = 0; i < ENGLISH_ALPHABET_LENGTH; i++) {
                englishAlphabet.add((char) ('A' + i));
            }
        }

    Товарищ уже уволился :)

    jekyll, 20 Января 2012

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

    +76

    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
    public class FormForThemeView extends LayoutContainer {
    
        private double innerRightPanelHeight = 0.7;
        private LayoutContainer leftContentPanel;
        private LayoutContainer rightContentPanel;
    
        private ContentPanel innerLeftDataPanel;
        private ContentPanel innerRightDataPanel;
        private ContentPanel upperRightDataPanel;
        private ContentPanel bottomRightDataPanel;
        private ContentPanel bottomMiddleDataPanel;
    
        public FormForThemeView() {
            leftContentPanel = new LayoutContainer(new RowLayout(Style.Orientation.HORIZONTAL));
            rightContentPanel = new LayoutContainer(new RowLayout(Style.Orientation.VERTICAL));
    
            innerLeftDataPanel = new ContentPanel(new RowLayout(Style.Orientation.VERTICAL));
            innerRightDataPanel = new ContentPanel(new RowLayout(Style.Orientation.VERTICAL));
            bottomMiddleDataPanel = new ContentPanel(new RowLayout(Style.Orientation.VERTICAL));
    
            upperRightDataPanel = new ContentPanel(new RowLayout(Style.Orientation.VERTICAL));
            bottomRightDataPanel = new ContentPanel(new RowLayout(Style.Orientation.VERTICAL));
        }
    
        public void render() {
            innerLeftDataPanel.setBorders(false);
            innerLeftDataPanel.setBodyBorder(false);
            innerLeftDataPanel.setHeaderVisible(false);
            innerLeftDataPanel.setBodyStyle("backgroundColor: transparent");
            innerLeftDataPanel.add(bottomMiddleDataPanel, new RowData(-1, -1));
    
            innerRightDataPanel.setBorders(false);
            innerRightDataPanel.setBodyBorder(false);
            innerRightDataPanel.setHeaderVisible(false);
            innerRightDataPanel.setBodyStyle("backgroundColor: transparent");
    
            bottomMiddleDataPanel.setBorders(false);
            bottomMiddleDataPanel.setBodyBorder(false);
            bottomMiddleDataPanel.setHeaderVisible(false);
            bottomMiddleDataPanel.setBodyStyle("backgroundColor: transparent");
    
            leftContentPanel.setBorders(false);
            leftContentPanel.add(innerRightDataPanel, new RowData(156, 1));
            leftContentPanel.add(innerLeftDataPanel, new RowData(1, 1));
    
    
            rightContentPanel.setStyleAttribute("borderLeft", "2px dotted #99BBE8");
            rightContentPanel.add(upperRightDataPanel, new RowData(1, innerRightPanelHeight));
            rightContentPanel.add(bottomRightDataPanel, new RowData(1, 1 - innerRightPanelHeight));
    
            setLayout(new RowLayout(Style.Orientation.HORIZONTAL));
            add(leftContentPanel, new RowData(1, 1));
            add(rightContentPanel, new RowData(156, 1));
        }
    }

    Попытка сделать панель на GXT. Попутаны стороны right находится слева, тк смотрим с другой стороны. По названиям переменных ничего не понятно. inner, bottom, left, rigth - найдите лишнее.

    johnny1987, 06 Января 2012

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

    +76

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public int RemoveEquals(AtASEData[] ar,int ln) {
       if (ln==0) return 0;
       int i=1;
       int j=0;
       while (i<ln) {
          if (((Integer)ar[i].inData).intValue()==((Integer)ar[j].inData).intValue())
          ar[i].SetRootData(ar[j]); else ar[++j]=ar[i];
          i++;
       }
       return j+1;
    }

    Loord, 14 Декабря 2011

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

    +76

    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
    public class Xorer {
        private static long SHIFR= 71180519;
        private Xorer() {
        }
    
        /**
         * ��������� �������� value XOR shifr
         * @param value ������� �������� �������� � ��������� �������
         * @return ��������� ��� �������� �������� � ��������� �������
         */
        public static synchronized String executeString(String value){
            String res=null;
            long code=0;
            try{
                  code=Long.parseLong(value);
            } catch(Exception e){
                e.printStackTrace();
            }
            res=execute(code);
            return res;
        }
    
        /**
         * ��������� �������� value XOR shifr
         * @param code ������� �������� �������� � ������� long
         * @return ��������� ��� �������� �������� � ��������� �������
        */
        public static synchronized String execute(long code){
            String res=null;
            if(code>0){
                long newvalue= code ^ SHIFR;
                res=""+newvalue;
            }
            return res;
        }
    }

    Вот вам ещё еда.

    nikelin, 08 Декабря 2011

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

    +76

    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
    @Retention(RetentionPolicy.RUNTIME)
    @Target({ ElementType.FIELD})
    public static @interface Property { String value(); }
    	
    public static class PropertyImpl implements Property {
        private final String value; 
        public PropertyImpl(String value) { this.value = value; }
        @Override public Class<? extends Annotation> annotationType() { return Property.class; }		
        @Override public String value() { return this.value; }
        @Override public int hashCode() { return (127 * "value".hashCode()) ^ value.hashCode();  }
        @Override public boolean equals(Object o) {
            if (!(o instanceof Property)) { return false; }
            Property other = (Property) o;
            return value.equals(other.value());
        }
    }

    отформатировал для компактности.
    Идеи для чего делать реализцию аннотации?

    tir, 06 Декабря 2011

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

    +76

    1. 1
    assertTrue(!reportDto.getOrder());

    Фантазия индусов неиссякаема. Перед написанием кода читать Упанишады до просветления.

    roman-kashitsyn, 01 Декабря 2011

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

    +76

    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
    public class Sorting {  
    
        private static void swapElements(int[] arr, int index1, int index2) {
            int temp = arr[index1];
            arr[index1] = arr[index2];
            arr[index2] = temp;
        }
    
        public static void mergeSort(int[] arr) {
            if (arr.length == 1) {
                return;
            }        
            final int temp = (arr.length % 2 == 0) ? arr.length / 2 : (arr.length + 1) / 2;
    
            int[] left = new int[temp];
            int[] right = new int[arr.length / 2];
            System.arraycopy(arr, 0, left, 0, temp);
            System.arraycopy(arr, temp, right, 0, arr.length / 2);
    
            Sorting.mergeSort(left);
            Sorting.mergeSort(right);
            Sorting.mergeSortHelper(arr, left, right);
        }
    
        private static void mergeSortHelper(int[] arr, int[] left, int[] right) {
            int L = 0, R = 0;
            boolean Ltop = false, Rtop = false;
    
            for (int i = 0; i < arr.length; i++) {
                if (L < left.length - 1 && R < right.length - 1) {
                    if (left[L] <= right[R]) {
                        arr[i] = left[L];
                        L++;
                    } else {
                        arr[i] = right[R];
                        R++;
                    }
                } else if ((L == left.length - 1) ^ (R == right.length - 1)) {
                    if (L == left.length - 1) {
                        if ((left[L] <= right[R]) && !Ltop) {
                            arr[i] = left[L];
                            Ltop = true;
                        } else {                        
                            arr[i] = right[R];
                            R++;
                        }
                    } else {
                        if ((right[R] <= left[L]) && !Rtop) {
                            arr[i] = right[R];
                            Rtop = true;
                        } else {                        
                            arr[i] = left[L];
                            L++;
                        }
                    }
                } else {
                    if (i < arr.length - 1) {
                        arr[i] = (left[L] < right[R]) ? left[L] : right[R];                    
                    } else {                    
                        arr[i] = (left[L] > right[R]) ? left[L] : right[R];
                    }
                }
            }        
        }

    Реализация сортировки слиянием на Java

    kaspvar, 31 Августа 2011

    Комментарии (43)
  9. Java / Говнокод #7643

    +76

    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
    if (s.contains("-"))
                    {
                        String[] sa = s.split("-", 2);
                        for (Long i = Long.parseLong(sa[0].trim()); i<=Long.parseLong(sa[1].trim()); i++)
                        {
                            departmentsQueue.add(i);
                        }
                    }
                    else
                    {
                        Long id = Long.parseLong(s.trim());
                        departmentsQueue.add(id);
                    }

    Отличный цикл! Кстати, я бы тут ещё и s.contains() убрал

    konsoletyper, 25 Августа 2011

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

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    @Override
        public ResponseBag[] send(SmsBag[] smsBag) {
            ArrayList<ResponseBag> responseList = new ArrayList<ResponseBag>();
            for(SmsBag bag : smsBag) {
                responseList.add(super.send(bag));
            }
            ResponseBag[] responseBag = new ResponseBag[responseList.size()];
            return responseList.toArray(responseBag);
        }

    manyrus, 18 Августа 2011

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

    +76

    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
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    class PseudoVamp {
    	public int num;
    	public boolean truevamp = false;
    	public int x;
    	public int y;
    	public int n1;
    	public int n2;
    	public int n3;
    	public int n4;
    
    	void breaknsort() {
    		n1 = num % 10;
    		n2 = num / 10 % 10;
    		n3 = num / 100 % 10;
    		n4 = num / 1000;
    		int tmp;
    		for (int i = 0; i < 4; i++) {
    			if (n1 > n2) {
    				tmp = n1;
    				n1 = n2;
    				n2 = tmp;
    			}
    
    			if (n2 > n3) {
    				tmp = n2;
    				n2 = n3;
    				n3 = tmp;
    			}
    
    			if (n3 > n4) {
    				tmp = n3;
    				n3 = n4;
    				n4 = tmp;
    			}
    		}
    	}
    
    	public PseudoVamp(int a, int b) {
    		x = a;
    		y = b;
    		num = x * y;
    		breaknsort();
    	}
    }
    
    public class Test {
    
    	static void checkvamp(PseudoVamp vamp) {
    		int x1 = vamp.x % 10;
    		int x2 = vamp.x / 10;
    
    		int y1 = vamp.y % 10;
    		int y2 = vamp.y / 10;
    
    		int tmp;
    		for (int i = 0; i < 4; i++) {
    			if (x1 > x2) {
    				tmp = x1;
    				x1 = x2;
    				x2 = tmp;
    			}
    
    			if (x2 > y1) {
    				tmp = x2;
    				x2 = y1;
    				y1 = tmp;
    			}
    
    			if (y1 > y2) {
    				tmp = y1;
    				y1 = y2;
    				y2 = tmp;
    			}
    		}
    		if (vamp.n1 == x1 && vamp.n2 == x2 && vamp.n3 == y1 && vamp.n4 == y2)
    			vamp.truevamp = true;
    	}
    
    	public static void main(String[] args) {
    		for (int i = 11; i < 100; i++) {
    			for (int j = 11; j < 100; j++) {
    				PseudoVamp v = new PseudoVamp(i, j);
    				if (v.num < 1000)
    					continue;
    				if (v.num > 9999)
    					return;
    				checkvamp(v);
    				if (v.truevamp)
    				System.out.println(v.x + " * " + v.y + " = " + v.num);
    			}
    		}
    	}
    }

    A vampire number has an even number of digits and is formed by multiplying a pair of numbers containing half the number of digits of the result. The digits are taken from the original number in any order. Pairs of trailing zeroes are not allowed. Examples include:
    1260 = 21 * 60
    1827 = 21 * 87
    2187 = 27 * 81
    Write a program that finds all the 4-digit vampire numbers.
    w/o using of arrays.

    ch0sen, 15 Августа 2011

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