[Adium-devl] A thorny design problem
Evan Schoenberg
evan.s at dreskin.net
Mon Nov 10 20:14:20 UTC 2008
On Nov 10, 2008, at 2:51 PM, David Smith wrote:
> In my ongoing project to get contacts in multiple groups working
> and simplify the implementation of the offline group, I've been
> attempting to make visibility of a contact depend on where it's
> being displayed, rather than being inherent to the contact. With
> visibility now being recalculated on request instead of cached, this
> is simply a matter of changing the visible property to also take a
> 'container' argument.
>
> However, this introduces a nasty issue: Part of the visibility
> logic is shared (handling 'always visible', for example) and part
> isn't (handling 'show offline' differs between the offline group and
> regular groups for example). If I duplicate the shared logic it
> violates Don't Repeat Yourself, with all the expected maintenance
> headaches that brings. If I leave the visibility logic in one place
> and add special cases for each type of container, that makes it
> difficult to extend, and violates encapsulation.
What if rather than an object having a visible property at all --
which no longer makes much sense if one object can be in multiple
containers and therefore have a visible state in one situation but an
invisible state in another -- the logic were delegated to the container?
Container subclasses can call super's implementation to get the shared
logic, then OR this with their own visibility logic.
Something like:
-[NSObject<AIContainingObject> objectIsVisibile:(AIListObject *)object]
?
Cheers,
Evan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
URL: <http://adium.im/pipermail/devel_adium.im/attachments/20081110/f914a8fc/attachment.sig>
More information about the devel
mailing list