Magento: Design Patterns

Magento Design Pattern
Magento Design Pattern

The list of design pattern Which Magento used.

  • Model/View/Controller

Magento follow Model/View/Controller design pattern.

  • Singleton

Ensure that only one instance of a class is created and Provide a global access point to the object.

$category = Mage::getSingleton('catalog/session');
  • Factory

Creates objects without exposing the instantiation logic to the clientand Refers to the newly created object through a common interface.

$product = Mage::getModel('catalog/product');
  • Registry

It will provide you one way to store your information throughout your application.

$currentCategory = Mage::registry('current_category');
  • Prototype

Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.

Mage:getModel('catalog/product')->getTypeInstance();
  • Event/Observer

Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

Mage::dispatchEvent('model_load_after', $params);
  • Object Pool

Reuses and shares objects that are expensive to create.

$id = Mage::objects()->save($object);
$object = Mage::objects($id);
  • Iterator

Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Mage::getModel('catalog/product')->getCollection();
  • Vew Helper

It will react as a to access the helper classes.

Mage::helper('core');
  • Null object

Provide an object as a surrogate for the lack of an object of a given type. / The Null Object Pattern provides intelligent do nothing behavior, hiding the details from its collaborators.

$collection->getFirstItem();
  • Decorator

Aadd additional responsibilities dynamically to an object.

<script type="text/javascript">
     decorateTable('product_comparison');
</script>

Hope you  like article. Thanks for reading.

Advertisements

One thought on “Magento: Design Patterns

Leave your comments

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s