12
iFour Consultancy Coding Standards Best Practices

Coding standards and best practices

Embed Size (px)

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

Citation preview

Page 1: Coding standards and best practices

iFour Consultancy

Coding StandardsBest Practices

Page 2: Coding standards and best 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.

Page 3: Coding standards and best practices

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.

Page 4: Coding standards and best practices

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.

Page 5: Coding standards and best practices

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().

Page 6: Coding standards and best practices

Names from Mathematics

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

openParen = ( slash + asterix ) / equals;

Page 7: Coding standards and best practices

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.

Page 8: Coding standards and best practices

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.

Page 9: Coding standards and best practices

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.

Page 10: Coding standards and best practices

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.

Page 11: Coding standards and best practices

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

Page 12: Coding standards and best practices

THANK YOU!