Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Best coding practices


Published on

Coding practices

Published in: Education
  • Be the first to comment

  • Be the first to like this

Best coding practices

  1. 1. WELCOME
  2. 2. Best Coding Practices
  3. 3. Why • The rework time in coding is the actual killer • 20-25% of the time is spent in reworking in software – that means, fix the mistakes done It helps in • Greater consistency between developers • Easier to develop and maintain • Saves time and money
  4. 4. Areas Covered 1. Program Design 2. Naming Conventions 3. Documentation 4. Formatting Conventions
  5. 5. Program design Way of organizing the component structure, data structure, and control structure. • Use standard architectures – Eg: MVC • Type of data storage • Use of algorithms and flowchart
  6. 6. Naming conventions • Use full English descriptors • Use mixed case to make names readable – Camel casing and pascal casing – Or use underscore for separation • Avoid long names • Avoid leading/trailing underscores
  7. 7. Naming convention in Java Java follows camelcase syntax for naming Type Convention Class Should start with uppercase letter and be a noun e.g. String, Color, Button, System, Thread etc. Interface Should start with uppercase letter and be an adjective e.g. Runnable, Remote, ActionListener etc. Method Should start with lowercase letter and be a verb e.g. actionPerformed(), main(), print(), println() etc. Variable Should start with lowercase letter e.g. firstName, orderNumber etc. Package Should be in lowercase letter e.g. java, lang, sql, util etc. Constants Should be in uppercase letter. e.g. RED, YELLOW, MAX_PRIORITY etc.
  8. 8. Documentation (Comments) • Commenting is necessary for maintaining any program • Without commenting, the program is not complete • Do not assume that the other person who reads this program will understand it clearly • If commenting is not done at the beginning, it is forgotten.
  9. 9. Documentation (Comments) • Program - a physical file – you need to comment the following at the top. – at the top of the program - header comment – what the program achieves – who coded on what day • Classes – Comment at the beginning of the class about what the class does Ex: class Employee // this class is used to manage all information // about employees and retrieve specific data
  10. 10. Documentation (Comments) • Methods within classes – what this method/function/procedure does – what are the parameters and their purpose – what are the return values • Comment before every loop. • Comment before every file or database operation • Comment before every if condition
  11. 11. Formatting (Comments) • Indentation • White space • Opening and closing the braces/ block
  12. 12. THANK YOU