Factory Pattern without a Switch or If/Then
How about this (no Dictionary required and note that you will get an syntax error if your try to Create<Position>()): EDIT – Updated to use an IPosition interface implemented explicitly. Only instances of IPosition can access the member functions (e.g. <implementation of Manager>.Title will not compile). EDIT #2 Factory.Create should return an IPosition not T … Read more