【发布时间】:2013-06-25 21:32:34
【问题描述】:
我正在尝试使用 S.Lott 的 response 构建一个策略模式。
问题是函数返回 None。
我正在使用 Hickey 的 Simple vs Easy {what、how、who}-逻辑。
-[什么] I/O
class base_fnc(object):
def fncExc(self,data1,data2):
return
-[HOW] DATA queue[where,when](直接注入)
class stump( base_fnc ):
def fncExc(self, d1, aContext):
return d1
class MAB(base_fnc ):
def fncExc(self, d, aContext ):
return d+10
-[WHO] API
class context( object ):
def __init__(self, alt_how_class ):
self.how = alt_how_class
def exc(self, d ):
return self.how.fncExc(d, self)
if __name__ == "__main__":
c1 = context(MAB())
ss=c1.exc(10)
print ss
ss 打印无
【问题讨论】:
-
投反对票,因为这不太可能对其他人有用。无意冒犯。