Skip navigation.
 
mlRe:designing beyond MV and (one) C
FROM : Shripada Hebbar
DATE : Mon Jan 14 12:08:52 2008

On 12.01.2008, at 23:39, Daniel Child wrote:
> I'm building a utility to take various types of data and parse them
> according to my settings. I'm looking to have an introductory window
> that asks what type of file the user wants to parse. Then based on
> the response, I open the appropriate window to gather data about the
> file to be handled. Separate interfaces will be used for the
> different types of parsing operations.
>
> 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.


Regards
Shripada

Related mailsAuthorDate
mldesigning beyond MV and (one) C Daniel Child Jan 12, 23:39
mlRe: designing beyond MV and (one) C mmalc crawford Jan 12, 23:58
mlRe: designing beyond MV and (one) C Keary Suska Jan 13, 18:56
mlRe: designing beyond MV and (one) C Uli Kusterer Jan 14, 10:19
mlRe:designing beyond MV and (one) C Shripada Hebbar Jan 14, 12:08
mlRe: designing beyond MV and (one) C Daniel Child Jan 16, 00:40
mlRe: designing beyond MV and (one) C Uli Kusterer Jan 16, 02:31
mlRe: designing beyond MV and (one) C Ricky Sharp Jan 16, 03:03
mlRe: designing beyond MV and (one) C Ken Thomases Jan 20, 03:25