Python Dependency Injection
Copyright 2008, Google Inc Python Dependency InjectionAlex Martelli "levels" of this talk2ShuHaRiPyDP("Retain")("Detach")("Tr anscend") 3The novice goes astray and says, "The Art failed me."The master goes astray and says,"I failed the Art." Dependency Injection DP4Name: " Dependency Injection "Forces: an object depends on other concrete objects which it instantiates (or accesses as singletons, ...)we may want to control dependencies for all the usual good reasonsin particular, unit-testing may require mocking otherwise-concrete objectswe'll see examples & alternative solutions throughout the rest of this talkA simple schedulerclass ss(object): def __init__(self): = ().next = () def AddEvent(self, when, c, *a, **k): ((when, (), c, a, k)) def Run(self): while : when, n, c, a, k = () (when - ()) c(*a, **k) 5(A "side note")class PriorityQueue(object): def __init__(self): = [] def __len__(self): return len( ) def push(self, obj): ( , obj) def pop(self): return ( )6Fine, do you test ss without long waits?
Some issues with TM inheritance gives strong, inflexible coupling a customized-scheduler has complex, specialized extra logic far from ideal for either unit-testing or
Download Python Dependency Injection
Information
Domain:
Source:
Link to this page:
Please notify us if you found a problem with this document: