0% found this document useful (0 votes)
3 views

2. Programming Style

Programming style encompasses the techniques used in writing source code to enhance readability and minimize errors. Key guidelines include clarity, appropriate naming, control constructs, information hiding, and avoiding deep nesting, among others. Adhering to good programming style leads to more maintainable and understandable code.

Uploaded by

ptpt8091
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

2. Programming Style

Programming style encompasses the techniques used in writing source code to enhance readability and minimize errors. Key guidelines include clarity, appropriate naming, control constructs, information hiding, and avoiding deep nesting, among others. Adhering to good programming style leads to more maintainable and understandable code.

Uploaded by

ptpt8091
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming Style

Programming style refers to the technique used in writing the source code for a computer program. Most
programming styles are designed to help programmers quickly read and understands the program as well as avoid
making errors. (Older programming styles also focused on conserving screen space.) A good coding style can
overcome the many deficiencies of a first programming language, while poor style can defeat the intent of an
excellent language.

The goal of good programming style is to provide understandable, straightforward, elegant code. The programming
style used in a various program may be derived from the coding standards or code conventions of a company or
other computing organization, as well as the preferences of the actual programmer.

Some general rules or guidelines in respect of programming style:

1. Clarity and simplicity of Expression: The programs should be designed in such a manner so that the objectives
of the program is clear.

51.7M
950
Difference between JDK, JRE, and JVM

2. Naming: In a program, you are required to name the module, processes, and variable, and so on. Care should be
taken that the naming style should not be cryptic and non-representative.

For Example: a = 3.14 * r * r


area of circle = 3.14 * radius * radius;
3. Control Constructs: It is desirable that as much as a possible single entry and single exit constructs used.

4. Information hiding: The information secure in the data structures should be hidden from the rest of the system
where possible. Information hiding can decrease the coupling between modules and make the system more
maintainable.

5. Nesting: Deep nesting of loops and conditions greatly harm the static and dynamic behavior of a program. It also
becomes difficult to understand the program logic, so it is desirable to avoid deep nesting.

6. User-defined types: Make heavy use of user-defined data types like enum, class, structure, and union. These data
types make your program code easy to write and easy to understand.

7. Module size: The module size should be uniform. The size of the module should not be too big or too small. If
the module size is too large, it is not generally functionally cohesive. If the module size is too small, it leads to
unnecessary overheads.

8. Module Interface: A module with a complex interface should be carefully examined.

9. Side-effects: When a module is invoked, it sometimes has a side effect of modifying the program state. Such
side-effect should be avoided where as possible.

You might also like