Solomon Yakobson wrote:Also, the package body can be wrapped so the code is not easily accessible to prying eyes, whilst the specification remains 'public' (as you say) so that people can interface with the package without having to concern themselves with how those procedure/functions etc. are actually implemented... making the package a 'black box'.
Several reasons. We can hide functionality. What we declare in package specification is public (don't confuse with user PUBLIC). Procedures/functions/cursors/variables... declared in package specification can be accessed by anyone who has execute privilege. Procedures/functions/cursors/variables... declared in package body but not in package specification are private and can't be fererenced outside the package even if user has execute on the package. Secondly, we can recompile package body without invalidating objects that are referencing the package. Possibly there are some other advantages.