Recently I had a discussion with a friend of mine about usefulness of choreography and orchestration in service-oriented (SO) environment. One of examples we analysed was just a chess game. Quite interesting about it was the fact that we looked at it from different points of view: one of us considered that the chess game is a good example of choreography while another one saw a good example of orchestration in the same chess game.
From the choreography perspective, the players were services that had the same common goal - win the game. Certainly, both players shared the same game rules, e.g., how the pieces move. The pieces were used as messages that the services exchanged in the game, i.e. in the service collaboration.
From the orchestration perspective, the pieces were the services. Each service had its own capabilities defined by the game's rules about how each type of the pieces can move, 'beat' another piece and even become promoted into another piece (for pawn and queen). The business functionality of the services was move and beat the 'enemy' if met. The players were viewed as the orchestrating entities that commanded the service the next invocation and other directives, e.g. where to move to. That is, the players performed as two independent processes concurrently working against each other for the same goal - the game victory.
I am telling you this story to illustrate that even for such well known thing as chess game, the analysis and definition of what service is for particular situation is the must have thing. Continuing with the analysis, a few questions were set against each approach.
For choreography:
• Can we consider competition for the game victory as service collaboration in resolving the same task? My answer is - NO, those services did not share the same goal, they had individual goals, the victory for themselves
• Can we consider that sharing the game rules is the same as sharing the targeted collaboration (required by the orchestration via 'global' contract)? My answer is - NO because knowledge of the game rules does not specify any ordered steps toward the collaboration goal, every player/service performs moves (message sending) based on personal plans and situation analysis. What they are going to do in each next step is unknown.
• Can we consider the pieces as messages that the services exchanged? My answer is - NO. If pieces were messages, they were not 'exchanged' between services but rather were 'sent to the game' and changed the state of the game, which reflected on the situation to be analysed for each next move.
So, I do not find choreography as an adequate model for the chess game. Let see how orchestration model is doing:
• Did an execution of a service/piece produce a Real World Effect (result)? My answer is - YES. The result was in the change of the state of the position/situation on the chessboard observable to all.
• Did services/pieces operate in collaborations? My answer is - YES though separately for the white and black capms. Each service did not need to know how to collaborate; this knowledge was externalised into the orchestrating entity (the player's mind) but all services acted toward the same common goal - the game victory
• Did the services exchange messages in these collaborations? My answer is - YES though not directly with each other. The messages about new piece position and about event of being captured by the 'enemy' were sent to the position/situation on the chessboard where each orchestrating entity acquired the information from for the decision about the next move.
Thus, an orchestration represents a pattern of collaboration without direct interactions between collaborating participants. Instead, they interact, explicitly or implicitly, with the orchestrating entity. The most important thing about such model is that all participants act toward the benefit of the same shared goal, this is what a collaboration is about.














Leave a comment