H
hugo.elias
Hi all,
I hope nobody minds me posting this question to this group, but I
couldn't find any group closer to the Subject.
Can anyone clear up where you draw the lines when dividing up an
application into Model, View and Controller parts?
For example: I have some classes:
class FlatWorld;
class Shape;
class BlobbyShape; // inherits from Shape
class StringyShape; // inherits from Shape
class GassyShape; // inherits from Shape
And my application is split thus:
Model:
The Shapes. And Flatworld which contains a vector<Shape>
View:
Class which gets information from Flatworld, and renders the Shapes.
Controller:
Class which interprets mouse clicks/drags and tells the Shapes to
move or change shape.
The other important thing I have learned is to do things Once And Only
Once (OAOO). The problem is that the MVC concept seems to break the
OAOO principle, because two classes (perhaps written by two different
people) need to know enough about the Shapes to be able to render them.
For example the GassyShape is rendered in a totally different way to
the StringyShape. Also, there are totally different methods for
manipulating the Shapes.
What happens when someone writes a new kind of Shape? The author of
the View has to be contacted and taught how to read the information and
render the shape, and he must edit his code. Ditto the Controller.
Wouldn't it be better to integrate the Controller and View into the
Model?
For example:
class Shape
{
virtual void Render(Surface *S);
virtual void Click(Point P);
virtual void Drag(Point P);
virtual void Release(Point P);
};
Now, new Shapes can be written at any time, and they take care of
themselves, simply being told when/where to render, and any mouse
actions that come their way.
I have Googled for this a lot, and read the C2 Wiki, but I still can't
find a decent resolution to this. Can anyone offer any advice?
Many thanks in advance.
Hugo Elias
I hope nobody minds me posting this question to this group, but I
couldn't find any group closer to the Subject.
Can anyone clear up where you draw the lines when dividing up an
application into Model, View and Controller parts?
For example: I have some classes:
class FlatWorld;
class Shape;
class BlobbyShape; // inherits from Shape
class StringyShape; // inherits from Shape
class GassyShape; // inherits from Shape
And my application is split thus:
Model:
The Shapes. And Flatworld which contains a vector<Shape>
View:
Class which gets information from Flatworld, and renders the Shapes.
Controller:
Class which interprets mouse clicks/drags and tells the Shapes to
move or change shape.
The other important thing I have learned is to do things Once And Only
Once (OAOO). The problem is that the MVC concept seems to break the
OAOO principle, because two classes (perhaps written by two different
people) need to know enough about the Shapes to be able to render them.
For example the GassyShape is rendered in a totally different way to
the StringyShape. Also, there are totally different methods for
manipulating the Shapes.
What happens when someone writes a new kind of Shape? The author of
the View has to be contacted and taught how to read the information and
render the shape, and he must edit his code. Ditto the Controller.
Wouldn't it be better to integrate the Controller and View into the
Model?
For example:
class Shape
{
virtual void Render(Surface *S);
virtual void Click(Point P);
virtual void Drag(Point P);
virtual void Release(Point P);
};
Now, new Shapes can be written at any time, and they take care of
themselves, simply being told when/where to render, and any mouse
actions that come their way.
I have Googled for this a lot, and read the C2 Wiki, but I still can't
find a decent resolution to this. Can anyone offer any advice?
Many thanks in advance.
Hugo Elias