I know the difference between domain and application services. But it can’t see the difference between the methods in the domain entities and the domain services: /
I have a game that has State , Players , etc. It also has methods such as AddPlayer , MoveLeft , Jump . Where do these methods go? Should I create bare KOGame with only properties, and then KOGameServices with functionality?
Uncle Bob in his article here wrote: "An entity can be an object with methods or it can be a set of data structures and functions."
I don’t even want to mention that methods such as Move or Jump will have to be in App Services, in KOGameAPI - they force these methods to use the interface (via interfaces, of course).
Here is my class:
public class KOGame { public GameState State { get; set; } public IList<Player> Players { get; set; } public int PlayersCount; public KOGame() { State = GameState.New; PlayersCount = 2; Players = new List<Player>(); } public void AddPlayer(Player player) { } public bool MoveRight(int id) { return false; } public bool MoveLeft(int id) { return false; } public bool Jump(int id) { return false; } }
So, close my question: what methods apply to domain services and what methods apply to domain objects? Having, for example, the class Class1 , when should I create the class Class1Services ?
EDIT: Just a brief explanation of why I choose DDD : I want to create a cross-platform application, and I want one layer to be common for each platform. I choose C# , called using Xamarin . I can easily implement a single-user model and even services for each platform. I was just stuck in deciding which methods should go to Services and what as part of the objects in the Domain Model
source share