I was looking into the development guidelines File Naming conventions and I have a suggestion:
I should mention that certain extentions output plain text from standard browsers which can be easily fixed. Secondly the fix open an opportunity to expand and clarify the intention of the files by adding the intention in front of the file
Screen output files: filename.php Process files: filename.php => process/filename.php or process.filename.php (with filename same as calling or pulling filename so you know what it relates to) Includeble script block: filename.inc => inc.filename.php Includeble functions: filenmame.inc => fie.filename.php or lib.filename.php (personally prefer the first) Includeble classes: filename.class.php => class.filename.php
That way output is always empty + you know what's in the file without opening it.
You basically can do the same for javascript: Basic js file: filename.js Included js file: filename.js.src => src.filename.js
You should also consider putting html comment tags around the javascript code (<!-code //-->) so it wont output if javascript is turned off. To make sure javascript is turned on, you should consider disabling all process buttons and turning them on at runtime.
I haven't looked at the database conventions, but what I personally always do is the following: SELECT field FROM Table WHERE otherfield LIKE 'value' LIMIT 0,1; As you can see sql-specific parts are in uppercase, fields in lowercase and table in ucfirst. This way you can separate what they are by simply looking how it's written. PS the LIMIT 0,1 (mysql) is a faster query then without, even when you know there can only be one value returned, as it stops looking after it's found one which it wont if the limit is not there.
Note that it's just a suggestion, which I've used myself for a few years now. Especially in complicated applications it's proven to be very useful to me as it reduces time when searching for the wright file, even after some time has passed working on the application.
Wkr,
Dirk Rennen
KPN Belgium N.V. Koningin Astridlaan 166 1780 Wemmel Belgium
List info: http://lists.roundcube.net/dev/
I'm not a developer of this project, so I cannot speak for it, but these are some thoughts:
Dirk Rennen wrote:
You should also consider putting html comment tags around the javascript code (<!—code //) so it wont output if javascript is turned off.
To make sure javascript is turned on, you should consider disabling all process buttons and turning them on at runtime.
Personally, I wouldn't worry about javascript checking until a 1.0 release. (And if you are forcing javascript, you should redirect to an error page post-login.) All modern browsers support parsing <script> tags even if javascript is off. The proper way to separate inline javascript from the html is as follows:
<script type="text/javascript"> //<![CDATA[ .. javascript code here ... //]]> </script>
I haven't looked at the database conventions, but what I personally always do is the following:
SELECT field FROM Table WHERE otherfield LIKE 'value' LIMIT 0,1;
As you can see sql-specific parts are in uppercase, fields in lowercase and table in ucfirst. This way you can separate what they are by simply looking how it's written.
I totally agree on uppercasing SQL keywords as most IDEs won't syntax-highlight inside strings.
PS the LIMIT 0,1 (mysql) is a faster query then without, even when you know there can only be one value returned, as it stops looking after it's found one which it wont if the limit is not there.
I disagree here -- I could be wrong, but please prove me wrong. If you *know* the query will only return one row (because your WHERE statement uses a primary key and there are no left-joins or other mechanisms to provide multiple rows) then the limit will not help. The LIMIT expression is applied after the results have been gathered. (Use 'explain' before your query to test this.)
I agree the LIMIT *is* faster when multiple rows *may* be returned. But if you only want one row out of a possible set, then the query will already have the limit statement.
Thus, adding LIMIT 1 or LIMIT 0,1 to all single-row queries is redundant.
-gnul _______________________________________________ List info: http://lists.roundcube.net/dev/
Gnul wrote:
The LIMIT expression is applied after the results have been gathered.
I refer to: http://dev.mysql.com/doc/refman/5.0/en/limit-optimization.html Quote: As soon as MySQL has sent the required number of rows to the client, it aborts the query unless you are using SQL_CALC_FOUND_ROWS.
So it's faster with the limit 1 or limit 0,1 as it's stops the query once it'f found a result. Especially in large tables this can be significant. I doubt the speed will be significantly improved in this application, but It's good practice. I've worked on DBs of +5 TerraBytes and there the the Increase in speed was significant.
-----Original Message----- From: dev-bounces+dirk.rennen=kpn.be@lists.roundcube.net [mailto:dev-bounces+dirk.rennen=kpn.be@lists.roundcube.net] On Behalf Of gnul Sent: donderdag 8 januari 2009 20:20 To: dev@lists.roundcube.net Subject: Re: [RCD] File naming conventions
I'm not a developer of this project, so I cannot speak for it, but these are some thoughts:
Dirk Rennen wrote:
You should also consider putting html comment tags around the javascript code (<!-code //) so it wont output if javascript is turned off.
To make sure javascript is turned on, you should consider disabling all process buttons and turning them on at runtime.
Personally, I wouldn't worry about javascript checking until a 1.0 release. (And if you are forcing javascript, you should redirect to an error page post-login.) All modern browsers support parsing <script> tags even if javascript is off. The proper way to separate inline javascript from the html is as follows:
<script type="text/javascript"> //<![CDATA[ .. javascript code here ... //]]> </script>
I haven't looked at the database conventions, but what I personally always do is the following:
SELECT field FROM Table WHERE otherfield LIKE 'value' LIMIT 0,1;
As you can see sql-specific parts are in uppercase, fields in lowercase and table in ucfirst. This way you can separate what they are by simply looking how it's written.
I totally agree on uppercasing SQL keywords as most IDEs won't syntax-highlight inside strings.
PS the LIMIT 0,1 (mysql) is a faster query then without, even when you know there can only be one value returned, as it stops looking after it's found one which it wont if the limit is not there.
I disagree here -- I could be wrong, but please prove me wrong. If you *know* the query will only return one row (because your WHERE statement uses a primary key and there are no left-joins or other mechanisms to provide multiple rows) then the limit will not help. The LIMIT expression is applied after the results have been gathered. (Use 'explain' before your query to test this.)
I agree the LIMIT *is* faster when multiple rows *may* be returned. But if you only want one row out of a possible set, then the query will already have the limit statement.
Thus, adding LIMIT 1 or LIMIT 0,1 to all single-row queries is redundant.
-gnul _______________________________________________ List info: http://lists.roundcube.net/dev/ _______________________________________________ List info: http://lists.roundcube.net/dev/