I need a suggestion on detecting the faults/bugs in a java program. To say I should check whether my program is faultless.
Varun Krishna. P
Google for JUnit and design unit tests, and then do extensive "business" tests as well. And then you will know that your program is as good as you are currently able to test it for, but some user will STILL find bugs (and you can only hope it isn't a hacker that does it first).
And even if you make something that contains no flaws of its own, it's going to be compiled by a compiler that might have flaws, run on a runtime that has flaws, which exists on an operating system with flaws that runs on hardware with flaws and is used by end users who are definitely flawed.
@masijade and @jwenting, thanks for your reply.
You say that it is not worth in checking for flaws?
Varun Krishna. P
Varunkrishna: that's not at all what he said.
what he says is: even if your code is perfect, there are always other variables that might be less than perfect, and cause problems.
for instance: a ton of bugs you might get, are just pebkac/pebcak errors.
I agree with all what have been said here.
I want to add a tiny trick : in applications with GUI, the developer might have put some
.printStackTrace() from the
This method uses the console as an output which is invisible from a "double-click" launching, to see those messages, you can try the command line:
java -jar MyApplication.jar
and how are you going to "detect it is faultless" anyway? Do you have perfect understanding of what it's supposed to do under any and all conditions, expected or otherwise?
And can you describe that knowledge mathematically in such a way that you could create a test that incorporates all those scenarios yet runs in a finite amount of time?
And how are you going to guarantee that that test itself is not flawed?
No, you can't ever get to a state where you can claim your program is faultless, in other words perfect.
At most you can get to a state where you can claim that you've exhausted all reasonable means to asserting that it will run nominally under a given set of conditions, then describe those conditions.
Tarek: even though that 'll work, it 's a bit a futile way of programming.
for any decent application, the developer would have applied logging rather than just print the stacktrace to a console.
We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.