
A Database Model for Simple Board Games - pai1009
http://www.vertabelo.com/blog/technical-articles/a-database-model-for-simple-board-games
======
lewisl9029
I personally prefer a more data-oriented approach to modeling, as opposed to
modeling in terms of objects and relations. One of my favorite videos from
Clojure Conj last year talks about the approach in more detail and contrasts
it with traditional OO modeling in the context of a board game:

[https://youtu.be/Tb823aqgX_0](https://youtu.be/Tb823aqgX_0)

In summary, modeling the board game with data (state) and pure functions
(state transitions) had significant benefits over the alternative OO style
model in terms of the overall simplicity of the model. The OO modeling
approach resulted in a model that consisted of 22 classes, 11 interfaces, 1
enum, and 271 lines of boilerplate code just to implement the classes and
relationships alone, with no game logic whatsoever. On the other hand, the
data-oriented approach produced an entire working implementation of the game
logic in 144 lines using 31 functions (small and highly composable functions,
longest of which was 7 lines).

My takeaway was that modeling in the traditional OO style can be a helpful
process in getting a good feel for your problem domain at a high level, but
trying to immediately translate the resulting relationship model into code is
not necessarily a good idea, because the classical OO relationship model is
inherently highly complected, and will bring that complexity straight into
your codebase if you try to translate it word-for-word. Taking the insights
from your relational model and using it as a guide to help model your problem
domain as data and functions usually results in a much simpler codebase, and
in turn, a much more robust and predictable application.

~~~
octagonal
Thank you for that link, super interesting! It made me interested in trying
out Clojure and seeing what it's all about.

------
eridal
_> We know which player starts first. After that, players move alternately._

During my teen ages I really enjoyed playing _truco_ , which is a card game in
which player turns are decided upon the previous hand's result.

[https://en.wikipedia.org/wiki/Truco](https://en.wikipedia.org/wiki/Truco)

------
iblaine
The vertabelo.com spam on reddit.com/r/database can now be found on
hackernews...it's a cool product and all but seriously...spam is spam...

~~~
DanBC
I think it's a good idea to email this kind of thing to HN.

Here vertabelo links are submitted only by one or two people; and this
submitter moslty submits only vertabello links. I think that's the kind of
thing dang is interested in.

(But I'm not sure).

------
jonbarker
Not interested in supporting Go? Would be great timing with the AlphaGo
tournament!

------
jasondc
I would love to see the document model for the same board games, compared to
relational.

