这个模式我在书上(JavaScript设计模式)的那个章节来来回回看了几遍,有两个关键点并没有说清楚,导致尽管表面上是很简单明了,但本质没有说清,以下是书上的例子。书中淡解例子(改前):var carManager = { // request information r ...
这个模式我在书上(JavaScript设计模式)的那个章节来来回回看了几遍,有两个关键点并没有说清楚,导致尽管表面上是很简单明了,但本质没有说清,以下是书上的例子。
书中淡解
例子(改前):
var carManager = { // request information requestInfo: function( model, id ){ return "The information for " + model + " with ID " + id + " is foobar"; }, // purchase the car buyVehicle: function( model, id ){ return "You have successfully purchased Item " + id + ", a " + model; }, // arrange a vieget='_blank'>wing arrangeViewing: function( model, id ){ return "You have successfully booked a viewing of " + model + " ( " + id + " ) "; }};carManager.arrangeViewing("Ferrari", "14523" );carManager.requestInfo("Ford Mondeo", "54323" );carManager.requestInfo("Ford Escort", "34232" );carManager.buyVehicle("Ford Escort", "34232" );
原标题:设计模式(七):命令模式
关键词:设计模式
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。