Reduce dependancy and coupling (best design pattern)?

public class CScoreBoardRow {
    private int m_score;
    private int m_rank;
    private string m_username;
}
public class CGameVersion {
    public string GetVersion() {
        return BackendServer.GetInstance().GetVersion();
    }
}
public class CScoreBoard{
    private string m_scoreBoardName;
    public CScoreBoard(string _scoreBoardName) {
        m_scoreBoardName = _scoreBoardName;
    }
    public int GetMyRank(string _userId) {
        int myRank= BackendServer.GetInstance().GetUserRank(_userId, m_scoreBoardName);
        return myRank;
    }
    public CScoreBoardRow[] GetScoreBoard(int _numRow) {
        CScoreBoardRow[] scoreBoardRows=new CScoreBoardRow[_numRow];
        scoreBoardRows = BackendServer.GetInstance().GetScoreBoard(0, _numRow,m_scoreBoardName);
        return scoreBoardRows;
    }
}

public class CServerTime {
    private uint m_currServerTime;
    public uint GetServerTime() {
        m_currServerTime= BackendServer.GetInstance().GetServerTime();
        return m_currServerTime;
    }
    public void UpdateCurrServerTime(uint _currServerTime) {
        m_currServerTime = _currServerTime;
    }
}

public class CServerController : MonoBehaviour {
    private static CServerController m_instance;
    private CScoreBoard m_scoreBoard;
    private CServerTime m_serverTime;
    public static CServerController GetInstance() {
        return m_instance;
    }
    void Awake() {
        if (m_instance == null) {
            m_instance = this;
        }
        m_scoreBoard = new CScoreBoard("UserRanking");
        m_serverTime = new CServerTime();
    }

    public CScoreBoardRow[] GetScoreBoard(int _numRow) {
        return m_scoreBoard.GetScoreBoard(_numRow);
    }
    public int GetMyRank(string _userId) {
        return m_scoreBoard.GetMyRank(_userId);
    }
    public uint GetServerTime() {
        return m_serverTime.GetServerTime();
    }

}

I have several questions.
If you want to implement servercontroller class that controls sent and received data,how do you do?
question1: you split it to several classes like scoreboard,servertime,version and etc classes and then create objects of these classes into servercontroller class?
or prefer to implement only one class servercontroller.
question2: you prefer to call scoreboard and other classes directly from another script like CScoreboardUI monobehaviour (create scoreboard object class and then call its functions)
or call servercontroller.GetInstance() functions.
question3:
you prefer to define numRow (GetScoreBoard(int _numRow)) as a parameter or field of the class.
and please refer one pro book to learn design pattern in game programming (reduce duplicate codes and coupling)
thanks in advance

Hi mahdii,
Make sure to use code tags when posting on the forums

1 Like

And actually write sentences explaining what kind of questions you have or feedback you want.

The best design pattern is the one that puts your game into the hands of users as fast as possible, IMNSHO.

2 Likes

No such thing as a super-pattern that is just the best.

Take a look and see what applies best to your circumstance.

so sorry, my explanations were cleaned and I put them to code quote
I correct them now

so cool :))))
I have so obsession about that