We are working on an existing project that has already been developed. We've been asked to use Parasoft's Jtest software to do coding standards as well as unittesting.
A)We are adding essentially a bunch of preconditions and postconditions that check if any of the inputs/outputs are null. Is there any benefit to this? Does anyone know a better/more useful approach to this?
B)We realize that DbC is best used during the development phase, but since this is already developed, is there any value to our efforts? Can any good come about from adding DbC comments post-development?
Cody, a) The null @pre checks are the minimum required checks to get JTest to point out fewer errors. Be careful of applying them blindly though. Sometimes it is valid to pass a null. And if you are adding the null @pre check whereever JTest complains about an error, that is equivalent to supressing an error. It doesn't actually make the code more robust unless you change the code.
b) While it is good to document after the fact, it can be overwhelming. You have to go back and think about what the methods do and what contracts you were thinking about when you wrote them.
Cody, do you know *why* you've been asked to "use Parasoft's Jtest software to do coding standards as well as unit testing"? That is, what is your goal of doing so?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ilja brings up a good point. I'd also like to mention that I find JTest's coding standard checking more valuable than its unit testing.
Joined: Aug 02, 2004
A few guys and I have been asked to simply evaluate the usefulness of JTest on a part of a larger project (just a small test). The current goal is only to make this code more stable. But the overall goal is to find out if Unit Testing can be useful post-development.
I agree with your comments on the coding standards and how they can even add to the code post-development. But I am still just curious if (in post-development) any good can come of using Unit Testing. It is quite a bit of work to re-think every method, in your opinion is this a waste of time?
Cody, I think there are two main advantages to using JTest post-development for your use.
1) Evaluate and learn how to use the tool - it is easier to evaluate when you aren't so focused on a coding task and deadline. 2) Fine "problem classes" - any classes with a higher number of errors than similar classes warrants further inspection.
It's a great time to learn how to use DBC, but I don't think it's practical to spend the time to do DBC for lots of already written code.