This is not Cool, Dude

Recently I've been working on some code wrote in 2013 by some dude, and I kind of feel it's funny due to the quality of the code. Yes there are some more advanced topic about how to write good code but you don't really see example of bad code everyday, for example:

[[[[self tabBarController] tabBar] items] objectAtIndex:3]

And I'm about to change the order of the tabs.

UIViewController *viewController5 = [[MoreViewController alloc] initWithNibName:@"MoreViewController" bundle:nil];

Nice variable name.

Duplicated code.

It's hard for us to totally avoid duplicated code (especially for those 2-line codes), but copy/paste the whole login code/xib into 2 places is just... not very common.

CGRectMake(0, 0, 320, 44)

It used be everywhere but not anymore, so hi old buddy! Actually you don't need to use things like UIScreen.main_width, self.view.w should be fair enough (+main_width and -w are from LCategory) in most cases. 

Why, oh why?

    if (selectedScope == 0) {

        distanceToFilterResults = filterDistance500M;

        [[QCDTaskMaster sharedInstance]setFilterDistance:filterDistance500M];

    }else if (selectedScope == 1) {

        distanceToFilterResults = filterDistance5KM;

        [[QCDTaskMaster sharedInstance]setFilterDistance:filterDistance5KM];

    }else if (selectedScope == 2) {

        distanceToFilterResults = filterDistance50KM;

        [[QCDTaskMaster sharedInstance]setFilterDistance:filterDistance50KM];

    }else if (selectedScope == 3) {

        distanceToFilterResults = filterDistanceALL;

        [[QCDTaskMaster sharedInstance]setFilterDistance:filterDistanceALL];


I totally don't understand why someone would write code like this. There are more than 5 ways to make the code cleaner.


There are a shit load of stuff like this, and guess who's not cool? It's me 'cause I'm making fun of other people, which is totally not cool. Don't do it kids.

No comments: