• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

assertions

 
janne kallio
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again!
I am having problems with figuring out the usage of Java's asssertions. I know that they are primarily intended for testing reasons and they can disabled/enabled etc.
But can anyone of you give me an example how these assertions related things can be tested in the exam? Can f.ex anyone that already has passed the programmer test, recall from their experiences how this feature was tested in their particular exam?
I would appreciate your experiences very much!
Cheers,
janne
 
Cathy Song
Ranch Hand
Posts: 270
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Janne,
Look at the questions related to assertions Dan has posted on this site:
http://www.danchisholm.net/
These will give you an idea about the type of questions to expect on the exam.
Thanks.
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that assertions are disabled by default!!!
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Questions can be asked on the appropriate use of assertions. For example, they might show a public method where assertions are used to validate passed parameters and ask if this is a valid use of assertions.
 
Doug Dunn
Author
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My first column in the Java Developer's Journal was "Using Assertions". You can read it at http://www.sys-con.com/story/?storyid=34283. Even experienced programmers are sometimes not sure when to use assertions. It is a difficult subject.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure how many use Assertions in their programs.
[ October 22, 2003: Message edited by: Pradeep Bhat ]
 
Jeff Bosch
Ranch Hand
Posts: 805
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a C background, and I have to do some stuff in C++. I celebrated when Sun added assertions because I found them invaluable in testing C/C++ code to make sure things don't break from passing invalid arguments, etc. Because Java doesn't permit conditional compilation as such, assertions are the closest tool the Java programmer gets to a conditional compilation.
Remember, assert is a programmer/tester debugging and testing tool; don't put any code in your assertions that the program relies on. I think that once the Java community appreciates the power of assertions, they (assertions) will be much more widely used and understood.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic