Recursion
:: -- The method calls itself. Until
condition is satisfied & executes in reverse manner.
Assertions
– 1.4 Ver
Very
common way of debugging is usage of SOP statements. Bu the problem with sops is
after fixing the bug compulsary we have to delete SOP statements otherwise
these sops will be executed at run time for every req, which creates
performance problem & disturbs server logging.
To
overcome this problem sun people introduced Assertions concept in 1.4 ver.
The
main adv of assertions when compare with Sops is after fixing the bug, we are
not required to remove assert statements because they wont be executed by
default at run time. Base don our requirement we can enable / disable
assertions & by default assertions are disabled.
Hence
the main objective of assertions is to perform debugging.
Simple
version
Augmented
version
Simple
Assertion::
assert(b) – b is of Boolean type – if b is
true our assumption is satisfied & hence rest of the program will be
executed normally.
If
b is false our assumption fails i.e somehwhere something goes wrong & hence
the program will be terminated abnormally by raising assertion error. Once we
got assertion error we will analyze the code & we can fix the problem.
By
default assert statements will not get executed but we can enable assertion by
using
-ea option
assert(x>10);
Augmented
version::::
assert(x>10):”x
is greater than 10”
No comments:
Post a Comment