• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can I split an implementation file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Can I split an implementation file? (From: "Greg Robertson" <email@hidden>)
 >Re: Can I split an implementation file? (From: "Michael Ash" <email@hidden>)

  • Prev by Date: Re: What is the best way to get an NSSlider to respond to the mouse scroll wheel?
  • Next by Date: Re: What is the best way to get an NSSlider to respond to the mouse scroll wheel?
  • Previous by thread: Re: Can I split an implementation file?
  • Next by thread: [MEET] Aachen CocoaHeads TODAY (November 27, 2008)
  • Index(es):
    • Date
    • Thread