I'm making a Java chess game as a uni project, and I'm basically getting the move from a player using a GUI.
My game has several classes, but the main classes are the Pieces, HumanPlayer and GraphicalDisplay classes.
What I'm basically doing is, when the HumanPlayer wants to make a move, it's currently using a class called PieceController, which is using a PieceModel class and the GraphicalDisplay classes as the model and view.
The problem is that I'm having to write code to set, for example, MouseListeners to certain cells in the chess grid (contained in an two dimensional array called cellHolder) in the Model class. This is because the code that contains adding listeners to cells also change state of the data, which is then used to display the game in the GUI.
This is causing a problem. The cellHolder object is created inside the GraphicalDisplay (GUI) class, but it's also used in the model and therefore the model is using data from the view.
I can't really think of another way of doing this without having to share (or pass as an argument) the cellHolder.
Any suggestions on how to improve the current MVC design?
Check this link http://www.tutorialspoint.com/design_pattern/adapter_pattern.htm
About Design Patterns In Java this one is called "the Adapter Pattern" .. It's basically a software design pattern that allows the interface of an existing class to be used from another interface