• 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: designing beyond MV and (one) C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: designing beyond MV and (one) C


  • Subject: Re: designing beyond MV and (one) C
  • From: Sam Stigler <email@hidden>
  • Date: Sun, 27 Jan 2008 11:09:12 -0800

You might consider looking into categories. They let you add methods to existing classes... for example, add an -appendDOCstring:(NSData *)wordDocument method to NSMutableAttributedString. For more, see http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_1.html . It might be more convenient for you in the long run to write all of your parsers as categories -- if not of NSMutableAttributedString, maybe of NSData.


On Jan 27, 2008, at 10:33 AM, Daniel Child wrote:

I'm wondering, though, whether I haven't done something strange by setting up a RecordParsingStrategies class with no instance variables? Or is that how you would do it in Objective-C. There's nothing that seems to correspond exactly to the "implements" keyword in Java, so I just made a field-less class with methods. (I guess they could just as well have been plain functions.) If there is a better way, please let me know. Otherwise, thanks for the tip.

On Jan 14, 2008, at 10:20 AM, email@hidden wrote:
In the MVC paradigm, do you typically use a different controller for
each major interface? Should I have three controllers, one to handle
each type of parser? Three window controllers, to handle each major
settings interface?

Look into the 'strategy' design pattern. All that you can do is have a
single controller with appropriate
strategy for each of the file type use different strategies
dynamically for parsing them.


http://en.wikipedia.org/wiki/Strategy_pattern

I would propose a solution something like this:

A ParserController class. This will dynamically associate with a
subclass of an abstract 'ParsingStrategy'
class. Lets imagine that we are parsing an RTF, a DOC and a PDF file.
What I would have is classes: RTFParsingStrategy,
DOCParsingStrategy and PDFParsingStrategy - all are subclasses of
ParsingStrategy. And each of these parsing strategies
will associate with appropriate window controllers of their own to
facilitate the necessary UI. I recommond having one window controller
per window. ParserController can also act as the window controller
for your 'Entry UI'. The same can have intelligence to decide which
strategy at runtime. This design makes it extremely flexible to add
new strategies as you introduce new file types.



_______________________________________________

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

_______________________________________________

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


References: 
 >designing beyond MV and (one) C (From: Daniel Child <email@hidden>)

  • Prev by Date: Handling User Generated Tablet Events
  • Next by Date: Re: Handling User Generated Tablet Events
  • Previous by thread: designing beyond MV and (one) C
  • Next by thread: Re: designing beyond MV and (one) C
  • Index(es):
    • Date
    • Thread