SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist Jhorra's Avatar
    Join Date
    Sep 2004
    Location
    Phoenix, Az
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How complex to make a page?

    I've been trying to make my code cleaner and more professional lately, and I have a question for you. I have a site that is basically a ticket tracking system for different types of forms. Basically I flag a person as to which forms they have access to. They are either viewing the form or updating it. So right now I have a different page depending on which form it is, a page for searching for them, and a page for updating users. Given this type of page should I have one page for all the forms, and just let it know via the url which form to pull and do everything with the one page? If I did it this way would I use a class to create the page, or just call a function depending on which form they want?

    I'm having problems figuring out at what point does a page warrant making a class for it. Right now I am calling a function that does what I want, but it basically the same thing as if I just included the code, or for that matter just write it on the page. I'm having a hard time seeing how using a function or class for my page helps me any. Or should I just do it for good coding practice?

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i personally dont like classes couse i even dont need them now for my work!
    if u code some intranet network for some agency then class is needed couse u havent many things to change after onbly little upgrades of the class code.
    but when u code a website u even dont need classes.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using a function or class is just good coding practice for modifications and updates at a later date. Let's say you have 30 pages that all use the same function. It's a small function so you decided to just include the code in each page. Now, its three months later and you need to make a modification to that function. You'd have to go into all 30 pages, page by page and update the code.

    If you had a function or class, you'd just have to update the code once and its done.

    It is just more efficient.

  4. #4
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well if you create a function or class that will show or update your form and include it in each of your pages then if there is a bug in it you just have to fix it one place. Generally the fewer pages and less code you have the easier it is to maintain your site.

  5. #5
    SitePoint Evangelist Jhorra's Avatar
    Join Date
    Sep 2004
    Location
    Phoenix, Az
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well in my case each form has specific fields that need updated, and depending on which form it is go different places. So if I created a class or function to do all of them in one I would have to be able to tell it what to do for each form. At that point isn't it just the same thing?


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
  •