Closed antifun closed 9 years ago
@antifun
I don't think the use of instance variables in an interactor is necessarily a good practice or a bad practice; it's simply a part of the Ruby language that is available to the programmer if needed. As such, I don't think that it is necessary to call out instance variables explicitly in an example/test case.
Is it a good or bad practice to use instance-level attributes in an Interactor? (Why would you want to? Our current wish was to memoize an expensive lookup. We also use private instance methods to make the code more understandable. Combining these two techniques results in this desire.)
Currently, an Interactor instance's lifespan does not extend past its
call
-site. In other words, it works like we expect. If that ever were to change such that the instances were re-used, though, things might become...interesting.I can think of no reason at all why the lifespan of Interactor instances might be changed, but if using instance attributes is regarded as an acceptable practice, doing so somewhere in an example or test case would be a good way to make sure it's known to be acceptable.