RatRating

coding style in software engineering

Coding/Programming style in software engineering

Programmers have their own style of writing programs. Good programming style makes the code easy to understand, not only for other people but also for the programmer himself.


coding style in software engineering

Importance of programming style.

Programming style is important for some of the main or important reasons.

To simplify software maintenance
  • Readability implies clarity and understandability.
  • Programs have to be read to be maintained.
To avoid problems
  • Good style can avoid common bugs and typos.
  • Good style can make mistakes clear.
To achieve simplicity
  • Consistency is simplicity
To achieve readability
  • By yourself and others
  • Now and a year from now

General Program Style

  • If you have to use global variables, use long descriptive names.
  • Never guess about data structure sizes.
  • Variables names should be mnemonic, clear, and simple, e.g., largest rather than x.
  • Expressions should be clear and simple.
  • Indentation and formats
  1. Indent bodies of structured statement at least 3 spaces
  2. Leave blank lines between logically related groups of statements, after the declarations, and between functions.
  3. Clearly delineate subprograms (procedures, functions, modules).
  4. Wrap long lines at no more than 80 characters and indent the continued statement further than the beginning of that statement.
  • Make use of the features of the language, i.e., if the language has a useful built-in feature, use it.
  • Procedure and function names should be mnemonic.
  • Local variables should be declared at the beginning of the function.
  • Use purify to plug memory leaks and detect memory access violations.
  • If what you're doing seems clever, think of another way to do it.
Good Programming Style
  • Here are some components of good style:
  • Naming conventions (variables, controls, and subroutine names)
  • Indented and properly spaced code.
  • Documented code.
  • Cohesive Modules.
  • Minimum Coupling.
  • Minimize data scope where possible.
Good Programming Style Aids

Modifiability
  • Code must be easily understood and modified.
  • Almost every code is modified during its lifetime.
  • A good style will help people to easily modify other's code.
Transportability
  • To increase productivity and usability, a program should be easy to transport to different environments and computers.
  • A good style of programming is to isolate all machine-dependent areas of code and label them as such.
  • Input/Output is a typical area where machine/operating system dependencies surface.
Readability
  • Use of good indentation blanks lines and comments aid in reading sections of code.
  • To improve readability, use identifiers that mean something or are relevant to the values they represent.
  • Separate blocks of self-contained code with spaces, comments,  and blank lines.
  • Indent segments of code in loops or in the conditional statements.
  • Make good use of procedures and functions to modularise the program.
  • If it has to be modified or transported it must be able to understand easily by the modifier/ transporter.
Usability
  • The user should be presented with a consistent, easily understandable, and friendly interface.
  • Use error recovery techniques that help the user. Also, make certain that your error messages are consistent and helpful.
  • Make certain that your prompts are consistent and contain all needed information for the user.
  • A frustrated user will blame the programmer rather than him/her.
  • User Interface management systems are becoming increasingly important in computing especially with the advent of graphical workstations with windowing systems.
Efficiency 
  • A well thought out program is nearly always an efficient program.
  • Efficiency is not without reducing readability to zero. This is efficient with restrictions.

Post a comment

0 Comments