X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=doc%2Fwebserver%2Fdeveloper-manual%2Fcoding.html;h=fbc9bb6535caa4a2461b7324d86c3c8aaec401b5;hp=fead798d309e9b5ea72bf3f23ceaf6e5649f7514;hb=52dd7ce940f67888a660efbef86d49c4384f7e77;hpb=72081f829de368392d04076728f8c991178c0080 diff --git a/doc/webserver/developer-manual/coding.html b/doc/webserver/developer-manual/coding.html index fead798d..fbc9bb65 100644 --- a/doc/webserver/developer-manual/coding.html +++ b/doc/webserver/developer-manual/coding.html @@ -1,11 +1,11 @@ - +
Comment as much as possible without commenting the obvious. - For example do not comment "aVariable is equal to bVariable". - Instead explain why aVariable should be equal to the bVariable. + For example do not comment "variable_a is equal to variable_b". + Instead explain why variable_a should be equal to the variable_b. Just because a person can read code does not mean they will understand why or what is being done. A reader may spend a lot more time figuring out what is going on when a simple comment @@ -153,13 +156,13 @@ WIDTH="100%" >
/* if page size greater than 1k ... */ -if ( PageLength() > 1024 ) +if ( page_length() > 1024 ) { ... "block" the page up ... } /* if page size is small, send it in blocks */ -if ( PageLength() > 1024 ) +if ( page_length() > 1024 ) { ... "block" the page up ... } @@ -212,22 +215,22 @@ CLASS="PROGRAMLISTING" >/********************************************************************* * This will stand out clearly in your code! *********************************************************************/ -if ( thisVariable == thatVariable ) +if ( this_variable == that_variable ) { - DoSomethingVeryImportant(); + do_something_very_important(); } /* unfortunately, this may not */ -if ( thisVariable == thatVariable ) +if ( this_variable == that_variable ) { - DoSomethingVeryImportant(); + do_something_very_important(); } -if ( thisVariable == thatVariable ) /* this may not either */ +if ( this_variable == that_variable ) /* this may not either */ { - DoSomethingVeryImportant(); + do_something_very_important(); }if ( 1 == X ) { - DoSomethingVeryImportant(); + do_something_very_important(); ...some long list of commands... } /* -END- if x is 1 */ @@ -438,7 +441,7 @@ or: if ( 1 == X ) { - DoSomethingVeryImportant(); + do_something_very_important(); ...some long list of commands... } /* -END- if ( 1 == X ) */if ( this == that ) { - DoSomething(); - DoSomethingElse(); + do_something(); + do_something_else(); }
if ( this == that ) DoSomething(); DoSomethingElse();
if ( this == that ) do_something(); do_something_else();or
if ( this == that ) DoSomething();
if ( this == that ) do_something();int firstValue = 0; -int someValue = 0; -int anotherValue = 0; -int thisVariable = 0; +>int first_value = 0; +int some_value = 0; +int another_value = 0; +int this_variable = 0; -if ( thisVariable == thatVariable ) +if ( this_variable == this_variable ) -firstValue = oldValue + ( ( someValue - anotherValue ) - whatever )
aStruct->aMember; -aStruct.aMember; -FunctionName();a_struct->a_member; +a_struct.a_member; +function_name();
int function1( ... ) { ...code... return( retCode ); } int +>int function1( ... ) { ...code... return( ret_code ); } int function2( ... ) { }
short anShort = 0; -float aFloat = 0; +>short a_short = 0; +float a_float = 0; struct *ptr = NULL;
ShouldWeBlockThis(); -ContainsAnImage(); -IsWebPageBlank();should_we_block_this(); +contains_an_image(); +is_web_page_blank();
for ( size_t cnt = 0; cnt < blockListLength(); cnt ++ ) +>for ( size_t cnt = 0; cnt < block_list_length(); cnt++ ) { .... }
Instead of using a function call during the iterations, @@ -1505,9 +1508,9 @@ WIDTH="100%" >
size_t len = blockListLength(); +>size_t len = block_list_length(); -for ( size_t cnt = 0; cnt < len; cnt ++ ) +for ( size_t cnt = 0; cnt < len; cnt++ ) { .... }Exceptions: if the value of blockListLength() *may* - change or could *potentially* change, then you must code the +> if the value of block_list_length() + *may* change or could *potentially* change, then you must code the function call in the for/while loop.
4.7.10. "Uncertain" new code and/or changes to
- existing code, use FIXME
const char FILENAME_rcs[] = "$Id: coding.html,v 1.19.2.7 2004/01/31 00:05:44 oes Exp $"; +>const char FILENAME_rcs[] = "$Id$"; /********************************************************************* * - * File : $Source: /cvsroot/ijbswa/current/doc/webserver/developer-manual/coding.html,v $ + * File : $Source$ * * Purpose : (Fill me in with a good description!) * - * Copyright : Written by and Copyright (C) 2001 the SourceForge - * Privoxy team. http://www.privoxy.org/ - * - * Based on the Internet Junkbuster originally written - * by and Copyright (C) 1997 Anonymous Coders and - * Junkbusters Corporation. http://www.junkbusters.com + * Copyright : Written by and Copyright (C) 2001-2009 + * the Privoxy team. http://www.privoxy.org/ * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General @@ -2362,15 +2360,13 @@ CLASS="PROGRAMLISTING" * * The GNU General Public License should be included with * this file. If not, you can view it at - * http://www.gnu.org/copyleft/gpl.html - * or write to the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 , + * USA * * Revisions : - * $Log: coding.html,v $ - * Revision 1.19.2.7 2004/01/31 00:05:44 oes - * Regenerated from sgml source - * + * $Log$ * *********************************************************************/ @@ -2424,19 +2420,15 @@ WIDTH="100%" CLASS="PROGRAMLISTING" >#ifndef _FILENAME_H #define _FILENAME_H -#define FILENAME_H_VERSION "$Id: coding.html,v 1.19.2.7 2004/01/31 00:05:44 oes Exp $" +#define FILENAME_H_VERSION "$Id$" /********************************************************************* * - * File : $Source: /cvsroot/ijbswa/current/doc/webserver/developer-manual/coding.html,v $ + * File : $Source$ * * Purpose : (Fill me in with a good description!) * - * Copyright : Written by and Copyright (C) 2001 the SourceForge - * Privoxy team. http://www.privoxy.org/ - * - * Based on the Internet Junkbuster originally written - * by and Copyright (C) 1997 Anonymous Coders and - * Junkbusters Corporation. http://www.junkbusters.com + * Copyright : Written by and Copyright (C) 2001-2009 + * the Privoxy team. http://www.privoxy.org/ * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General @@ -2452,15 +2444,13 @@ CLASS="PROGRAMLISTING" * * The GNU General Public License should be included with * this file. If not, you can view it at - * http://www.gnu.org/copyleft/gpl.html - * or write to the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 , + * USA * * Revisions : - * $Log: coding.html,v $ - * Revision 1.19.2.7 2004/01/31 00:05:44 oes - * Regenerated from sgml source - * + * $Log$ * *********************************************************************/