• 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: class cluster making: easy/lazy way to keep counterpart methods in sync?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: class cluster making: easy/lazy way to keep counterpart methods in sync?


  • Subject: Re: class cluster making: easy/lazy way to keep counterpart methods in sync?
  • From: Allan Odgaard <email@hidden>
  • Date: Sun, 22 Feb 2004 05:30:23 +0100

On 21. Feb 2004, at 22:36, Ben Dougall wrote:

has anyone got any ideas for keeping counter part concrete class methods of a class cluster in sync while working on them? that's same name, very similar implementations (except usually for direct dealings with ivars, although other parts also will vary sometimes) methods. [...]

If only the access of ivars differ in the concrete implementation, you should probably only factor out the part which access the ivar and put the implementation in the abstract base class.

If you look at e.g. NSArray I think most methods are in the base class and the derived classes only need to implement a few access methods.

a perfect situation, although i can't imagine how it'd be possible, is to update one method and the others change too, automatically, but only if it's the non-specific to ivar parts of the method.

You can make the code for the "base" implementation a (C++) template. Though if you haven't worked with C++ templates before (for "advanced" stuff, i.e. meta programming), there might be a few new concepts to learn (traits is probably the most important thing for what you are doing).

An example of templates used with Cocoa is e.g. the back insert iterators in CocoaSTL -- it allows insertion into a container through an STL iterator, but since NSIndexSet, NSData, NSString and NSArray all have different ways to insert elements, the code is written as a template which receive the actual code for insertion as a template argument (an inline function) -- although here that could actually just as well have been a constructor argument (but that would make it difficult to default construct the iterators).
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >class cluster making: easy/lazy way to keep counterpart methods in sync? (From: Ben Dougall <email@hidden>)

  • Prev by Date: Re: NSPasteboard notifications?
  • Next by Date: Re: [SOLVED !] Re-enabling Expose for certain windows (Andreas Kummer)
  • Previous by thread: Re: class cluster making: easy/lazy way to keep counterpart methods in sync?
  • Next by thread: Zlib compression
  • Index(es):
    • Date
    • Thread