Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Design Patterns ? (http://www.go4expert.com/forums/design-patterns-t8998/)

malu 23Feb2008 00:43

Design Patterns ?
 
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 ;)

shabbir 23Feb2008 09:23

Re: Design Patterns ?
 
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

malu 23Feb2008 21:47

Re: Design Patterns ?
 
Quote:

Originally Posted by shabbir
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

can you show me a simple example(coding)? lets say i have <input type="text">, how do I implement?

shabbir 23Feb2008 22:37

Re: Design Patterns ?
 
Something like
PHP Code:

CreateObject(string objType)
{
    switch(
objType)
    {
        case 
"text":
            return 
'<input type="text" name="somename" />';
    }




All times are GMT +5.5. The time now is 00:08.