2 ms·
Seems to me that if I've got a factory, I need some way to tell it what I want it to produce. That's either a string or an exemplar or some set of properties/f
by AnimalMuppet 13y ago
Seems to me that if I've got a factory, I need some way to tell it what I want it to produce. That's either a string or an exemplar or some set of properties/flags. Somehow, you have to say what you want.
Or have I not understood your pain?
- vectorpush 13y agoRight, and this is what happens in Go. I can use a string or struct as a signal for what type to produce, but I wish I could communicate that type in a "first class" way, rather than using another data type as a proxy signal. Check my reply to melvinmt for a more clear example of what I mean.
- AnimalMuppet 13y agoI'm still unclear on what you mean by "first class". In Java, you could pass in WeatherProvider.class to tell it that you want it to produce a WeatherProvider instance or a string that said "WeatherProvider". Is that the kind of thing you have in mind?
- vectorpush 13y agoI am not a Java programmer but the Java class literal seems like a perfect example. The class literal provides a language mechanism for representing a type of class (in Go's case it would be a type of struct) without the need for an actual instance of the class or another arbitrary data type (like a string or const) that the application is programmed to recognize as a signal for that class.