I am wondering what a service layer is in MVC. I like to understand concepts through a game of monopoly as it's relatable to a lot of people and fairly easy to explain whilst allowing for some good OOP and SOLID principles to be implemented . Can someone tell me if this is the job of a service layer in an example described here:
1- The controller responds to a user rolling a dice by calling a controller funciton named roll Dice.
2- Now when we roll the dice in monopoly a handful of things could occur. First the current square count of the players turn that it is needs to be updated. We then need to check if the player is in jail or not , we then need to see what square the player has landed on and give the user option etc etc. I have multiple classes for Dice, Board, Square, Player etc which all have very specific methods and as a result of these methods data is changed. I often pass dependancies via dependancy injection as either arguments to other methods or as properties when instantiating a new class to achieve polymorphism without needing if/else statements on multiple possibilities.
3- Although I have various methods which do one thing e.g. updateCount() or isPlayerInJail(), at some point these methods need to be put in a bigger piece of logic to all interact with each other. Originally I did this in the controller but found achieving polymorphism is impossible unless making new classes which hold data inside the controller ( which I obviously wouldn't want to do due to (SOC) ). So I then decided to do all my logic in the Model, where inside my controller I call a method on a class, and pass in dependancies. Now this method is always a lot bigger than all the other methods which only do one thing. Instead this method controls the logic of what happens sequentially when the player rolls the dice. 4. My final questions , is this larger method an example of a service, and this service should be called directly from my controller , the same as I do now , but instead of calling this method from inside the class directly from the model as a method, I should call it from the service layer , outside the class ? This service method will change data inside the model by calling its smaller methods ?
Each implantation works and whereas I accept a MVC pattern with a service layer is probably overkill for such a project, the concepts learnt I am happy will put me in good stead for a larger application where MVC is designed for Law and order.
Am I on the right lines here regarding what a service layer is used for ?