Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2003
    Location
    Australia
    Posts
    217

    Unanswered: Error prevention in coding (1)

    Error prevention is NOT complete if it is only done in the early stages of software development. So, what do we need to do to facilitate error prevention in coding?

    The basic principles:
    1) Write codes that are easy to read ;
    (2) Write codes that can be tested easily and independently ;
    (2) Aim for absolute correctness, not conditional correctness ;
    (3) Establish several layers of abstraction if possible ;
    (4) For each table, for any functional purpose, a piece of code should appear in 1 place only.
    __________________________________________________ _______________
    Zhimin, on that day when I saw you off at the airport, sadness overcame me. I really wished you'd stay. All I'd do was just giving you a kiss motivated from my heart, to express my love. Zhimin, my feelings clearly indicated I love you.
    Last edited by Lepanto; 10-23-05 at 01:48.

  2. #2
    Join Date
    Jul 2003
    Location
    Australia
    Posts
    217
    These basic principles might seem simple, but in fact few programmers know them OR put them into action. Software developers should be more concerned with "error prevention" than "error detection".

    I've even seen senior programmers who do not care about error prevention. Their style is "error detection" rather than "error prevention" - they allow themselves to inject as many bugs as possible and then fix them one by one afterwards --- consequently, they spent more time in building the same software than programmers who adopt "error prevention" strategies.

    Programmers who have no concern for quality management do not fit in a CMM Level 3 (or above) organisation environment.
    Last edited by Lepanto; 10-23-05 at 01:38.

  3. #3
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Use modular coding. Write a function/class. Debug it thoroughly. Then, use that module whenever possible.

    Avoid global variables.

    Use a consistent naming scheme. Personally, I like hungarian, but, whatever format you use, be consistent.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  4. #4
    Join Date
    Jul 2003
    Location
    Australia
    Posts
    217

    further descriptions

    1) Write codes that are easy to read ;
    If programs are hard to read, then there is higher chance for bugs to creep in.
    They are also harder to review and debug.

    (2) Write codes that can be tested easily and independently ;
    This saves testing and debugging time and efforts.

    (3) Aim for absolute correctness, not conditional correctness ;
    Very often programmers write codes that only work in certain circumstances.
    That is not good enough -- should try to write programs which work in all circumstances.

    (4) Establish several layers of abstraction if possible ;
    Establish a level for business logic or rules, another level for database operations, etc.

    (5) For each table, for any functional purpose, a piece of code should appear in 1 place only.
    Just as normalization removes data duplication and ease data updating, principle #5 removes program code duplication and ease code maintenance.
    Last edited by Lepanto; 11-07-05 at 21:48.

  5. #5
    Join Date
    Jul 2003
    Location
    Australia
    Posts
    217
    Are there any modifications or additions needed ??

  6. #6
    Join Date
    Jul 2003
    Location
    Australia
    Posts
    217
    Plan your program before coding.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •