Thursday, 22 March 2018

Importance of use of Indentation in Programming

Remember that indentation is useful for people, not the machine Correct use of identifiers, white space and documentation makes your program easier to understand for those humans reading it. Since you also will be reading your own program, you will want to be consistent and current with your documentation.

  Properties of good style
    1. Program that are easy to read and understand.
    2. Programs that communicate the algorithm used in a form easy to follow.
    3.Programs that are easy to modify and enhance to adapt to new and changing environments.( It is important to keep in mind that the programmer making the modifications may not be the initial author.)

Principles of good style
  1. Clarity and simplicity
         Avoid unnecessary complexity.When possible,use the straight forward method.Don't sacrifice clarity for cleverness.
  2. Use meaningful identifiers
         Choose names for constant, variables,functions,etc. , that accurately describe the purpose of the identifier.For instance, a, x, t are poor identifiers because they are meaningless whereas age, salary, and first_name are good choices.Constant should be all uppercase. Other identifiers should make use of the underscore"_" and uppercase letters to distinguish the words in an identifier (FirstName or first_name but not firstname).
   3. One statement per line
   4. Use proper indentation of control structures.
         Be consistent with indentation.There are several styles to choose from but whichever you choose, be consistent! Some example are given below.Note the placement of the curly braces and the code.

0 Comments:

Post a Comment

Popular Posts

Categories

AI (33) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (146) C (77) C# (12) C++ (82) Course (67) Coursera (198) Cybersecurity (24) data management (11) Data Science (106) Data Strucures (8) Deep Learning (13) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (21) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (46) Meta (18) MICHIGAN (5) microsoft (4) Nvidia (1) Pandas (3) PHP (20) Projects (29) Python (893) Python Coding Challenge (285) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (42) UX Research (1) web application (8)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses