RE: Your Opinion?! PHP4 coding style - Comment and Splitting source code

From: Date: Tue, 13 Feb 2001 21:48:10 +0000
Subject: RE: Your Opinion?! PHP4 coding style - Comment and Splitting source code
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39506@lists.php.net to get a copy of this message
My personal opinions: The effect of comments in code parsing speed is negligable. Never hesitate to put in a comment because you think it's going to slow down the procedure. If your speed requirements were that down to the wire, you should have gone with a compiled app anyway. Or a faster server. Or anything other than not putting in comments. That said, it's rare that I've written 2 lines of comments for every 1 line of code, and I tend to be fairly rigorous (on good days, anyway) about commenting completely. You may want to consider putting some of those comments in seperate design documentation. Finally, I tend to break up my source code into several files, usually around the class definitions (I like object orientation). I usually wind up with one file for the database interface, a few files containing class definitions corresponding to the business logic, and an included fragment for each block of HTML which needs to interact heavily with the PHP (for example, pre-populated form fields). This is purely for ease-of-maintenance. Where you can, you should replace calls to include() with calls to require(), because require() is a bit faster. The catch is that you can't place require() calls in conditional blocks, so: if ($something) include($foo); // this is okay if ($something) require($bar); // this is not. Hope this helps, Sam > -----Original Message----- > From: Yasuo Ohgaki [mailto:yohgaki@hotmail.com] > Sent: Tuesday, February 13, 2001 5:40 AM > To: php-general@lists.php.net > Subject: Your Opinion?! PHP4 coding style - Comment and Splitting > source code > > > Hello all. > > I'm running PHP4 as Apache module under Linux. I would like to know good > script coding style. > > I should not write long comments in code or not? With Zend Cache, comments > should not matter. How about w/o Zend Cache? If I want to write long > comments, should I get Zend Cache? Or can I ignore the overheads? For > example, 50KB of comments for 25KB code - total 75KB script size. (Not > considering disk access/load overhead. I would like to know PHP4's > overheads) > > Whether I should split source code so that PHP4 can parse/compile > as little > code as possible or not. What is the best coding style you suggest? For > example, 200KB script containing all > code vs. split into several source files and load 100KB on average when it > executed. > > What is your opinion? > > Thanks in advance. > > -- > Yasuo Ohgaki > >

« previous php.general (#39506) next »