1. Список говнокодов пользователя Eyeless

    Всего: 5

  2. Java / Говнокод #11412

    +74

    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
    if (scope.equals("page")) {
        beanObject = context.getAttribute(bean);
    } else {
        if (scope.equals("request")) {
            beanObject = context.getRequest().getAttribute(bean);
        } else {
            if (scope.equals("session")) {
                beanObject = context.getSession().getAttribute(bean);
            } else {
                if (scope.equals("context")) {
                    beanObject = context.getServletContext().getAttribute(bean);
                }
            }
        }
    }

    Eyeless, 14 Июля 2012

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

    +71

    1. 1
    2. 2
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(new Date(System.currentTimeMillis()));

    Eyeless, 19 Апреля 2012

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

    +92

    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
    protected IOException copyRange(InputStream istream, ServletOutputStream ostream) {
    
            // Copy the input stream to the output stream
            IOException exception = null;
            byte buffer[] = new byte[input];
            int len = buffer.length;
            while (true) {
                try {
                    len = istream.read(buffer);
                    if (len == -1) {
                        break;
                    }
                    ostream.write(buffer, 0, len);
                } catch (IOException e) {
                    exception = e;
                    len = -1;
                    break;
                }
            }
            return exception;
    
        }

    Си-стайл в исходниках Tomcat. Зачем кидать исключения, если их можно возвращать вместо кода ошибки?

    Eyeless, 01 Августа 2011

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

    +102

    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
    if (nchan == 1)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 2)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 3)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 4)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 5)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 6)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],chan_list[5],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 7)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],chan_list[5],chan_list[6],sub_window_length,main_window_length,out_dir,decon_c);
      }
    ...
      }
      if (nchan >= 14)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],chan_list[5],chan_list[6],chan_list[7],chan_list[8],chan_list[9],chan_list[10],chan_list[11],chan_list[12],chan_list[13],sub_window_length,main_window_length,out_dir,decon_c);
      }

    Тяжело в сях работать со строками и переменным числом параметров...

    Eyeless, 04 Мая 2011

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

    +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
    long[] times = new long[9];
    times[0] = System.currentTimeMillis();
    initPsrList();
    times[1] = System.currentTimeMillis();
    initPsrHierarchy();
    times[2] = System.currentTimeMillis();
    initPsrCheckList()
    times[3] = System.currentTimeMillis();
    initTranslationTables();
    times[4] = System.currentTimeMillis();
    initTranslationInfo()
    times[5] = System.currentTimeMillis();
    initVoltage();
    times[6] = System.currentTimeMillis();        
    initElectroMetterPrecision();
    times[7] = System.currentTimeMillis();        
    initMeasTransformers();
    times[8] = System.currentTimeMillis();
    
    long diff;
    System.out.println("\n\n\n\n******************************************************************");
    diff = times[1] - times[0];
    System.out.println("-- initPsrList() = " + diff + "ms");
    diff = times[2] - times[1];
    System.out.println("-- initPsrHierarchy() = " + diff + "ms");
    diff = times[3] - times[2];
    System.out.println("-- initPsrCheckList() = " + diff + "ms");
    diff = times[4] - times[3];
    System.out.println("-- initTranslationTables() = " + diff + "ms");
    diff = times[5] - times[4];
    System.out.println("-- initTranslationInfo() = " + diff + "ms");
    diff = times[6] - times[5];
    System.out.println("-- initVoltage() = " + diff + "ms");
    diff = times[7] - times[6];
    System.out.println("-- initElectroMettersPrecision() = " + diff + "ms");
    diff = times[8] - times[7];
    System.out.println("-- initMeasTransformers() = " + diff + "ms");
    diff = times[8] - times[0];
    System.out.println("total = " + diff + "ms");
    System.out.println("\n******************************************************************\n\n\n\n ");

    Код подготовки отображаемой страницы на сервере.

    Eyeless, 12 Мая 2010

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