Skip to content

Instantly share code, notes, and snippets.

@samkrishna
Last active December 13, 2015 21:09
Show Gist options
  • Save samkrishna/4975595 to your computer and use it in GitHub Desktop.
Save samkrishna/4975595 to your computer and use it in GitHub Desktop.
Optimize This! (Coding Habits)

So, it turns out that there's always another good idea.

Patrick Hughes implemented a cool idea WRT eliminating the use of magic strings from his Objective-C codebases (at least for the use of the -[UIImage imageNamed:]). It's a pretty good idea, and one that has inspired at least one extension: GenLoc by Ivan Suhinin.

The problem is, both of them use preprocessor hacking to get this done

I read an article last year about code smells and I can definitely say that I felt a LOT better knowing that I wasn't littering the precompiled header file with a lot of auto-or-human-generated constants. Seeing it used A LOT on The Daily's codebase creeped me out.

I have to believe that there's a way to do this such that:

  1. You can have a practically-zero-smell codebase.
  2. Fast compiles
  3. Extensive and automated test coverage

I saw during my time on the last project that a mistake I made by having the Object Model have it's own global .h import file (ObjectModel.h) made things slower, not faster.

Trick is going to be in how to create this as an automated script that works and is code-smell-free.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment