http://www.cs.unc.edu/~stotts/GOF/hires/pat3cfso.htmCreateMaze is the function which instantiates the objects. IMO, according to factory pattern we are not supposed to overload or modify or re-write the function which instantiates objects.But in the example, the CreateMaze function returns a Maze*. So, now if we have to write an EnchangedMaze class, will we have to re-write CreateMaze function to return a pointer of EnchantedMaze?From: http://www.cs.unc.edu/~stotts/GOF/hires/chap3fso.htmChanging the layout means changing this member function, either by overriding itwhich means reimplementing the whole thingor by changing parts of itwhich is error-prone and doesn't promote reuse.Isn't this what factory pattern wants to avoid?What point am I missing?
Aim of Factory pattern is to stop us from over-riding or re-writing the functions which instantiate?
factory method;factory