• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using assert/debugger

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I assume it would depend on the standards of the company. What the company uses (does), you use (do).

Justin Fox
 
Marshal
Posts: 28137
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul! Thanks Justin.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic