?????????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()