aspose file tools*
The moose likes Beginning Java and the fly likes Using assert/debugger Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Using assert/debugger" Watch "Using assert/debugger" New topic
Author

Using assert/debugger

Preeti Yarla
Ranch Hand

Joined: Sep 08, 2007
Posts: 69
In all of my code (amateur learner code) I never used assert, because I was thinking that I don't need an assert when I am using a debugger. But in the industry does your boss expect you to use assert even if we have a debugger? (OR no one cares as long as you can debug?)

Thanks.


SCJP
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
I assume it would depend on the standards of the company. What the company uses (does), you use (do).

Justin Fox


You down with OOP? Yeah you know me!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18141
    
    8

Assertions and debugging are tools which are used for different purposes. Approximately speaking, assertions are used to ensure that code is doing what it is supposed to do. One normally assumes (hopes) that assertions will not be triggered, except during the testing phase. In that way they are a support tool for testing.

But debugging is used to find out why a program is not doing what you think it should be doing. Debugging only helps you to find out what happened on one particular run of your code. You aren't going to debug every single line of your code for every single test case and verify on a checklist that the right thing is happening.

So don't be surprised if you find both assertions and debugging being used.
Preeti Yarla
Ranch Hand

Joined: Sep 08, 2007
Posts: 69
Thanks Paul! Thanks Justin.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Originally posted by Paul Clapham:
But debugging is used to find out why a program is not doing what you think it should be doing.


This certainly is a common use for the debugger, but is not the only one.

It is often productive to use the debugger to step through your new code, even when you do not have a specific bug to find. By doing so, you verify that variables really do have the values you think they should, and that the path through the code is what you expect.

You can't do this for every piece of code, but when you have written something short, but complicated, it can be invaluable.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using assert/debugger
 
Similar Threads
junit.framework.Assert Class?????
NX:Create/Delete invalid data
[Bodgit Scrapper] what's the meaning of magic cookie value?
JUnit : AssertionFailed on String Comparison
Assert syntax