Is there a design template that is recognized as the best model to use when decoupling the datamodel and the gui drawing engine?
So say that I have a Circle class and a Square class, then I will be tempted to have a draw method in both of these classes. However, this would force the class to import all kinds of unpleasant things, depending on the canvas they use (swing, j3d, opengl, etc.).
My first thought was that the visitor pattern could solve this by making Square and Circle an implemented method that accepts the visitor as an input argument and calls the visitor function. then I can have two drawing methods on the visitor that takes a Circle and Square instance as an input argument and draws them accordingly.
Any suggestions on this?
source
share