Julian is right that we still will create many CallCopyingArgHandler instances though SqlShuttle is a sington. I created a subclass QueryTemplatizer which extends SqlShuttle but overrides visit(Literal or Interval) methods only, I make it a singleton in DI context so that I don't need to create it explicitly. This is just my case, I don't know whether others have or not. Another consideration is that inner classes have the risk of memory leak when others use elsewhere incorrectly, I always avoid using them unless it has a private scope.
Vladimir Sitnikov <[email protected]> 于2021年6月26日周六 上午2:37写道: > Julian>I’m not a fan of dependency injection. .... But it requires mutable > fields. > > On contrary, DI does not require mutable fields, and field injection is > considered an anti-pattern in production code. > For example, see > https://github.com/google/guice/wiki/Injections#constructor-injection > > I do not see how DI could help with SqlShuttle though. > > Vladimir >
