Thanks and Regards
Souvik
SCJP, SCWCD, OCEJWSD
Alam Ameghino wrote:Thanks for response Souvik!
I believe the same, but I am not sure.
Someone knows exactly what is the answer?
OCAJP 7, OCPJP 7
Alam Ameghino wrote:
We know that is not correct to use assertion for validate args in public method. So, in the next example, line 02 is not a good use of asertions.
William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Not sure why you are saying it because line #2 looks perfect to me.
Alam Ameghino wrote:Nick, thanks for the link and your answer.
But, I can not see the answer to me question in this link!
Where do you see the answer in the link?
OCAJP 7, OCPJP 7
Alam Ameghino wrote:
Hi Nick, and again thanks!
Mmmmm, I am not agree..
You must say if assertions are appropriate or not in COMPILE-TIME, no in RUNTIME-TIME.
OCAJP 7, OCPJP 7
Alam Ameghino wrote:I know thtat assertions work only in runtime, but you must say if they are appropiate or not in compile-time.
You don't need run a program for know if assertions are appropiate or nor!
As a rule, the expressions contained in assertions should be free of side effects: evaluating the expression should not affect any state that is visible after the evaluation is complete. One exception to this rule is that assertions can modify state that is used only from within other assertions. An idiom that makes use of this exception is presented later in this document.
OCAJP 7, OCPJP 7
Alam Ameghino wrote:I think that my poor ingles is a problem in this case. Sorry.
See friend,
From Kathy and Bert's book
Page 392. Title: Don't use assertions to validate arguments to a public method.
So, it is not correct:
Page 393. Title: Do use assertions to validate argument to a private method
So, it is correct.
But, What happen when in a private method we are validating an argument that belong to the previous public method? The argument is the same, the same object in both.
Thanks Nick.
Sorry if I am not being clear.
OCAJP 7, OCPJP 7
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|