Python Advanced Programming: The guide to learn pyhton programming. Reference with exercises and samples about dynamical programming, multithreading, multiprocessing, debugging, testing and more. by Lioy Kevin

Python Advanced Programming: The guide to learn pyhton programming. Reference with exercises and samples about dynamical programming, multithreading, multiprocessing, debugging, testing and more. by Lioy Kevin

Author:Lioy, Kevin [Lioy, Kevin]
Language: eng
Format: epub
Published: 2019-10-30T16:00:00+00:00


# In class Undo

In the Stack.load() strategy we have utilized super() to call LoadSave.load() be-cause there is no Undo.load() technique to cause vagueness. In the event that both base class-es had a heap() strategy, the one that would get called would rely upon Python's technique goals request. We want to utilize super() just when there is no uncertainty, and to utilize the suitable base name generally, so we never depend on the technique goals request. For the self.clear() call, again there is no vagueness since just the Undo class has a reasonable() strategy, and we don't have to utilize super() since (in contrast to stack()) FileStack doesn't have an unmistakable() technique.

What might occur if, later on, a reasonable() strategy was added to the FileStack class? It would break the heap() strategy. One arrangement is call su-per().clear() inside burden() rather than plain self.clear(). This would result inthe first super-class' reasonable() strategy that was found being utilized. To ensure against such issues we could make it a strategy to utilize hard-coded base classes when utilizing numerous legacy (in this model, calling Undo.clear(self)). Or on the other hand we could stay away from different legacy inside and out and use collection, for test ple, acquiring the Undo class and making a LoadSave class intended for aggre-gation.

What different legacy has given us here is a blend of two rather dif-ferent classes, without the need to execute any of the fix or the stacking and sparing ourselves, depending rather on the usefulness given by the base classes. This can be helpful and works particularly well when the inher-ited classes have no covering APIs.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.