Let's say I am making a video game. The player has an X and a Y coordinate, and these values are members of the Player object. Let us also assume I am using the hypothetical GAME-X game engine, which renders each object using the GX_x and GX_y values.
If I want to separate the domain (Player) from the view (GAME-X), it is my understanding that the player should have its own X and Y coordinates which are manipulated independently, and the GX_x and GX_y simply "listen" to the player's current coordinates. Doing this would allow me to, for example, choose a new game engine while leaving the domain layer untouched. It also means that the game can essentially run on a strictly domain level.
Is this a good design strategy? If not, why? If so, what is the real name for this strategy and how can I improve upon on it throughout my system?
player should have its own X and Y coordinates which are manipulated independently, and the GX_x and GX_y simply "listen" to the player's current coordinates.
That's correct strategy. Since GX_x, GX_y are presentation level and can be device / resolution / engine specific.
Consider 2 phones with 480*320 and 960*640 resolutions. x,y in your model should be the same (the same code running in both phones) whereas GX_x and GX_y will be different on both devices.
It is Model View Controller pattern you're talking about.
choose a new game engine while leaving the domain layer untouched. It also means that the game can essentially run on a strictly domain level.
These are advantages and reasons for the pattern to be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With