0

I have a class RoomDesign which holds information about the measurements and color of the room for example. I need to be able to render this same information in different ways by a different class. Such as display it graphically with a diagram, or just simple with text. What is the best pattern to use for this kind of design.

Suhaib Janjua
  • 3,452
  • 14
  • 56
  • 72
Nick
  • 1,229
  • 3
  • 30
  • 45

3 Answers3

2

You should look into the model-view-controller pattern.

The views would be your renderers (diagram, text etc.) and the model would be your RoomDesign class or maybe a container for multiple room designs.

Thomas
  • 84,542
  • 12
  • 116
  • 151
0

If you view your RoomDesign as the Model part of Model-View-Controller (MVC), it pretty much speaks for itself. Just keep in mind not to store any purely visual-specific information in your model.

Smutje
  • 16,951
  • 4
  • 21
  • 38
0

Build and design a room. Aside from model-view-pattern, you can take a look at Builder pattern. Here's a good SO reference.

An example.

Community
  • 1
  • 1
Sajal Dutta
  • 17,444
  • 10
  • 51
  • 74