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 (27) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (112) C (77) C# (12) C++ (82) Course (60) Coursera (176) coursewra (1) Cybersecurity (22) data management (11) Data Science (85) Data Strucures (6) Deep Learning (9) Django (6) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (5) flutter (1) FPL (17) Google (18) Hadoop (3) HTML&CSS (46) IBM (25) IoT (1) IS (25) Java (92) Leet Code (4) Machine Learning (43) Meta (18) MICHIGAN (4) microsoft (3) Pandas (3) PHP (20) Projects (29) Python (719) Python Coding Challenge (155) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (40) UX Research (1) web application (8)

Followers

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