saraaaaras / Redo-YYY-New

0 stars 0 forks source link

Definition of Variable and Hard Code #7

Open PCRedHot opened 1 year ago

PCRedHot commented 1 year ago

https://github.com/saraaaaras/Redo-YYY-New/blob/7d2da933fc6a144d62eb12a0f94cc54c3e474cad/Assets/Inport/script/GameEngine.cs#L411-L418

Ok, a few problems here.

  1. State management problem, using colour as the state.
  2. Definition of the variable problem. You saved several Buttons in conditionButton variable, but they should have the same property / usage / role in the system. But here you wrote
    for (int j = 9; j < 11; j++)

    Where do 9 and 11 come from? It appears to me the role of the buttons are not the same, which I would separate them in different variables. 9 and 11 here are known as hard coding (not generalised).

Hard coding problem also found here https://github.com/saraaaaras/Redo-YYY-New/blob/7d2da933fc6a144d62eb12a0f94cc54c3e474cad/Assets/Inport/script/GameEngine.cs#L425-L439 6 should be the number of dice, don't you have the variable for that?

PCRedHot commented 1 year ago

Actually, you have been hard coding all the way, for example https://github.com/saraaaaras/Redo-YYY-New/blob/7d2da933fc6a144d62eb12a0f94cc54c3e474cad/Assets/Inport/script/GameEngine.cs#L453

For another developer, s/he would have no idea what conditionButton[10] refers to. Why are we checking this Button at index 10?

The improvement to this depends very much on the structure of the game, so i cannot give a improvement right away