The attribute
string has to be packed with the corresponding columns/values when using the
methods
New__/Modify__.
Inside those methods, Unpack___
converts the attribute string into a table record. Then
Check_XXX___
methods carries out the validations. Packing and unpacking
adds unnecessary overheads in server-to-server method calls. Using table
records directly to perform validations and data manipulations avoids this
overhead. More importantly, when working
with records you are always future proofed, even if columns are added or removed from
the table.
This method requires all the attributes needed for the new record as individual
parameters. The parameters are then packed into an attribute string. The
New__
method unpack, validates, and then inserts the record by calling the
Unpack___
, Check_Insert___
and Insert___
methods. This type
of implementation often worsens
the performance and also has
other disadvantages, including a more complex code which harder to maintain
and read.
If we can use a table record as input, then we do not need to list all the columns as method arguments. Then we can use base methods that already exist in the package, which will future proof the solution. Columns can then be added to, or removed from the table without interfering with the code.
If business validation is needed you simply call the New___
method (which will call Check_Insert___
, where validation is done).
Validating the data is generally the recommended solution, but if you can
guarantee the validity of incoming data you can skip all validations and call the
Insert___
method directly. This will improve the performance even
more.