Re: Can I split an implementation file?
Re: Can I split an implementation file?
- Subject: Re: Can I split an implementation file?
- From: Andy Lee <email@hidden>
- Date: Thu, 27 Nov 2008 16:36:53 -0800
On Nov 27, 2008, at 8:34 AM, Michael Ash wrote:
Others have answered the direct question, I thought I would wander off
into the realm of potentially unwanted advice. If your class is
getting this large, then it may be a sign that your design is becoming
unwieldy and you should actually be splitting it into multiple
classes. Personally I try to keep my classes under 2000 lines whenever
possible, and under 1000 if I can. When I can't avoid them getting
larger, then I try to see if I can split them up nicely. Often when
they become that large, it's because they're doing 2-3 distinct tasks,
and each of those distinct tasks can generally be split into a
separate class.
Yet another option is to split the large class into subclasses. If
you have a class ThingThatDoesFooAndBar, it might make sense to have:
@interface ThingThatDoesFoo : NSObject
...stuff related to Foo...
@end
@interface ThingThatDoesBar : ThingThatDoesFoo
...stuff related to Bar...
@end
Even if you never expect to create any other subclasses of
ThingThatDoesFoo, splitting the code along these lines can make the
code easier to manage. Your particular class may not be amenable to
this kind of split, but it's worth at least considering.
Anyway, just a thought on design, obviously you don't have to
listen. :-)
Ditto. :)
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden