Showing results for 
Search instead for 
Did you mean: 

Magento Prototype pattern implementation

Magento Prototype pattern implementation

I'm wondering how Magento uses Prototype pattern. I know that Mage::getModel('catalog/product')->getTypeInstance for example uses prototype pattern with factory() function somehow. However Isn't Prototype pattern used to make clone of instances and use those for better performance? I've tried to look the source code and figure out how this works and how I can represent it as an UML diagram but without success.


This is one of the articles that I've read about Magento's Prototype pattern:


Here's also an example of usual implementation of Prototype pattern:


So I really can't understand how Magento's Prototype pattern is the same as the usual Prototype pattern. They look completely different. Magento's Prototype pattern looks more like a Factory Method pattern. I have the same problem with Magento's Observer pattern, although that's a lot more clear than this one.

I would really appreciate your help with this one. This would also help me understand more how Magento works.