??Python??Java????????????
?????Pulpcode-??????? ???????[ 2017/1/9 11:02:59 ] ????????Python Java
?????????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()
??????
???路???
??????????????????
2023/3/23 14:23:39???写?貌??????????
2023/3/22 16:17:39????????????????????些??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???路???????路
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11