Login to Your Account

Free Recharge

View RSS Feed

Software Engineers BLOG

Avoid these mistakes while writing code

Rate this Entry
Avoid these mistakes while writing code

  1. Donít write deeply nested code
    It is bad programming style to write deeply nested code Ė the code has a tendency to drift across the page to the right and soon becomes unreadable. Try to limit most of your code to a maximum of two levels of indentation. This can be achieved by dividing the code into shorter functions.
  2. Donít write very large modules
    A module should not contain more than 400 lines of source code. It is better to have several small modules than one large one.
  3. Donít write very long functions
    Donít write functions with more than 15 to 20 lines of code. Split large function into several smaller ones. Donít solve the problem by writing long lines.
  4. Donít write very long lines
    Donít write very long lines. A line should not have more than 80 characters.
    if(objHideRevealPalette.tree["paletteButton.textHideIcon"].getSelected() || objHideRevealPalette.tree["paletteButton.textRevealIcon"].getSelected())
    Write above line like this:
    var bHide:Boolean = objHideRevealPalette.tree["paletteButton.textHideIcon"].getSelected();
    var bReveal:Boolean = objHideRevealPalette.tree["paletteButton.textRevealIcon"].getSelected();
    if(bHide || bReveal)
  5. Variable names
    Choose meaningful variable names Ė this is very difficult.
  6. Function names
    The function name must agree exactly with what the function does. It should return the kind of arguments implied by the function name. It should not surprise the reader. Use conventional names for conventional functions
  7. Format programs in a consistent manner
    A consistent programming style will help you, and other people, to understand your code. Different people have different styles concerning indentation, usage of spaces etc.
    For example you might like to write tuples with a single comma between the elements:
    Other people might use a comma followed by a blank:
    {12, 23, 45}
    Once you have adopted style Ė stick to it.
    Within a larger project, the same style should be used in all parts.

Career , Technology


  1. [FE].Zatak's Avatar
    thnx... useful
  2. shailendra's Avatar
  3. raghu's Avatar
    i think i must practice it,,,might b useful
  4. swathi2621's Avatar
    very very nice pls post some more tips
  5. karya's Avatar
  6. rohitjindal_2008's Avatar
    very good
  7. Rahul Dahake's Avatar
    Thanks 4 such a good tip
  8. apurvadhoot's Avatar
    thanx 4 guiding!!!!!!!!! very useful tips........