|
As a developer, I have started my programming since 2006, after 1 years, I found that the applications which I developed had a certain in common, means I had some place for libraries, style sheets. I use to send my output to certain files to render, then I realized that there is a designing of some sort of pattern of mine was developed.
There comes a question in my mind. Is there any other design too by other developers?
Yes there was. I was too far from other experts in the industry in design architecture.
There were many patterns some of them are listed below:
- Value object pattern
- Factory pattern
- Registry pattern
- Mock object pattern
- Singleton pattern
- Strategy pattern
- Iterate pattern
- Observer pattern
- Specification pattern
- Proxy pattern
- Decorator pattern
- Adapter pattern
- Active record pattern
- Table data gateway pattern
- Data mapper pattern
- Model- View-Controller pattern
![Design Pattern [image powered by Joomla] Design Pattern](/images/stories/joomla_mvc-diagram.png)
Among the listed ones the model view controller pattern and singleton patterns are very popular.
You must be thinking why should I implement any of the design architecture, I have a very small query before I answer your query. Why we ask architecture to design our houses or colonies etc. now the answer to the query is that, in any software development cycle, maintenance costs the most. So we as a developer try to do the task in a tougher and complicated way but when it comes to maintenance its cost comes to be lesser than estimated.
Codeigniter and other frameworks like zend and cakephp are built on MVC architecture. Codeigniter framework uses singleton pattern so that different database experts could make a common class that extends the abstract class to fulfill the database independent framework. It too have an active record class, I haven’t gone so far that this framework have adopted the active record pattern or not but as the names suggests it should have.
Model–View-Controller
My friend had asked me once, why it is called MVC, why not VCM or CVM?
I still don’t have answer to this question.
In web applications MVC pattern is widely used and followed different PHP frameworks.
- Model: it consist of your applications dataflow and business logic
- View: It formats the model's data
- Controller: It directs the application flow
There are many ways to adopt the MVC pattern.
It all depends upon your way. But as discussed above, the request comes to the controller and it asks the model to perform the task, and tells View to render the GUI, this data flow between view and model is controlled by controller.
If not heard off but let me introduce PEAR and Smarty here to explain the concept, in broader sense.
PEAR_DB has the whole database layer, working as Model and Smarty, the best template engine on internet, acts as View. So where is controller, controller is the PHP files, which are calling PEAR_DB class for logic’s and enabling Smarty engine to render the GUI of the application.
|