P
Peter Judge
Guest
A CASE statement is one way of doing it. I’ve also seen code that builds a string from “bank1” + some package (“app.banking.”) and then does a dynamic-new. You could also keep a JSON file or other config with with a mapping from a logical name to a class (type) name. { “app.banking.interfaces.bank”: { “bank1”: “app.banking.bank1”, “bank2”: “extensions.bank2”, “bank3”: “app.banking.bank3” } } If you do follow such an approach I STRONGLY recommend using interfaces pervasively in your code; it’ll make the calling code much cleaner. There are some approaches outlined in this presentation I did a couple of years ago: http://pugchallenge.org/downloads2015/417_Composing_Complex_Applications.pdf . In addition to that, you can look at a Service Manager component (see a spec at github.com/.../v1_0 ); this turns all of the above into its own component. hth
Continue reading...
Continue reading...