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


Groups > comp.lang.java.programmer > #31291

Re: best practices to prevent new bugs

From Martin Gregorie <martin@address-in-sig.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: best practices to prevent new bugs
Date 2015-03-08 21:05 +0000
Organization A noiseless patient Spider
Message-ID <mdidio$f4m$1@dont-email.me> (permalink)
References <0518334b-4613-4931-b324-05c36e089154@googlegroups.com>

Show all headers | View raw


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       |

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

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

csiph-web