public void ExecuteAction(string command)

{

    if (command == "Jump")

    {

        Jump();

    }

    else if (command == "Run")
    {

        Run();

    }

    else if (command == "Attack")

    {

        Attack();

    }

    else if (command == "Defend")

    {

        Defend();

    }

    else

    {

        Console.WriteLine("Unknown command.");

    }

}


이렇게 있으면

public enum PlayerCommand
{
    Jump,
    Run,
    Attack,
    Defend
}

private readonly Dictionary<PlayerCommand, Action> dispatchTable;

public PlayerController()
{
    dispatchTable = new Dictionary<PlayerCommand, Action>
    {
        { PlayerCommand.Jump, Jump },
        { PlayerCommand.Run, Run },
        { PlayerCommand.Attack, Attack },
        { PlayerCommand.Defend, Defend }
    };
}

public void ExecuteCommand(PlayerCommand command)
{
    if (dispatchTable.TryGetValue(command, out Action action))
    {
        action();
    }
}

이런식으로

이게 훨씬 보기 편함