Skip to main content

Naming Conventions While Programming.

1. All files names which will be represeted to site visitors should be in lower case

2. All other file names should follow - {first_character_capital} of each word in name. for example if file name is shoppingcart.php then it should be ShoppingCart.php

3. All local variable names should follow
a) {first_character_capital} of each word in name. for example if variable name is firstname then it should be FirstName
b) should have following prefixes
i - integer
b - boolean
s - string
c - character
f - float
d - date
obj - class object
iArr - integer array
bArr - boolean array
sArr - string array
cArr - character array
fArr - float array
dArr - date array
objArr - class object array

c) name should be meaningfull. like id should be Id, login id should be LoginId, loop counter should be Counter or ProdCounter

4. All function parameters and any public variable names should follow
a) {first_character_capital} of each word in name. for example if variable name is firstname then it should be FirstName
b) name should be meaningfull. like id should be Id, login id should be LoginId, loop counter should be Counter or ProductCounter

5. All function names should follow
a) first character of first word should be small. for example if function name is get_quantity then it should be getQuantity or get_email_id should be getEmailId

6. All variables should be declared before use

7. All variables should be destroyed immediately after its FINAL use

********* code formatting *******

8. For each function there should be comments above it which explains use of function, user of parameters and return type.

/**
* use of function
* @variable name - data type - use of variable - default value in case of optional - allowed values in case of fixed value options
* return - data type - explaination
**/


for example

/**
* validates passed user name and password and returns true or false
* @UserName - string - user name
* @Password - string - password
* return boolean - true / false
**/

function validatePassword(UserName, Password)
{
}

second example

/**
* constructor of class
* @CategoryId - int - category id to filter products - default 0
* @FetchAll - boolean - if true then fetches all records from database - false - true/false
**/

function Products(CategoryId = 0, FetchAll = false)

9. For each variable there should be comment for use of variable

for example

var $iCounter; // counter of products loop

10. Each inner block should be started with a tab
for example

Outer block
Inner block 1 statement 1
Inner block 1 statement 1
Inner block 1 statement 1
Inner block 2 statement 1
Inner block 2 statement 2
Inner block 1 statement 1
Inner block 3 statement 1
Inner block 4 statement 1

11. block bracket should start be on separate line
for example

block start
{
block statement 1
block statement 2
block statement 3
}

12. there should be space after and before any operator = > < ; + - * /

Comments

Popular posts from this blog

Import Customers by csv file in Magento

Import Customers by csv file in Magento here i developed script to import customers in magento by csv file. csv file have following columns ########customerid (unique key) accesskey (customer type) emailaddress password firstname lastname companyname billingaddress1 city state postalcode country phonenumber faxnumber ########### here i didn't use any magento's core file. code is given below,i hope it will help you :) set_time_limit(36000); error_reporting(0); /** * @Use Script to import customer's data in Magento Database * @createDate Mar 2010 * @author Manoj Ninave (manojninave@gmail.com) **/ define("DB_HOST","localhost",TRUE); // database server name define("DB_USER","root",TRUE); // database user define("DB_PASS","",TRUE); // database user's password define("DB_NAME","dbname",TRUE); // database name require_once('db.class.php'); if( !isset($db_obj) ) {...

How to get detail information about facebook user

Solution to get Detailed information about facebook user. 1) First you need to log in to the Facebook Developer application: Go to the Facebook Developer AppAfter following the link, click “Allow” to let the Developer application access your profile. 2) Begin setting up a new application. Go to the Developer application and click “Set Up New Application”. Give your application a name, check to accept the Terms of Service, then click Submit. You’ll see some basic information about your application, including: but for that you will need PHP client library you can download “PHP client library” after clicking the above link. for detail information see get started * Your API key: this key identifies your application to Facebook. You pass it with all your API calls. * Your application secret: Facebook uses this key to authenticate the requests you make. As you can tell by its name, you should never share this key with anyone. code: require_once ‘facebook.php’; $appapikey = ‘Your API Key’; $a...

PHP Birthday

This information took from http://www.sitepoint.com/ PHP was released by Rasmus Lerdorf on June 8, 1995. His original usenet post is still available online if you want to examine a computing artefact from the dawn of the web. Many of us owe our careers to the language, so here’s a brief history of PHP… PHP originally stood for “Personal Home Page” and Rasmus started the project in 1994. PHP was written in C and was intended to replace several Perl scripts he was using on his homepage. Few people will be ancient enough to remember CGI programming in Perl, but it wasn’t much fun. You could not embed code within HTML and development was slow and clunky. Rasmus added his own Form Interpreter and other C libraries including database connectivity engines. PHP 2.0 was born on this day 15 years ago. PHP had a modest following until the launch of version 3.0 in June 1998. The parser was completely re-written by Andi Gutmans and Zeev Suraski; they also changed the name to the recursive “PH...