Sometimes, we will may write conditional statements that may be valid still, and are unnecessary and cumbersome. Such statements often reflect a lack of understanding about how you can and should use language structures.
for exempli gratia :
one more classic example for the inefficient use of the boolena variable we can find at here;DECLARE   boolean_variable BOOLEAN;BEGIN   IF boolean_variable = TRUE   THEN      ...   ELSIF boolean_variable = FALSE   THEN      ...   END IF;
END;
what we are gonna acheive by redoing the thing already
the compiler is doing for us.
( havent u heard of word like " never try to re-invent the wheel " ) ;;)
here goes the simplification of the code .
It is implicit that the what the boolean is going to do for us,DECLARE   boolean_variable BOOLEAN;BEGIN   IF boolean_variable   THEN      ...   ELSIF NOT boolean_variable   THEN      ...   END IF;
END;
here u can see the idea behind this is to find the boolean, has it been celebrated.IF DOB '<' SYSDATE THEN   celebrated := TRUE;ELSE   celebrated := FALSE;END IF; 
may be simple thing here to notice will be.
there are only two state for the conditional statements.
here watch out carefully, the DOB can be NULL ;celebrated := DOB '<' SYSDATE;
The  above statement offers a comparable expression ;)  is it nt ?celebrated := NVL( DOB '<' SYSDATE);
( doing this may make ur code look expressive )
Friday, July 15, 2005
Dont ever try to redo the thing !
Posted by Vetriselvan at 7/15/2005 03:03:00 PM
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment