SitePoint Sponsor

User Tag List

Page 3 of 4 FirstFirst 1234 LastLast
Results 51 to 75 of 81
  1. #51
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I usually cap code per file at 400 to 500 lines.

  2. #52
    SitePoint Addict Jack Matier's Avatar
    Join Date
    Feb 2005
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was wondering about this too.. and I did end up developing an index page that serves many pages out of one file being referred from modRewrite.

    I have all the dropdown menu's and titles created from a single array so that when I change this it affects the whole site. Then other conditional statements to serve up individual pages. It also serves up userpages.

    To me, this is kind of like creating 1 page around the selected page.. instead of the selected page with a bunch of includes. (I still do have includes). It's been easier to manage this way especially for growth reasons.

    It got me curious what exactly the zend engine does, by loading the same page over and over, and how much memory it does actually take to say, get through an if statement if it isn't actually used the first time compared to the next?

    now, the application is less then 600 lines.

    I mean, after I concluded that the file would be the same length if includes I wondered about the difference of serving 1 page over and over to 50 people at a time compared to 20 pages served to 50 people.

    I dunno. This is odd of me to create something like this, since I usually cap my code at around 500 lines max.

  3. #53
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RonS
    From a QA standpoint, if you touch a line of code in a module (file), you must test every bit of functionality in that module... in your case, the entire application would have to be retested for, say, a change in the copyright line.
    Which would take about 10 seconds if it is unit tested

    Quote Originally Posted by dbevfat
    This is not really an advantage, is it? If taken into account how much effort has to be put into the maintainance of a large file.
    Miss one } somewhere, and you'll get a nice: Syntax error, missing } at line 6000.

    Douglas
    Hello World

  4. #54
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX



    Miss one } somewhere, and you'll get a nice: Syntax error, missing } at line 6000.

    Douglas
    I was just thinking about that

  5. #55
    I <3 Internet Tekime's Avatar
    Join Date
    Dec 2003
    Location
    Maine
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I never set a maximum length for individual files, but once you start pushing a few thousand lines it gets a bit unwieldy. I have some big classess here and there, but I certainly wouldn't break it into smaller parts just because it's a big class. Complex software requires a lot of code. There are a little over 60,000 lines of code in the current project I'm working on, I don't even want to imagine that in one file. :|
    Scriptalicious SEO Scripts
    Save 20% with coupon code SPROCKS


  6. #56
    SitePoint Zealot ShytKicka's Avatar
    Join Date
    Aug 2004
    Location
    New York
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Etnu
    Pros:

    - If you're using something like Turck MMCache, or e-Accelerator, this is the only file that would ever have to be cached. This would boost performance by a huge amount.
    I disagree as well.

  7. #57
    SitePoint Wizard Dangermouse's Avatar
    Join Date
    Oct 2003
    Posts
    1,024
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    Miss one } somewhere, and you'll get a nice: Syntax error, missing } at line 6000.
    Which version of PHP are you using that tells you that?

  8. #58
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think we are forgetting that with all the code in one file, ALL the code is executed EVERY TIME for EVERY PAGE LOAD (even if some code is not used in that page load). If you have code in different files/classes, you can only include what you need for that specific page, dramatically reducing the amount of lines of code executed for one page. So a proper compairison would not be 6,000 lines in one file to 6,000 lines in many separate files - The truth is that with many separate files, you can only include the files/classes that you are going to use that page load, so the actual number of lines executed per page load would have a large variance depending on the functions you run.

    Why would you include every single file when you only need one class? You wouldn't, and that is the argument for speed optimization for splitting code into many different files. A better compairison would be 6,000 lines in one file to 1,200 lines (or however many you need for the specific page load) in many different files. Less code executed wins hands down every time. That is why you must split up your code into multiple files.

  9. #59
    SitePoint Zealot ShytKicka's Avatar
    Join Date
    Aug 2004
    Location
    New York
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ^^ That's your answer.

  10. #60
    SitePoint Evangelist dmsuperman's Avatar
    Join Date
    Feb 2005
    Location
    A box
    Posts
    516
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Argh, stupid star wars nerds.
    *hides collectables* :P
    Yea, using anything much bigger than a couple hundred lines is horrible, it's slow and bulky and hard to edit what you need... I can't stand it.
    <(^.^<) \(^.^\) (^.^) (/^.^)/ (>^.^)>
    Core 2 Duo E8400 clocked @ 3.375GHz, 2x2GB 800MHz DDR2 RAM
    5x SATA drives totalling 2.5TB, 7900GS KO, 6600GT

  11. #61
    SitePoint Enthusiast
    Join Date
    May 2005
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Damn all you new age optimising freaks!

    I'm very happy with my 6000 line class file, I don't find debugging or handling the code a problem because I know it all off by heart anyway. performance is good, so why change.

    Size does matter lads!

  12. #62
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    6000 lines of code is ok...

    6000 lines of code in Dreamweaver?

    What were you thinking!

  13. #63
    SitePoint Enthusiast rommi's Avatar
    Join Date
    Sep 2004
    Location
    Toronto, Canada
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reuse Suffers

    Having large files eliminates possibility of code reuse. I create small include files that I prefix with "fn_". In future prjects I copy the file, include it and reuse it.

  14. #64
    SitePoint Zealot ShytKicka's Avatar
    Join Date
    Aug 2004
    Location
    New York
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dale_C
    Damn all you new age optimising freaks!

    I'm very happy with my 6000 line class file, I don't find debugging or handling the code a problem because I know it all off by heart anyway. performance is good, so why change.

    Size does matter lads!
    The whole point of splitting things up, is to not only allow better debugging and handling, but also, you have to think about is other developers besides yourself. If somebody else looks at it, they will have no idea what is going on, and the code will become worthless.

    Here are just some advantages to keeping your files seperated, in small pieces:

    1. Your code is more organized, it is easier to see what is going on, and will be more valueable and understandable to a second developer, or even yourself, imagine you stop working with the code for 5 months, and then you come back, you will most likely forget the entire piece of code does. And to remind yourself, you'll have to go through the entire code.

    2. Saving, opening, and uploading your file will be alot faster. Anytime you edit a tiny piece of the code on a large file, it'll take a longer time to upload.

    3. Your code is more reusable. Nowadays, developers are forced to use object orientation, and with many files, you are programming in a more oriented manner. For instance, if you want to call a piece of your code through Flash, or from a different server, your components and webservices have to lay in a different file. I am not saying seperating your code into seperate files is object oriented, but it does bring you 1 step closer to it.

    4. There will be a performance gain. If you have 1 file that does 10 different things, you are either using 10 case blocks or 10 if blocks. Also, you are probably including all your classes that you will use in the entire file, when on 1 page, you will only use a portion of them.

    5. Debugging is alot simpler. Like others said, if you have to go down to line 6000, to edit a bracket, and then upload a megabyte file, then you won't really be too happy.

    Overall, 1 file, will be confusing and disorganized. That is the key thing to note here.

  15. #65
    SitePoint Enthusiast
    Join Date
    May 2005
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, my file is 200kb, I think someone else was talking about a 1mb file..agreed 1mb would be far too much but with 200kb, considering I have a 2mb connection, it takes 3 seconds to upload so theres no problem in terms of size.

    Also, because it's all OOP and each CLASS is only a few hundred lines, even though it's one file, personally I see it as separate files, coming from a java background...

    In terms of re-use, no one is going to be using this code except for me, in fact it's not even going to be viewable by the company that is using it as it will be encrypted, encrypting one file is a lot easier than encrytping many many files. All the points are valid though and ofcourse, I am not ignorant to the fact that in an organised, large scale project smaller files are vital in terms of organisation and I will always take this approach in the future. Just in terms of this particular project, it was more convenient to have the API in one large class file.

  16. #66
    SitePoint Guru dbevfat's Avatar
    Join Date
    Dec 2004
    Location
    ljubljana, slovenia
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about a MDI editor that allows you to open many files and edit them all? How do you edit your application code at two different positions at the same time?

    Also, imagine deciding to replace a single player in your system (a class, a function) or using factories with all possible classes it creates .

  17. #67
    SitePoint Guru Galo's Avatar
    Join Date
    May 2005
    Location
    Holland!
    Posts
    852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah let's try some cvs with one file :P...
    Business as usual is off the menu folks, ...

  18. #68
    SitePoint Member
    Join Date
    Jun 2004
    Location
    Brazil
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A large PHP app on one single file? The first question that pops up is: why do this way?

    The first thing that comes to mind is that you'll have problems when another programmer comes to help you maintain your large app. It will be a pain to work out two person trying to edit/improve/fix your app by both editing the same file.

    __________________
    Pilhas Recarregáveis Total Shape Farinha de Maracujá
    Last edited by afmbr; May 25, 2005 at 21:09.

  19. #69
    SitePoint Zealot ShytKicka's Avatar
    Join Date
    Aug 2004
    Location
    New York
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Quote Originally Posted by Dale_C
    Well, my file is 200kb, I think someone else was talking about a 1mb file..agreed 1mb would be far too much but with 200kb, considering I have a 2mb connection, it takes 3 seconds to upload so theres no problem in terms of size.
    Doesn't the 3 second delay annoy you enough?

    Also, because it's all OOP and each CLASS is only a few hundred lines, even though it's one file, personally I see it as separate files, coming from a java background...
    I don't understand what a java background has to do with a single file? It's not all object oriented, if it would be you would have webservices, soap, components, and objects, located in seperate files. Methods and classes are just the first step of the stair case.

    In terms of re-use, no one is going to be using this code except for me, in fact it's not even going to be viewable by the company that is using it as it will be encrypted, encrypting one file is a lot easier than encrytping many many files.
    That is what many beginners say, anybody can say that about many projects. But you are not thinking correctly. What if one day, you would like to expand your files across a cluster? What about if you want to interact with the file from a different server? What if one day, a second site will branch off from your company site, and will be located on a differetn server in a different programming language, how will you call things from your company server files if you aren't using webservices? What if one day you sell your company site to somebody, they won't buy it unless you have a good organized code with true object orientation. What if one day, another developer wants to help you? He/she will be lost.

    We cannot fortell the future. We might think none of these things will happen, but many times they do, so it is correct to plan for the future.

  20. #70
    Thinking about Visual Thinking
    Join Date
    May 2003
    Location
    back in South Africa
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink PEAR Proposal ScriptReorganizer

    Quote Originally Posted by Viflux
    If it's the latter, I may be tempted to create a parser that, after the application is complete and before uploading, strips out comments, whitespace, and replaces all include()'s with the actual code...
    The PEAR Proposal ScriptReorganizer has been called for votes.

  21. #71
    I &lt;3 Internet Tekime's Avatar
    Join Date
    Dec 2003
    Location
    Maine
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rommi
    Having large files eliminates possibility of code reuse.
    File size has nothing to do with reusability, unless your files are big due to poor design.
    Scriptalicious SEO Scripts
    Save 20% with coupon code SPROCKS


  22. #72
    SitePoint Guru dbevfat's Avatar
    Join Date
    Dec 2004
    Location
    ljubljana, slovenia
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Tekime
    File size has nothing to do with reusability, unless your files are big due to poor design.
    I beg to differ. How are you supposed to reuse a single class?

  23. #73
    Employed Again Viflux's Avatar
    Join Date
    May 2003
    Location
    London, On.
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Include the file.

    It reduces the EFFICIENCY, but not the reusability.

  24. #74
    I &lt;3 Internet Tekime's Avatar
    Join Date
    Dec 2003
    Location
    Maine
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right. I'm not sure I understand your question though dbevfat, I reuse classes all the time. My templating class is just shy of 1,000 lines, well optimized, and growing steadily as I add features.

    Big classes are a breeze to navigate if you comment well and organize all of your functions alphabetically (or in some other order that means something to you).

    Example of a huge class that is not a breeze to navigate: adodb.inc.php
    Scriptalicious SEO Scripts
    Save 20% with coupon code SPROCKS


  25. #75
    SitePoint Guru dbevfat's Avatar
    Join Date
    Dec 2004
    Location
    ljubljana, slovenia
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I meant was, imagine that you have a bunch of classes in one file for one project and only decide to use ONE or SOME of them for another project - which is what reusability is all about. To use what you need. You are forced to include them all, which is AT LEAST not efficient, and can get worse to various class/var/const clashes and all.

    Or, imagine you decide to use ALL of those classes in the file, except ONE, which you want to rewrite for a specific project?

    I think it's pretty obvious that large files are not just inefficient, but also hard to reuse. I am talking about a file with many classes in it, of course. There is nothing wrong with reusing a large file with a single class, I guess, except that it's probably designed badly. It's arguable, but I'd dare to say that 99% of all classes out there don't need 1000 lines.


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
  •