In my project,I use the mvc concept when do the UI related operation.
For example,there is a model named “Map”,then there is another object “MapView” along with “Map” object.
Now I create them this way:
function Map(){
//other codes.
this.view=new MapView(this);
}
function MapView(model){
//other code
this.model=model;
}
Now both the model and view have a reference to each other.
I wonder this is the best practice?
Will this cause performance problem?
There is nothing wrong performance wise (it might slow down on IE3 or NN4 though).
However it seems bad to have a bidirectional reference from a design view point.
You may want to use reference passing instead like
MapView.render(model)