{"push_id":849815889,"size":2,"distinct_size":2,"ref":"refs/heads/Chp_21EnhancingTheReliabilityOfMediator-BasedCode","head":"88c9260c9a88241d260988e7fabc48db45f7444e","before":"60a12a9feb7bd10e537543b97a2d0b563a83caea","commits":[{"sha":"77a370a1a2cc93972d07cffba45c96f0103465dc","author":{"email":"688085edcac35a6f5d4cd9ba4db0e893cb0d2736@gmail.com","name":"petrero"},"message":"The mediatorContracts.js module created a mediatorForPlayer interface.\n  Now playerContracts.js can ensure that whenever a player is created, it gets such a mediator\n  The first two lines of the attachValidators method cause the mediatorForPlayer contract to be checked against the argument to\nGame.player :\nregistry.attachArgumentsValidator(\n  'player', Game, ['mediatorForPlayer']);\n  If something else is passed in, an exception is thrown. In return, player promises that it will return an object that meets the 'player' contract:\nregistry.attachReturnValidator(\n'player', Game, 'player');\n  That contract is a promise to provide the methods you saw in player :\n  function isPlayer(thing) {\n    return typeof thing === 'object' &&\n      typeof thing.getId === 'function' &&\n      typeof thing.setNode === 'function' &&\n      typeof thing.getNode === 'function' &&\n      typeof thing.activate === 'function' &&\n      typeof thing.deactivate === 'function';\n  }\n  Importantly, it is not a guarantee of an actual player object (using instanceof , for example). Contracts that use characteristics instead of types keep your code in the JavaScript “duck-typing” idiom. In fact, you have already seen how this was useful when creating the fakeMediator in playerSpec.js.","distinct":true,"url":"https://api.github.com/repos/pyterDiaconescu/ReliableJavascript/commits/77a370a1a2cc93972d07cffba45c96f0103465dc"},{"sha":"88c9260c9a88241d260988e7fabc48db45f7444e","author":{"email":"688085edcac35a6f5d4cd9ba4db0e893cb0d2736@gmail.com","name":"petrero"},"message":"downloaded contracts for normalPoint, gameNode, bot and gameLogic","distinct":true,"url":"https://api.github.com/repos/pyterDiaconescu/ReliableJavascript/commits/88c9260c9a88241d260988e7fabc48db45f7444e"}]}