Note that there are some explanatory texts on larger screens.

plurals
  1. POGame player object design
    text
    copied!<p>I'm supporting a server for an online card game and while thinking about refactoring it into a better state I have found myself unable to decide what is a proper object model for my needs.</p> <p>I have a Player class which has a lot of attributes. The first problem is just that - the class is too big. The second problem is that I don't know how to refactor it. I will list some of the attributes and issues with these.</p> <p>Some attributes are very tightly bound to a player: nick, email, last login &amp;c. These, I suppose, are to be kept directly in the player class and in the same table in the DB.</p> <p>Now, some attributes are a little more difficult, like money and gold amount. The problem with these is that they are historically stored in a different table, there might be some more currencies later on and that they MUST be synched into the database at their own pace.</p> <p>Third category of attributes are loosely coupled to the player, like status string, experience, achievements, statistics &amp;c. These are stored in different tables in the DB and MUST be stored, retrieved, cached and synchronized at their own pace.</p> <p>Note that one of the big problems here is that we have to implement relatively complex database synchronization schemes because we have a lot of online players and our game is soft-realtime and we have to make load on the DB as low as possible.</p> <p>My questions are: </p> <ol> <li>How to determine which attributes to store within a player class and which not to? Say, experience, nickname, money amount?</li> <li>When one has some attributes that may be grouped together like (strength, agility, endurance, &amp;c.) and (handItem, headItem, feetItem, weapon) when they should be grouped and when not? </li> <li>What to do with complex database synchronization schemes? Make a separate model for each attribute that needs to be synched independently or make some DataManager classes to take them apart and work with them?</li> <li>What to do with the need for a class to have several different "data representations" for external consumers? Like XML, Json, another XML for some external service, human-readable string, &amp;c.</li> </ol> <p>I'm sorry if my questions are bogus, I'm not really good at OOP design, I'm more an FP guy. And my English is not very good =).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload