Re: "context-aware" bindings
Re: "context-aware" bindings
- Subject: Re: "context-aware" bindings
- From: Joanna Carter <email@hidden>
- Date: Sun, 27 Feb 2011 16:19:59 +0000
Le 27 févr. 2011 à 15:25, Mikkel Eide Eriksen a écrit :
> It would only return nil in some cases. I'm working on some Gedcom <-> Core Data code. All objects in Gedcom have a "tag" identifier. One such object is an "Event", with the generic tag EVEN. There are multiple subtypes of Event, such as BIRT (birth), DEAT (death), CONF (confirmation), etc.
>
> An Event can also have a "type", which in the case of generic EVENs is something for which no specific tag exists. So:
>
> Event with type "Birth" should become:
> 1 BIRT
> 2 DATE ...
> 2 PLAC ...
>
> generic Event with some type should become:
> 1 EVEN
> 2 TYPE Event Type
> 2 DATE ...
> 2 PLAC ...
>
> My current implementation of the type getter on the Event object checks to see if the type is one of the known tags (Birth, etc), and returns nil so as to avoid redundant data:
>
> 1 BIRT
> 2 TYPE Birth
> 2 DATE ...
> 2 PLAC ...
>
> I think I'll probably use a displayType property for bindings, and the internal type property for writing out to Gedcom. Another option would be to subclass Event into all the different types, but that seems overkill.
If you are displaying the event's "tag", then all you need is to return the appropriate string; the event getter can check what to return.
But, if you are transforming to/from an event from/to something else that should contain the tag value, then what about using a variation of the Visitor design pattern?
Are you creating something from the event, or an event from something else? Can you let us see an idea of the two classes involved?
Joanna
--
Joanna Carter
Carter Consulting
_______________________________________________
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