This document discusses best practices in PL/SQL including following principles like single point of definition (SPOD), using explicit cursors, avoiding hard coding and literals, practicing data encapsulation, and handling errors separately. It emphasizes defining objects once and reusing them, using explicit cursors over implicit ones for maintainability, hiding business rules in packages rather than having complex code blocks, and managing errors in a separate package.
2. Why Do we Need to follow
Best Practices???
? Good practices help to ensure that code is
developed properly
? Best practices help to ensure that code is in a
maintainable fashion
4. SPOD
? SPOD is well known as ¡°Single Point of
definition¡±
? SPOD simply implies that define once and use
every where!!!!
? Therefore, developer does not need to repeat
the code.
5. Explicit Vs Implicit
? Use Explicit cursors as much as possible in
code.
? Avoid to use ¡®select¡¯ implicit cursor
? Nevertheless, Steven Feuerstein has
recommended to use implicit cursor in the
code.
? BUT in IFS context, ¡®Explicit¡¯ cursors are
recommended!!!
6. Avoid!!
? Avoid Hard coding
? Avoid to use VARCHAR2(N) declaration
? Avoid to use ¡®Literal¡¯ value. But, use
name%type or name%rowtype
8. Data encapsulation
? Hide business rules and formulas!
? Move blocks of complex code such as Function
and Procedure
? Write small, Narrowly focused code
easy to reuse package