To class or not to class

Discussion in 'PHP' started by bookatechie, Feb 14, 2008.

  1. #1
    I'm working on a website that will potentially have to server a large amount of users. I was thinking I will use something like phpfox, vbulletin or some other proven php software as a model for the structure but I started to notice that a lot of these do not use classes much. They just include a set of functions from some files.
    What I would like to do is essentially the index.php page or edit.php page or what ever be a really high level sudo code type page that handles IO and just makes class calls to the appropriate sections.
    It would be really easy to understand for even noncoders but why isn't anyone else doing this?
     
    bookatechie, Feb 14, 2008 IP
  2. Ares

    Ares Member

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #2
    I'm not quite sure what you wanna do, but vbulletin and phpfox are different !
    vbulletin is a forum like here and phpfox is social network like live.phpfox.com/demo .
    and by the way, why on the earth do you want to change the code ?
    creating class will just make it easy for programming ,and if you are a programmer I dont think you would have any problem to change the code whether it uses class or not .
     
    Ares, Feb 14, 2008 IP
  3. bookatechie

    bookatechie Peon

    Messages:
    225
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the response Ares, sorry for not being more clear. I'm actually starting a brand new project, I was just interested to see how other software out there works that is used for large volume websites. I'm going to start from scratch and wanted input on good coding technique ... use classes or just call include files with functions in it, and the pros/cons of both ... I would vote class everything but then why aren't the big guys doing this?
     
    bookatechie, Feb 14, 2008 IP
  4. fairuz.ismail

    fairuz.ismail Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    yes they are...you should use class when you think you want to reuse them someday...the most important advantage of class from my point of view is that you can reuse the classes you've made for any website that you want..But remember dont reinvent the wheel, there are a lot of class out there that you use right away such as login class, user class, db class etc.. yyou can referat phpclasses.org

    good luck
     
    fairuz.ismail, Feb 14, 2008 IP
  5. jnestor

    jnestor Peon

    Messages:
    133
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Most likely for legacy reasons. That is they have a lot of functional code written that they want to use but not re-write into an object oriented fashion.

    I think you can write good, extensible, maintainable code in either an object oriented or function fashion. The biggest thing I'd suggest is to separate your logic from your output. Look into the model-view-container pattern if you're not familiar with it.
     
    jnestor, Feb 14, 2008 IP
  6. bookatechie

    bookatechie Peon

    Messages:
    225
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    bookatechie, Feb 15, 2008 IP