On Mar 14, 2013, at 4:51 PM, Luther Baker <lutherba...@gmail.com> wrote:

> but more
> recently, several seniors Obj-C devs have suggested that they prefer
> #import in the .h files.

Oh god, no. Who says that?! Importing a header just because it defines a class 
you’re using is a major waste. The only times you should need to import a 
header are if you’re subclassing a class declared in it, or implementing a 
protocol it defines, or using some C-level thing like a constant or macro 
defined in it.

If you overuse #imports in headers you’re liable to run into circular 
references at some point, as well as slowing down your compilation 
unnecessarily. It will also tend to bring into scope a whole ton of irrelevant 
methods from classes you don’t use, which will make autocomplete less useful 
and increase the chance of mistakes not getting caught when you end up 
messaging an ‘id’.

Several times in my career I’ve spent time going through a large and 
excruciatingly slow-to-build project removing unnecessary #includes/#imports. 
It makes a big difference.

—Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to