On Nov 4, 2009, at 10:47 AM, Paul Bruneau wrote:

So this is very attractive, but I keep worrying about how I would change a door from one type to another if I utilize these subclasses. Any ideas the best pattern to use? I can't figure out how I would take an existing object of say SLFlushDoor and convert it to an SLMonumentalDoor

Do you need to change the type of an instance? Or can you replace it with a new instance of the new type? I don't know the details of your model, but the latter seems cleaner, and works well with subclassing.

For example, if you need to convert to SLMonumentalDoor, you can add a method to SLDoor:
        - (SLMonumentalDoor*) asMonumentalDoor;
which creates a new instance. (SLMonumentalDoor can override this to return self, of course.)

—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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to