From bf8b7659a918b15cf8ccb42c23aadc446df52542 Mon Sep 17 00:00:00 2001 From: natec Date: Sat, 9 Jun 2001 21:00:12 +0000 Subject: Updated/fixed coding standards doc. git-svn-id: file:///svn/phpbb/trunk@445 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/docs/codingstandards.htm | 47 ++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/phpBB/docs/codingstandards.htm b/phpBB/docs/codingstandards.htm index 1810af5589..1cb7f3c57d 100644 --- a/phpBB/docs/codingstandards.htm +++ b/phpBB/docs/codingstandards.htm @@ -1,20 +1,20 @@ - -phpBB Coding Standard Guidelines - - - + +phpBB Coding Standard Guidelines + + +

phpBB Coding Standard Guidelines

Comments or suggestions? email nate@phpbb.com

Editor +href="#editor">Editor Settings
Naming +href="#naming">Naming Conventions
Code Layout
General +href="#layout">Code Layout
General Guidelines


top +href="#top">top

Editor Settings

Tabs vs Spaces: In order to make this as simple as possible, we will be using tabs, not spaces. Feel free to set how many spaces your editor uses @@ -28,7 +28,7 @@ are on Win32, or whatever the Mac uses. Any decent Win32 editor should be able to do this, but it might not always be the default. Know your editor. If you want advice on Windows text editors, just ask one of the developers. Some of them do their editing on Win32.



top +href="#top">top

Naming Conventions

We will not be using any form of hungarian notation in our naming conventions. Many of us believe that hungarian naming is one of the primary code @@ -72,7 +72,7 @@ though; print_login_status_for_a_given_user() goes too far, for example -- that function would be better named print_user_login_status() , or just print_login_status().



top +href="#top">top

Code Layout

Standard header for new files: Here a template of the header that must be included at the start of all phpBB files:


@@ -205,8 +205,25 @@ look. Note where the lines break, the capitalization, and the use of brackets.
 		FROM table a, table b
 		WHERE (this = that) AND (this2 = that2)
 		
+

+

SQL insert statements: SQL INSERT statements can be written in two +different ways. Either you specify explicitly the columns being inserted, or +you rely on knowing the order of the columns in the database and do not +specify them. We want to use the former approach, where it is explicitly +stated whcih columns are being inserted. This means our application-level code +will not depend on the order of the fields in the database, and will not be broken +if we add additional fields (unless they're specified as NOT NULL, of course). +

   Examples:


+		# This is not what we want.
+		INSERT INTO mytable
+		VALUES ('something', 1, 'else')
+		
+		# This is correct.
+		INSERT INTO mytable (column1, column2, column3)
+		VALUES ('something', 1, 'else')
+		



top +href="#top">top

General Guidelines

Quoting strings: There are two different ways to quote strings in PHP - either with single quotes or with double quotes. The main difference is that @@ -306,5 +323,5 @@ been set.

   Examples:


 		/* New way */
 		if (isset($forum)) ...
 		
-



Return +



Return to top
-- cgit v1.2.1