?????????Hystrix???胁?????????????????????????????????????web?????泻????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????oop?????槎�???????????
?????????????????
????????????????????????????????
???????????????????????????锟�?
????????????????A??B??C…?????X??Y??Z…??????????????????????A??B??C?????X??Y??Z??????????A??B????????????薪????F1??F2??F3??????薪???????????????X??Y??Z???????????????A??B??C????????????X??Y??Z?????????????F1??F2??F3???????????F??????????睢�
?????????????????些???????????谩?????A??B??C??X??Y??Z???????A??B??C????????????????????????????????????????????????????????????????Command??execute?????
????????????????F1??F2??F3?????X??Y??Z???????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????(undo)??????(redo)??hystrix?卸??????????????????????????????????写?????????????泄???????????????????????????????????????????????????????????????????????????????????????
???????????????????????????谓????????????????MenuItem????????????client????????????????command?????小?

????java???
public interfaceICommand{
publicvoidExecute();
}
public classCopyCommandimplementsICommand{
publicvoidExecute(){
xxxx
xxxx
}
}
public classPasteCommandimplementsICommand{
publicvoidExecute(){
xxxx
xxxx
}
}
public Class MenuItem{
private ICommand command;
publicvoidClicked(){
this.command.Execute();
}
}
????python???
??????python????????????????????????????????”???”?????????????????????????????????????? call ??????
????# ??????????????????????????????????睢�
classCommand(object):
def__init__(self?? do?? undo):
assert callable(do) and callable(undo)
self.do = do
self.undo = undo
def__call__(self):
self.do()
command = Command()
command()
# ????????????
classMacro(object):
def__init__(self):
self.__commands = []
defadd(self?? command):
self.__commands.append(command)
def__call__(self):
for command in self.__commands:
command()
do = __call__
defundo(self):
for command in reversed(self.__commands):
command.undo()