nirbhab.com

Recent Article

2008-07-04

First, you need the framework, so go to http://fra..

more

2008-06-30

  Design patterns As a developer, I have star..

more

Design Pattern

 

Design patterns

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:

1.       Value object pattern

2.       Factory pattern

3.       Singleton pattern

4.       Registry pattern

5.       Mock object pattern

6.       Strategy pattern

7.       Iterate pattern

8.       Observer pattern

9.       Specification pattern

10.   Proxy pattern

11.   Decorator pattern

12.   Adapter pattern

13.   Active record pattern

14.   Table data gateway pattern

15.   Data mapper pattern

16.   Model- View-Controller pattern

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.

Comment

Donations For Us

Pic 2

  • Codeigniter
    CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. If you're a developer who lives in the real world of shared hosting accounts and clients with deadlines, and if you're tired of ponderously large and thoroughly undocumented frameworks.
  • JQuery
    JQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript.
  • Joomla
    Joomla! is an award-winning Content Management System (CMS) that will help you build websites and other powerful online applications. Best of all, Joomla! is an open source solution that is freely available to everybody.
  • Ajax
    Ajax (asynchronous JavaScript and XML), or AJAX, is a group of inter-related web development techniques used for creating interactive web applications. A primary characteristic is the increased responsiveness of web pages achieved by exchanging small amounts of data with the server "behind the scenes" so that entire web pages do not have to be reloaded each time there is a need to fetch data from the server. This is intended to increase the web page's interactivity, speed, functionality and usability.
  • PHP
    PHP (a recursive acronym for PHP: Hypertext Preprocessor) is a computer scripting language, originally designed for producing dynamic web pages. It is for server-side scripting, but can be used from a command line interface or in standalone graphical applications.
  • JSON
    JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

API Gallery