Sep 7, 2018 · 1 min read
Thanks Carsten Führmann for the thoughtful response. Your point about loose coupling is a good one, and indeed, if you’re writing object oriented code then you should probably be relying on polymorphism rather than type checking to dictate how your objects act. I think there is an argument to be made for the value of occasional type checking but one shouldn’t rely on it in all situations. For that reason, the factory pattern is definitely a good option in many cases (even if it does have some downsides.)
