So I am making a 2D board game using the MVC pattern, and want to use the Observer-Observable pattern too. The game consists of one player moving around a map.

My idea : In my model, I have a class Board, which basically constists of an array of instances of the class Tile. In my view, I plan to do the same : a class BoardRenderer, composed of instances of the class TileRenderer. I want to this so that after each turn, I don't have to update the whole board view, but just the two tiles concerned by the move.

My questions :

  • does this seem like a good approach ?
  • the Observer-Observable design would suggest to make the Board class extend Observable and the BoardRenderer class implement Observer. But then the update method would be a bit nasty to update only two tiles, wouldn't it ?
  • or would it be better that each Tile be an Observable, and each associated TileRenderer instance an Observer ? But this is maybe more memory consuming and less in the philosophy of the pattern ?

I guess this is a pretty general question, so it will probably be useful for later reference.

Related posts

Recent Viewed