1 / 16

Quality and Readability of the code

Quality and Readability of the code. Criteria covered in this presentation. The importance of the quality of the code. High quality code is important to ensure having an efficient, a reliable, a robust, a usable, a portable and an easily maintainable system Efficiency Reliability

kynan
Télécharger la présentation

Quality and Readability of the code

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Quality and Readability of the code

  2. Criteria covered in this presentation

  3. The importance of the quality of the code High quality code is important to ensure having an efficient, a reliable, a robust, a usable, a portable and an easily maintainable system • Efficiency • Reliability • Robustness: • Usability • Portability • Maintainability

  4. Efficiency • The goal of code efficiency is to reduce resource consumption and completion time as much as possible with minimum risk • Code efficiency is directly linked with the speed of runtime execution for software. • Can be achieved through using appropriate data types, functions, procedures and try catch statements

  5. Reliability • Will your code function every time it is run? • Will it break down, will it throw out errors? • Will it produce different results even though you're running the same data through it?

  6. Robustness • Provide predictable documented behaviour in response to errors and exceptions. • Do not hide errors and do not force clients to detect errors. • E.g.; data entry validation and displaying error messages using if and using try catch statements

  7. Usability • How easy is the code to use • Can an untrained user use the code • How easy is the code to edit

  8. Portability • Can your code be used on different computers, different operating systems • Can your code be used in different companies, or different countries

  9. Maintainability • How easy is it to edit the code • How often do people have to update the code • How well commented is the code • The most important factor that affects the maintainability of a program is its readability which is discussed in the coming slides

  10. Readability of the code • Readability describes the ease of which programs can be read and understood. • It is so important because it significantly effects the maintainability of code which has in turn been a major cost for programs.

  11. Factors that improve the readability of code • Comments • Appropriate naming scheme • Indentation • Code grouping • DRY Principle

  12. Comments • Comments are usually added with the purpose of making the source code easier to understand • Comments are used to explain the intent of the programmer • It’s a good practice to include the name of the programmer and last date of modifying the program at the top of the program in form of comments

  13. Appropriate names for variables • Meaningful names that match the purpose it’s used for, like: name and age instead of n and a for to save values of name and age respectively • Consistent Naming Scheme: The names should have word boundaries. There are two popular options: • camelCase: First letter of each word is capitalized, except the first word, like: netPrice, discountAmount • underscores: Underscores between words, like: net_price, discount_amount

  14. Indentation • It is a good idea to keep your indentation style consistent. • Automatically done through visual studio

  15. Code Grouping • Most often, certain tasks require a few lines of code. It is a good idea to keep these tasks within separate blocks of code, with some spaces between them.

  16. DRY Principle • DRY stands for Don’t Repeat Yourself. Also known as DIE: Duplication is Evil. • The principle states:“Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.” • This principle should be maintained in all code. The same piece of code should not be repeated over and over again. • Like using functions and procedures

More Related