SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Mar 2002
    Location
    Los Angeles
    Posts
    325
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Slight design pattern confusion...which one is more appropriate?

    Hello,

    I'm building an app where in which I generate a database table, a 'controller' php class file, and another file (probably xml-not sure yet) to build the an input form in flash for each section of a site. So, if one section of the site were 'portfolios', i would wind up with a portoflios table, PortfolioController.php and portfolioform.xml (which flash would read in and build the form dynamically).

    So my question is about design patterns. Sounds like it would be logical to use a separate Builder for each part I am outputting...one for the db table, one for the controller file, and one for the xml form. I could have an abstract 'Builder' class with a subclass for each.

    Then i started thinking, well what i have here is the same basic steps for contruction of the three different types, with just a different behavior for the different steps of construction...which sounds to me like I might want to just encapsulate the differnt behaviors into different classes, which sounds liek a case for the Strategy pattern.

    Does what I am saying make any sense? Or maybe there's another angle I'm not considering yet. Any help is appreciated.

    edit:
    come to think of it, I may also be able to use the Tempate method pattern, since the stpes are the same, and each subclass could define their own algorithm for the those steps.

    yikes.
    From here on, it's instinctual...even straight roads meander.

  2. #2
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would have said the Factory pattern
    - one method for the db table, one for the php file, one for the xml file
    - then subclass to create concrete Factory classes for each section of the
    site

    Factory pattern is often used to create product families with a uniform interface. In your case, it sounds like each site section is its own product family.

  3. #3
    SitePoint Addict
    Join Date
    Mar 2002
    Location
    Los Angeles
    Posts
    325
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, i thought about Factory, but the the thing is that the generation of each item is a multistep process. Also, I wouldnt know the sections of the site beforehand, that's what I am generating. After I generate everything, I can use Factory to get the different items. Basically, I am making an app that builds another app.
    From here on, it's instinctual...even straight roads meander.


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
  •