Reedyn / Just-Another-Webshop

Webshop built for a university PHP project
2 stars 1 forks source link

Clean up code #59

Open Reedyn opened 10 years ago

Reedyn commented 10 years ago

Split up functions.php into several smaller files to keep things organized

Suggestion

We should keep to one standard of naming functions. Right now the functions UserLogin() and UserRegister() differ from everything else.

The functions should also be verbs so UserLogin() could be better named simply login() to be more descriptive.

I suggest Zend Frameworks's version of naming functions.

Functions

function filterInput() { }
function getElementById() { }
function widgetFactory() { }

Variables

With variables we have three variants

1. Database

The one used in the database which look like this: OrderList & OrderId.

2. PHP

And then we have the php variables that look like the following in most cases:

$camelCaps // Normal variable
$_SESSION['user-login']; // Label in array, should match DOM named elements.
function dbAddUser($ssnr,$mail,$password,$firstName,$lastName) { }

3. HTML

The things stored in session I believe should follow the same naming convention as our HTML does. such as user-login and user-password, however we won't get around that we'll have some different names at some places.

<input name="login-password">
<button type="submit" name="login">Login</button>

which then would give us


$_POST => array (
          'login-password' => "value",
          'login' => "" )
Reedyn commented 10 years ago

I suggest we rename jaws-content to just content and place the img folder inside there.

Also that we rename jaws-includes to core