DOCX

good programming practice

By Louise Parker,2014-10-11 23:44
11 views 0
good programming practice

    Good Programming Practice

    1 Make the last character printed by a function a newline(\n). 2 Place a space after each comma( , ) to make programs

    more readable.

    3 To avoid ambiguity, do not use the same names for the

    arguments passed to a function and the corresponding

    parameters in the function definition.

    4 Capitalize the first letter of an identifier used as a

    user-defined type name.

    5 Use only uppercase letters in the names of enumeration

    constants. This makes these constants stand out in a program

    and reminds the programmer that enumeration constants are

    not variables.

    6 Declaring a variable as global rather than local allows

    unintended side effects to occur when a function that does

    not need access to the variable accidentally or maliciously

    modifies it. This is another example of the principle of least

    privilege.

    7 Avoid variable names that hide names in outer scopes.

    This can be accomplished by avoiding the use of duplicate

    identifiers in a program.

    8 For clarity and readability, use each access specifier only

    once in a class definition. Place public members first, where

    they are easy to locate.

    9 Place all friendship declarations first inside the class

    definition's body and do not precede them with any access

    specifier.(friend function is not member function) 10 the friendship relation isneither symmetric nor

    transitive; i.e., if class A is a friend of class B, and class B is a

    friend of class C, you cannot infer that class B is a friend of

    class A (again, friendship is not symmetric), that class C is a

    friend of class B (also because friendship is not symmetric),

    or that class A is a friend of class C (friendship is not

    transitive).

    11

Report this document

For any questions or suggestions please email
cust-service@docsford.com