The one you mean is called "Factory Method Pattern" in the Gang of Four book. The other one should be called "Simple Factory" or something like that.
They are very different things which unfortunately have very similar names.
They are very different things which unfortunately have very similar names.