SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    May 2007
    Location
    West Midlands, UK
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    The Most Common Pattern For Web App. Development?

    Whats the most common design pattern for web application development? I heard it was MVC but are there any others?

  2. #2
    SitePoint Guru
    Join Date
    May 2005
    Location
    Finland
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A half-assed implementation of Model-View-Controller with no actual oversight to their separation.

  3. #3
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your question doesn't really make sense. There is not a fixed number of patterns, and they do not exclude each other. I could claim that "using a dynamically typed programming language" is a design pattern. That is quite a common choice for web applications.

    What you might want to ask, is perhaps what alternatives there are to using the MVC pattern for structuring a web application. That question is much more specific and could actually be answered in a meaningful way (Even if it's still impossible to answer it in full).

  4. #4
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not really sure there is any most common design pattern. I guess you could say MVC with all the recent craze over it, but it doesn't really work that way. Most MVC frameworks have ActiveRecord and/or DataMapper patterns in their Model layer which use Adapters for different databases, whose Controllers are put together with Composites, Decorators, and Factories, which use a Chain of Responsibility and Iterators to execute chunks of code in a certain order, etc, etc.

    Design patterns were meant as ways to solve complex problems, and you will rarely ever seen just one pattern used in isolation, which would make it extremely hard to pinpoint just one pattern as the most popular. The natural flow of programming should be to code until you encounter a problem which a design pattern could make simpler instead of looking for a design pattern and fitting your code around it.

  5. #5
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    Some of the other common patterns - not mentioned by Kyber, Ezku, or Czaries are:

    Adapter: Allows classes to support a known interface so new classes can be used without refactoring old code.

    Decorator: Used to attach dynamically responsibilities to an object.

    Application Controller: A central point for handling navigation for an applications - many times this is done in an index.php file with query parameters dispatch.

    View Helper: Used to help collect data from the Model for the view.

    Builder: Used to help facilitate complex object initialization state.

    Table Gateway: Provides access to multiple rows in a database table. In between the ease of use of Active Record and the complexity of Data Mappers.

    Front Controller (also called a router): Handles all requests for your application - most people just allow apache (or IIS) to act as their front controller.

    Observer: Used to create Publish/Subscribe behaviour. Typically uses event based notification.

    Specification: Used to flexible evaluate objects against dynamic criteria.

    Iterator: Used to simplify the manipulation of a collection of objects.

    Registry: A place that holds references to objects. This can be as simple as an array or it can use a combination of a factory and a object storage array. Many heated discussions on this one. Have to be very careful because it can become no better than using global variables all over the place; however some people use registries very effectively when they keep them protected and to on class or being passed.

    Template View and Template Method: Two different ways to wire up your views.

    Hope this helps.

    ServerStorm
    ictus==""

  6. #6
    SitePoint Addict
    Join Date
    Feb 2007
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One correction to ServerStorm's list.

    Template Method is about encapsulating the invariant aspects of an algorithm inside a class method and calling subclass methods to carry out the variable aspects. In other words, it's a way to protect a class from its subclasses.

    PHP Code:
    abstract class Base {
        public final function 
    doSomething() {
            
    $this->stepA();
            if (
    $someCondition) {
                
    $this->stepB();
            }
        }
        abstract protected function 
    stepA();
        protected function 
    stepB() {
            
    // default behavior
        
    }
    }

    class 
    Sub extends Base {
        protected function 
    stepA() {
            
    // required behavior
        
    }

    I suspect ServerStorm meant Transform View in any case.

  7. #7
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If all you are posting is a list of definitions, at least provide a good link
    http://en.wikipedia.org/wiki/Design_...Classification

  8. #8
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    Hey Czaries,

    If all you are posting is a list of definitions, at least provide a good link
    Yea that would have been a whole lot easier, wouldn't it! Well I was seeing how good I could do at remembering, and well, I guess not so good, right Cuberoot?

    I suspect ServerStorm meant Transform View in any case.
    Yup

    Regards,
    ServerStorm
    ictus==""

  9. #9
    SitePoint Evangelist
    Join Date
    Aug 2005
    Location
    Winnipeg
    Posts
    498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Without a dought it's template separation first, then maybe registry then MVC.

    Most people keep global data in a $_GLOBAL variable even newbies. Although not a strict registry implementation, the concept is the same as it's passed around an application or accessed directly -- the latter of which is what a registry object would hopefully prevent.

    Most patterns are already utilized by developers with several years experience. You learn them through osmosis as you write software.

    What is nice about GoF and Fowler is that they formalized/standardized them...gave them official names and now make it easier for developer to communicate in our own vocabulary.

    Now instead of saying things like: "I implemented a system configurator and page requester delivery agent"

    You can now say: "I implemented the bootstrap and front controller"

    However because most people don't familiarize themselves with patterns, the next project you work on you will likely hear: "I implemented the initialization engine and request builder"
    The only constant in software is change itself


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •