Determining when to use built-in or user-defined routines

Built-in routines provide you with time-saving ready-to-use encapsulated functionality whereas user-defined routines provide you with the flexibility to define your own routines when no built-in routine adequately contains the functionality that you require.

Procedure

To determine whether to use a built-in or user-defined routine:

  1. Determine what functionality you want the routine to encapsulate.
  2. Check the list of available built-in routines to see if there are any that meet some or all of your requirements.
    • If there is a built-in routine that meets some, but not all of your requirements:
      • Determine if the functionality that is missing, is functionality that you can add simply to your application? If so, use the built-in routine and modify your application to cover the missing functionality. If the missing functionality is not easily added to your application or if the missing functionality would have to be repeated in many places consider creating a user-defined routine that contains the missing functionality and that invokes the built-in routine.
      • If you expect that your routine requirements will evolve and that you might have to frequently modify the routine definition, consider using a user-defined routine rather than the built-in routine.
      • Determine if there are additional parameters that you might want to pass into or out of the routine. If there are, consider creating a user-defined routine that encapsulates an invocation to the built-in routine.
    • If no built-in routine adequately captures the functionality that you want to encapsulate, create a user-defined routine.

Results

To save time and effort, whenever possible consider using built-in routines. There will be times when the functionality that you require will not be available within a built-in routine. For these cases you must create a user-defined routine. Other times it might be possible to include a call to built-in routine from a user-defined routine that covers the extra functionality that you require.