Re: Plug Ins - To Subclass or to Protocol?
Re: Plug Ins - To Subclass or to Protocol?
- Subject: Re: Plug Ins - To Subclass or to Protocol?
- From: Prachi Gauriar <email@hidden>
- Date: Wed, 21 Jul 2004 17:56:34 -0500
On Jul 21, 2004, at 4:27 PM, Lee Morgan wrote:
I'm working on a app that uses plug-in extensively.
And I need to decided if I should... Create a class that plug-in
developers would sub-class to make a plug-in? Or define a protocol
that the plug-in will have to follow?
The tricky part is...a single plug-in might work on different parts of
data. For example there might be a "placement" plug-in that sets the
location of a given object. But the plug-in might be passed a text
object, a graphic object or some other object.
So when the plug-in is loaded it should return what kind of objects it
can work on.
I would just use a protocol. It affords the plugin developers the most
flexibility, while still defining an interface between the plugin and
your app. In addition, you probably aren't providing any common data
for all plugins, just a list of methods that the plugin should respond
to. As such, a protocol seems like the best tool for the job.
Since you're dealing with different types of objects, you can just pass
a common superclass of those types to the plugin, or better yet, id.
As far as the plugin telling you what types it can handle, a simple
method like
+ (NSArray *)acceptedTypes;
that returns the types it can operate on should work swimmingly.
-Prachi
_______________________________________________
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.