Design Patterns ?

Discussion in 'PHP' started by malu, Feb 22, 2008.

  1. malu

    malu New Member

    Joined:
    Feb 22, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Hi again

    I am trying to create a web application that requires use of forms often. I want to use design patterns that I can use easily without hard-coding every time. I think I need to use Factory Pattern. I am new to PHP, so if someone can give me an advise, which design pattern would be more appropriate.

    Thanks ;)
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    You are absolute correct and Factory is one of the most appropriate one but remember that if you need more type of objects to be created like forms / other things then you can go for abstract factory
     
  3. malu

    malu New Member

    Joined:
    Feb 22, 2008
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    can you show me a simple example(coding)? lets say i have <input type="text">, how do I implement?
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Something like
    PHP:
    CreateObject(string objType)
    {
        switch(
    objType)
        {
            case 
    "text":
                return 
    '<input type="text" name="somename" />';
        }
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice