1. Objective C / Говнокод #13095

    −81

    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
    - (void)setCategory:(NSDictionary *)newCategory
    {
    	id category = [newCategory retain];
    	[_category release];
    	_category = category;
    	if(_category != nil) {
    		NSString *categoryID = GetString([_category objectForKey:@"id"]);
    		const CategoryViewData *data = FindCategoryViewData(categoryID);
    		if(data == NULL)
    			goto _clearView;
    
    		UIImage *buttonImage = [UIImage imageNamed:GetCategoryIconName(categoryID)];
    		[_titleButton setImage:buttonImage forState:UIControlStateNormal];
    		NSString *buttonTitle = [NSString stringWithFormat:@"  %@ ➤", data->buttonTitle];
    		[_titleButton setTitle:buttonTitle forState:UIControlStateNormal];
    		UIImage *buttonColorImage = [UIImage imageNamed:buttonColorImageName];
    		[_titleButton setTitleColor:[UIColor colorWithPatternImage:buttonColorImage] forState:UIControlStateNormal];
    		
    		_pageControl.onImage = [UIImage imageNamed:data->pageControlOnImageName];
    		_pageControl.currentPage = 0;
    		_pageControl.numberOfPages = numberOfPages;
    		
    		_allVideosLabel.text = [NSString stringWithFormat:@"Все %@", data->allVideosTitle];
    		
    		[self adjustVideoViews];
    	}
    	else {
    _clearView:
    		[_titleButton setImage:nil forState:UIControlStateNormal];
    		[_titleButton setTitle:nil forState:UIControlStateNormal];
    		[_titleButton setTitleColor:nil forState:UIControlStateNormal];
    		
    		_pageControl.onImage = nil;
    		_pageControl.currentPage = 0;
    		_pageControl.numberOfPages = 0;
    		
    		_allVideosLabel.text = nil;
    
    		for(CategoryRowCell *cell in _videoViews) {
    			[cell removeFromSuperview];
    		}
    		self.videoViews = nil;
    		_scrollView.contentSize = CGSizeZero;
    		_scrollView.contentOffset = CGPointZero;
    		_allVideosView.frame = CGRectMake(0, 0, CGRectGetWidth(_allVideosView.frame), CGRectGetHeight(_allVideosView.frame));
    		_allVideosView.hidden = YES;
    	}
    }

    Типичная ячейка

    ArtFeel, 03 Июня 2013

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

    +35

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    #if defined(_WIN32) || defined(_WIN64)
        ofstream outfile("help.txt");
        outfile << message << endl;
        system("notepad.exe help.txt");
     #else
        cout << message ;
    #endif

    Зачем бороться с юникодом в консоли, когда есть блокнот?

    crastinus, 03 Июня 2013

    Комментарии (13)
  3. PHP / Говнокод #13093

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    try {
                        throw new CException($exceptionMessage);
                    } catch (CException $e) {
                        Yii::app()->errorHandler->processException($e);
                    }

    береженного catch бережет

    DemoniacDeath, 03 Июня 2013

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

    +68

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    private void setFooMode() {
        if (foo.isSelected()) { // is currently showing
            App.appProps.put(Strings.BAR_MODE, Strings.TRUE);
        }
        else {
            App.appProps.put(Strings.BAR_MODE, Strings.FALSE);
        }
    }

    myzone, 03 Июня 2013

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

    +70

    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
    package <hostname>.sbrf.taxaccounting.service.impl;
    
    import org.junit.Test;
    
    import <hostname>.sbrf.taxaccounting.service.FormDataService;
    
    public class FormDataServiceTest {
    	private FormDataService formDataService;
    	
    	public void tearUp() {
    		 formDataService = new FormDataServiceImpl();
    	}
    	
    	@Test
    	public void testCheckMandatoryColumns() {
    		
    	}
    }

    Зато он используются юнит тесты
    и посмотрите внимательно кому это делается)))
    вот такие вот у нас тесты :)

    smpl, 03 Июня 2013

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

    +126

    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
    <td width="150">\n\
        <% if (editableParts.warehouseAssignment || shipping_map.length > 1) { %>\n\
          <a class="shipping-map-link dashed" href="#">\n\
        <% } else { %>\n\
          <span class="grey">\n\
        <% } %>\n\
          <% if (shipping_map.length == 0) { %>\n\
            не указан</span>\n\
          <% } else { %>\n\
            <% if (shipping_map.length == 1) { %>\n\
              <%= shipping_map[0].warehouse.name %>\n\
            <% } else { %>\n\
              с нескольких складов\n\
            <% } %>\n\
          <% } %>\n\
        <% if (editableParts.warehouseAssignment) { %>\n\
          </a>\n\
        <% } else { %>\n\
          </span>\n\
        <% } %>\n\
    </td>\n\

    0x2f8f, 03 Июня 2013

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

    −160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Ученик 1С спросил у своего учителя: что означает аббревиатура "Один Эс"?
    Учитель долго думал и наконец ответил ему:
    - "Один" - это когда солнечный день и воняет из трубы, это "Один"
    А "Эс", что такое "Эс", - спросил ученик
    - "Эс" - это когда солнечный день и опять же воняет из трубы

    Если бы у 1С были коаны, они выглядели бы примерно так.
    По мотивам к/ф "Моцарт" 2006

    serpinski, 02 Июня 2013

    Комментарии (26)
  8. JavaScript / Говнокод #13088

    +155

    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
    --- a/src/Foo.js
    +++ b/src/Foo.js
    @@ -1,21 +1,61 @@
         var Foo = (function () {
             function Foo(productId, productSettings, overrides) {
                 var backup, loc = document.location, home;
    -            this._sdkSettings = Program.Utils.deepCopy(Take5.settings);
    +            this._sdkSettings = JSON.parse(JSON.stringify(TGH5.settings));
                 if(overrides) {
    -                this._sdkSettings = Program.Utils.copyProperties(overrides, this._sdkSettings);
    +                if('debug' in overrides) {
    +                    this._sdkSettings.debug = overrides.debug;
    +                }
    +                if('inDemoMode' in overrides) {
    +                    this._sdkSettings.inDemoMode = overrides.inDemoMode;
    +                }
    +                if('sdkHome' in overrides) {
    +                    this._sdkSettings.sdkHome = overrides.sdkHome;
    +                }
    +                if('eixtUrl' in overrides) {
    +                    this._sdkSettings.exitUrl = overrides.exitUrl;
    +                }
    +                if('ads' in overrides) {
    +                    if('preRoll' in overrides.ads) {
    +                        this._sdkSettings.ads.preRoll = overrides.ads.preRoll;
    +                    }
    +                    if('inGame' in overrides.ads) {
    +                        this._sdkSettings.ads.inGame = overrides.ads.inGame;
    +                    }
    +                    if('postRoll' in overrides.ads) {
    +                        this._sdkSettings.ads.postRoll = overrides.ads.postRoll;
    +                    }
    +                }
    +                if('reporting' in overrides) {
    +                    if(overrides.reporting instanceof Object) {
    +                        if('analyticsId' in overrides.reporting) {
    +                            this._sdkSettings.reporting.analyticsId = overrides.reporting.analyticsId;
    +                        }
    +                        if('site' in overrides.reporting) {
    +                            this._sdkSettings.reporting.site = overrides.reporting.site;
    +                        }
    +                        if('virtualPageRoot' in overrides.reporting) {
    +                            this._sdkSettings.reporting.virtualPageRoot = overrides.reporting.virtualPageRoot;
    +                        }
    +                        if('initParams' in overrides.reporting) {
    +                            this._sdkSettings.reporting.initParams = overrides.reporting.initParams;
    +                        }
    +                    } else {
    +                        this._sdkSettings.reporting = overrides.reporting;
    +                    }
    +                }
                 }

    А я сажаю алюминивые агурцы - а-а - на брезентовом поле :(
    Некоторые имена сознательно изменены дабы не посягать на копирайты и торговые знаки.

    wvxvw, 02 Июня 2013

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

    +23

    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
    #ifndef SAFE_RELEASE
    #define SAFE_RELEASE(x) \
       if(x != NULL)        \
       {                    \
          x->Release();     \
          x = NULL;         \
       }
    #endif
    
    #define SAFE_DELETE(a) if( (a) != NULL ) delete (a); (a) = NULL;
    
    #ifndef SAFE_ARRAY_DELETE
    #define SAFE_ARRAY_DELETE(x) \
       if(x != NULL)             \
       {                         \
          delete[] x;            \
          x = NULL;              \
       }
    #endif
    
    #define SAFE_FREE( p )      if( p ) { free( p ) ; p=NULL ; }

    Я вот все никак не могу забыть старый код из доков макрософт по COM, а также из книги Андре Ла Мота.

    Два макроса до сих пор висят среди доков на сайте мс (по коду догадаетесь какие):

    http://msdn.microsoft.com/ru-RU/library/windows/desktop/dd743946(v=vs.85).aspx

    LispGovno, 01 Июня 2013

    Комментарии (48)
  10. Куча / Говнокод #13086

    +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
    <div class="is-element-border-top">
              <div class="is-element-border-right">
                <div class="is-element-border-bottom">
                  <div class="is-element-border-left">
                    <div class="is-element-corner-top-left">
                      <div class="is-element-corner-top-right">
                        <div class="is-element-corner-bottom-right">
                          <div class="is-element-corner-bottom-left">
                            <span class="curr_show ">
                              5 days                        </span>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>

    Каскадная таблица стилей, ёпта.

    bot-minurast, 01 Июня 2013

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