flashapache-flexmodel-view-controllercommandrobotlegs

RobotLegs Domain logic - where to place it


In Robotlegs does the domain logic needs to be in the Commands(controller) or the Models?

Example: lets say i'm building a "Tic Tac Toe" game. i have: GameMadiatore,CellSelectedCommand,BoardModel.

After the user clicks on a cell the "GameMadiatore" fires an event that initiates "CellSelectedCommand". Does the "find 3 in row" win logic needs to be in the "BoardModel" or "CellSelectedCommand" or some other command?


Solution

  • I would advise you to create atomic commands.

    This means a command should do 1 thing and 1 thing only. This allows you to easily rewire your application logic without refactoring too much later on.

    In the case described above your thinking is correct another command will do just fine. For example:

    Some more principles about MVCS:

    Cheers