Looking to see if anyone had any suggestions... I have a parse tree and what I've been doing is walking over the tree and for each different type of element in the parse tree i've been creating a simple data structure in my code. Each element creates a different data structure, most of which take a different set of parameters, so using a default constructor doesnt work, the constructors usually take a few args most of which are annotated w/ @Assisted.
So I made a factory interface w/ methods matching the signatures of all the different constructors for the parts annotated w/ @Assisted and I use FactoryModuleBuilder to glue the factory methods to the classes they're supposed to create. This works well, albeit a little cumbersome -- I partially just wanted to have a working example of using FactoryModuleBuilder. What I want now is to have some extensibility available to users. I'd like them to be able to override the default implementations for some things, but I don't see how that'd be possible with the FactoryModuleBuilder -- maybe it is and that's the answer. But I figured I would have to take it apart and use a different approach. There's currently 18 methods on the main factory. If I stop using FactoryModuleBuilder, given that all the methods/constructors are using @Assisted, I'm not sure how I'd re-organize things. I think I'd still need something like FactoryModuleBuilder given the use of @Assisted, but then I'd have 18 interfaces instead of one, which doesn't seem ideal. The objects are all immutable, so I can't call setters to provide the values that would normally be provided into the constructor. I don't mind writing parts of the factory code by hand, I figured I could get Guice to provide me an acceptable injector to create instances from, but I'm still left w/ the non-default constructors that I need to call. Anyone done anything similar to this and can share their thoughts? Thanks. -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
