On Fri, 3 Sep 2010 09:51:44 -0400, Eric Frederich <[email protected]> wrote: > I constantly find myself with options like... > a) create a connection from foo's custom signal to bar's slot.... or > b) when creating the foo object, give it a reference to bar, and instead of > emitting a custom signal, just call bar's slot directly. > > What is more lightweight.... an instance variable or a connection? > > I'm sure this must be common. > Are there guidelines to use, rules of thumb etc?
Signals and slots are there to support the development of re-usable components by encouraging the decoupling of objects. So it comes down to a design decision regarding how much you want foo to know about bar. If, in your design, foo and bar are inherently tightly coupled and foo would never want to call anything other than bar then you might as well make a direct call. However, in programming you should never say never. On the other hand, if you can imagine a case where foo might be used with something similar to bar (but not bar itself) then define a signal and use connect(). Another thing to consider is if you can imagine a case where a third object would want to establish the relationship between foo and bar - again a signal is the way to go. Phil _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
