coding standards and best practices

Post on 25-May-2015

504 Views

Category:

Technology

32 Downloads

Preview:

Click to see full reader

DESCRIPTION

The importance of coding standards and best practices for software companies in India. https://vimeo.com/99606251 https://www.youtube.com/watch?v=2nPHqIJDEmI

TRANSCRIPT

iFour Consultancy

Coding StandardsBest Practices

What you can do

Best Practices of coding standards are set of informal rules followed for sometime

These help in improving the quality of the software

Best Practices help in maintainability, dependability, efficiency and usability.

Single Letter/Very Short variable names

By naming your variables a,b,c, etc., not only will no one know what they are, it also makes it impossible to search for them with a text editor.

Instead use meaningful variable names that would give a sight to the item that is being represented by the variable.

For example – If we are to calculate the weight of a book, naming the variable bookWeight would be a better practice than using bw.

Naming

1. In naming functions and variables, original Hungarian notation for programming is used.

2. This specifies that a lowercase abbreviation should prefix all variable names with the remainder in upper camel case.

3. For example – When calculating the weight of a book, we would be using the variable as bookWeight or bkWeight rather than Bookweight or BookWeight or BKWeight, etc.

CapiTaliSaTion

1. When naming a function, we should be capitalizing the first letter of every word in the function name.

2. Randomly capitalize the first letter of a syllable in the middle of a word. For example: ComputeRasterHistoGram().

Names from Mathematics

1. Choose variable names that masquerade as mathematical operators, e.g.:

openParen = ( slash + asterix ) / equals;

Bedazzling Names

1. Choose variable names with irrelevant emotional connotation. e.g.:

Marypoppins = ( superman + starship ) / god;

This really confuses the reader because they have difficulty disassociating the emotional connotations of the words from the logic they're trying to think about.

Uppercase l looks a lot like the number 1

1. Use lower case l to indicate long constants. e.g. 10l is more likely to be mistaken for 101 that 10L is.

Using Comments

• Comments are used while writing codes for applications.

• Writing comments helps other team members or people working outside the application to understand the code better.

Red Herrings

Pepper your code with variables that are never used and methods that are never called. This is most easily done by failing to remove code that is no longer used. You can save the code on grounds someday it may need to be revived. You get bonus points if these drone variables and methods have names similar to actual worker ones. The maintenance programmer will inevitably confuse the two. Changes made to drone code will happily compile, but have no effect.

Advantages and Disadvantages of Best Practices

Advantages- Accountability- Enforces coding standards- Ensures correct systems are being used- Education and discovery of the code base- Ensures correctness of code

Disadvantages- Hard to enforce- Lack of time to enforce

THANK YOU!

top related