Skip to main content
Typos
Source Link
metacubed
  • 976
  • 5
  • 14

You are trying to merge two levels of functionality into a single class. That is almost guaranteed to cause a mess in your design. Instead, how about this:

Create another set of classes parallel to the VisualEventEvent classes. Each xxVisualEventxxVisualEvent will have a coresponding xxVisualEventRenderercorresponding xxVisualEventRenderer that encapsulates its rendering/display logic. These classes know about both the Model and the View and are essentially extensions of the Controller.

Create a Mapper class (basically a factory), which takes in a VisualEventVisualEvent and creates a VisualEventRendererVisualEventRenderer based on the type. Yes, this means a type-based switch, but it isthe class has no logic other than to construct Renderer instances.

Then you can call the Render/Draw method on these Renderer classes instead of on the VisualEventEvent classes. You retainswill retain all the advantages of your approach, such as the loose coupling, etc.

You are trying to merge two levels of functionality into a single class. That is almost guaranteed to cause a mess in your design. Instead, how about this:

Create another set of classes parallel to the VisualEvent classes. Each xxVisualEvent will have a coresponding xxVisualEventRenderer that encapsulates its rendering/display logic. These classes know about both the Model and the View and are essentially extensions of the Controller.

Create a Mapper class (basically a factory), which takes in a VisualEvent and creates a VisualEventRenderer based on the type. Yes, this means a type-based switch, but it is has no logic other than to construct Renderer instances.

Then you can call the Render/Draw method on these Renderer classes instead of on the VisualEvent classes. You retains all the advantages of your approach, such as the loose coupling, etc.

You are trying to merge two levels of functionality into a single class. That is almost guaranteed to cause a mess in your design. Instead, how about this:

Create another set of classes parallel to the Event classes. Each xxVisualEvent will have a corresponding xxVisualEventRenderer that encapsulates its rendering/display logic. These classes know about both the Model and the View and are essentially extensions of the Controller.

Create a Mapper class (basically a factory), which takes in a VisualEvent and creates a VisualEventRenderer based on the type. Yes, this means a type-based switch, but the class has no logic other than to construct Renderer instances.

Then you can call the Render/Draw method on these Renderer classes instead of on the Event classes. You will retain all the advantages of your approach, such as the loose coupling, etc.

Source Link
metacubed
  • 976
  • 5
  • 14

You are trying to merge two levels of functionality into a single class. That is almost guaranteed to cause a mess in your design. Instead, how about this:

Create another set of classes parallel to the VisualEvent classes. Each xxVisualEvent will have a coresponding xxVisualEventRenderer that encapsulates its rendering/display logic. These classes know about both the Model and the View and are essentially extensions of the Controller.

Create a Mapper class (basically a factory), which takes in a VisualEvent and creates a VisualEventRenderer based on the type. Yes, this means a type-based switch, but it is has no logic other than to construct Renderer instances.

Then you can call the Render/Draw method on these Renderer classes instead of on the VisualEvent classes. You retains all the advantages of your approach, such as the loose coupling, etc.