Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31289 > unrolled thread

best practices to prevent new bugs

Started byAjay Paul <ajaykpaul@gmail.com>
First post2015-03-08 13:33 -0700
Last post2015-03-08 21:05 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  best practices to prevent new bugs Ajay Paul <ajaykpaul@gmail.com> - 2015-03-08 13:33 -0700
    Re: best practices to prevent new bugs Martin Gregorie <martin@address-in-sig.invalid> - 2015-03-08 21:05 +0000

#31289 — best practices to prevent new bugs

FromAjay Paul <ajaykpaul@gmail.com>
Date2015-03-08 13:33 -0700
Subjectbest practices to prevent new bugs
Message-ID<0518334b-4613-4931-b324-05c36e089154@googlegroups.com>
Dear All,

I am looking some best practices while fixing bugs to prevent new bugs from coming up.

[toc] | [next] | [standalone]


#31291

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2015-03-08 21:05 +0000
Message-ID<mdidio$f4m$1@dont-email.me>
In reply to#31289
On Sun, 08 Mar 2015 13:33:44 -0700, Ajay Paul wrote:

> I am looking some best practices while fixing bugs to prevent new bugs
> from coming up.

Suggestions:

1) Develop a unit test harness and a comprehensive set of tests for 
   each class. Storing a set of validated expected results will allow 
   you to use these three elements to run regression tests each time the
   class is changed. The test suite for each class must be extended and
   revalidated each time the classes functionality is extended. 

   I think this should be mandatory for every class that is expected to
   be used in more than one program, though it may not be practical to
   carry out such fine-grained testing for classes that aren't intended
   for reuse.

   Before you ask, yes I do this for code I write for my own use too 
   and find it pays off in terms of more reliable code and fewer bugs.

2) Insist on having comprehensive class-level and method-level comments
   and keeping it up to date. Use javadocs to check the comments for
   readability. While this may not help with debugging when the code is
   initially written, it will be enormously helpful when the code is
   changed later.

   Yes, I do this for my own private code too and I do it because I find
   its useful.

3) Make sure the team library has a copy of The Practice of Programming
   by Kernighan & Pike and that junior members read it and take note of
   its recommendations, while its aimed more at C, its equally applicable
   to all block-structured languages and is helpful in a Java shop. If
   the team's development practices are based in its recommendations
   you'll find you're writing more easily debuggable and maintainable 
   code.
 

-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web