Hi suppose a game needs two parts a backend server and frontend (client). The server sends json strings and contains controllers and logics of the game while the client section is responsible for views. The question is that I need two type of classes to handle them? One type is classes that correspond to json strings (classes defined in the server) received from the server and the another one is classes that we need to use them to illustrate information.
Example: The class below corresponds to server js class sent as json format to the client side
[System.Serializable]
public class UserData{
public int gem;
public int coin;
public int level;
public int score;
public int cup;
public bool hasShield;
public int shieldLeftTime;
//....
}
But I do not want to show all of them in one page for example. So I need to break them to several smaller classes like below:
public class UserAsset{
public int gem;
public int coin;
}
public class UserLevel{
public int level;
public int score;
}
public class Shield{
public bool hasShield;
public int shieldLeftTime;
}
Also maybe I need to show only level of a user and shield status in other page or panel! So I need to create a new class?!
public class Class{
public int hasShield;
public int level;
}
or I need to match the classes in both server side and client side both smaller and suitable classes and prevent to create extra classes?
And my second question is about that the classes can have functions or not, they are only data structures.
How approach do you follow? thanks