Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in ExamLab question...

 
Hareendra Reddy
Ranch Hand
Posts: 173
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all...



The question is number of appropriate uses of assertions...

explanation is saying that the following usage is inappropriate ..

Here we are evaluating the argument passed to public method but we control the code that is cust value has been assigned 12,
so how this is considered as inappropriate??

Thanks
 
Amir Ashfaq
Greenhorn
Posts: 13
Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question has its answer.. as 12 is assigned within the code and you are sure about the value of "cust" after the execution of that line , so no need for assert "cust>=20".

As Assertion means your assumption, so why you will assume that the value will be >= 20, as you yourself has assigned it 12.


hope you understand...
 
T Vergilio
Ranch Hand
Posts: 230
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but it is not inappropriate, is it? You are assessing the value of a variable after you manipulated it, so it should be fine... I don't understand why it isn't either, Hareendra.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic