PHP Programmers - A question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • goldfish
    Confirmed User
    • Jan 2009
    • 723

    #1

    PHP Programmers - A question

    I was under the impression function files as includes were for frequently used functions so as to keep from having to repeat them.

    So I am rebuilding a script and I came across a function file, 4566 lines long!

    Many of the functions found inside are single use functions meaning they are called by one file and then never used again until the next time that file calls it again.

    So my question on a high traffic site should these these single use functions be placed in an include file or the file that is calling it when my focus is speed and server load impact to a minimum?
    ICQ: 566990329

    "There is no rest for the wicked... and porn purveyors!
  • Brujah
    Beer Money Baron
    • Jan 2001
    • 22157

    #2
    Are you using something like xcache, an opcode cache? It may not be as significant an issue as you're thinking if so.

    Comment

    • goldfish
      Confirmed User
      • Jan 2009
      • 723

      #3
      Originally posted by Brujah
      Are you using something like xcache, an opcode cache? It may not be as significant an issue as you're thinking if so.
      Nope....
      ICQ: 566990329

      "There is no rest for the wicked... and porn purveyors!

      Comment

      • KillerK
        Confirmed User
        • May 2008
        • 3406

        #4
        You should look into the caches he mentioned.

        Comment

        • Brujah
          Beer Money Baron
          • Jan 2001
          • 22157

          #5
          use an include file, the pros outweigh the cons, but if server load and speed is an issue you should look at the opcode caches anyway

          Comment

          • goldfish
            Confirmed User
            • Jan 2009
            • 723

            #6
            Originally posted by Brujah
            use an include file, the pros outweigh the cons, but if server load and speed is an issue you should look at the opcode caches anyway
            Would that answer change if I told you most of the function are just simple form interpetation, MYSQL queries and output from those queries?

            Will definitely look into cache issue thought!

            the biggest problem i may have with caching is this scripts makes tons of calls to another script(One I don't have control over) which uses its own programming language and an interpeter of some kind before it gets to the users browser and it is EXTREMELY tempermental.

            So here is a question then, is 4500 lines of code in one file considered alot? excessive?
            ICQ: 566990329

            "There is no rest for the wicked... and porn purveyors!

            Comment

            • LustyVixens
              Registered User
              • Feb 2010
              • 79

              #7
              4500 lines of code is nothing and unless the functions run processor intensive tasks, the effects would be negligible.

              Comment

              • Jakez
                Confirmed User
                • Jan 2004
                • 5656

                #8
                Is 4500 lines of codes nothing? I think 2 lines of code could be SOMETHING depending on what they are.. hell I could very easily fit and entire tube script into 4500 lines..
                Last edited by Jakez; 03-30-2010, 11:45 PM.
                [email protected] - jakezdumb - 573689400

                Killuminati

                Comment

                • rowan
                  Too lazy to set a custom title
                  • Mar 2002
                  • 17393

                  #9
                  4500 lines of code could be 200-300k in size, if you were compiling (once) the CPU time it takes is probably equivalent to an ant fart, but if it happens every page load the effect could be more noticeable IMHO. PHP isn't exactly efficient...

                  Comment

                  • LustyVixens
                    Registered User
                    • Feb 2010
                    • 79

                    #10
                    Originally posted by Jakez
                    Is 4500 lines of codes nothing? I think 2 lines of code could be SOMETHING depending on what they are.. hell I could very easily fit and entire tube script into 4500 lines..
                    He mentions the file contains functions and as I mentioned, there would be no obvious impact if the functions don't perform CPU-intensive tasks (in which case there would be an impact anyway, even if the intensive code was in its own file). Rather than concentrating on the number of lines as an indication of "excessive", rather ensure that the code within the file is written efficiently and clearly.

                    I of course don't support loading a file up with so many functions - it makes it hard to maintain. Optimal use of design patterns (notably MVC) should allow you to modularise your code more efficiently.

                    Comment

                    Working...