Re: adding a simulation mode

Discussion in 'Python' started by andrea crotti, Jul 5, 2012.

  1. 2012/7/5 Dieter Maurer <>:
    >
    > There is a paradigm called "inversion of control" which can be used
    > to handle those requirements.
    >
    > With "inversion of control", the components interact on the bases
    > of interfaces. The components themselves do not know each other, they
    > know only the interfaces they want to interact with. For the interaction
    > to really take place, a component asks a registry "give me a component
    > satisfying this interface", gets it and uses the interface.
    >
    > If you follow this paradigm, it is easy to switch components: just
    > register different alternatives for the interface at hand.
    >
    >
    > "zope.interface" and "zope.component" are python packages that
    > support this paradigm. Despite the "zope" in their name, they can be
    > used outside of "Zope".
    >
    > "zope.interface" models interfaces, while "zope.component" provides
    > so called "utilities" (e.g. "database utility", "filesystem utility", ...)
    > and "adapters" and the corresponding registries.
    >
    >
    > Of course, they contain only the infrastructure for the "inversion of control"
    > paradigm. Up to you to provide the implementation for the various
    > mocks.
    >



    Thanks that's a good point, in short I could do something like:


    class FSActions:
    @classmethod
    def copy_directories(cls, src, dest)
    raise NotImplementedError

    @classmethod
    ....

    And then have different implementations of this interface. This would
    work, but I don't really like the idea of constructing interfaces that
    provide only the few things I need.

    Instead of being good APIs they might become just random
    functionalities put together to make my life easier, and at that point
    maybe just some clear mocking might be even better..
     
    andrea crotti, Jul 5, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. andrea crotti

    adding a simulation mode

    andrea crotti, Jul 4, 2012, in forum: Python
    Replies:
    4
    Views:
    224
    Paul Rubin
    Jul 4, 2012
  2. Mike C. Fletcher

    Re: adding a simulation mode

    Mike C. Fletcher, Jul 4, 2012, in forum: Python
    Replies:
    0
    Views:
    177
    Mike C. Fletcher
    Jul 4, 2012
  3. Devin Jeanpierre

    Re: adding a simulation mode

    Devin Jeanpierre, Jul 4, 2012, in forum: Python
    Replies:
    0
    Views:
    197
    Devin Jeanpierre
    Jul 4, 2012
  4. Dieter Maurer

    Re: adding a simulation mode

    Dieter Maurer, Jul 5, 2012, in forum: Python
    Replies:
    0
    Views:
    178
    Dieter Maurer
    Jul 5, 2012
  5. andrea crotti

    Re: adding a simulation mode

    andrea crotti, Jul 12, 2012, in forum: Python
    Replies:
    11
    Views:
    425
    Chris Angelico
    Jul 13, 2012
Loading...

Share This Page