Formal name of Magento’s Class Override Design Pattern?

Posted by Alan Storm on Stack Overflow See other posts from Stack Overflow or by Alan Storm
Published on 2010-04-27T18:27:42Z Indexed on 2010/04/27 18:53 UTC
Read the original article Hit count: 176

Filed under:
|
|
|
|

Magento is a newish (past 5 years) PHP based Ecommerce system with an architecture that's similar to the Java Spring framework (or so I've been told)

One of the features of the Framework is certain classes are not directly instantiated. Rather than do something like

$model = new Mage_Foo_Model_Name();

you pass an identifier into a static method on a global application object

$model = Mage::getModel('foo/name');

and this instantiates the class for you.

One of the wins with this approach is getModel checks a global configuration system for the foo/name identifier, and instantiates the class name it finds in the configuration system. This allows you to change the behavior of a Model system wide with a single configuration change.

Is there a formal, Gang of Four or otherwise, name that describes this system/design pattern? The instantiation itself looks like a classic Factory pattern, but I'm specifically interested in the whole "override a class in the system via configuration" aspect. Is there a name/concept that covers this, or is it contained within the worldview of a Factory?

© Stack Overflow or respective owner

Related posts about php

Related posts about magento