Object Oriented Automatic Method Generation
Oracle Database Tips by Donald Burleson
In most object-oriented and
object/relational databases, the basic methods for all objects are
created automatically at the time that the object class is defined.
These basic methods are used when objects are created, deleted, updated
and displayed, and would correspond to the INSERT, DELETE and UPDATE SQL
verbs. It is important to recognize that methods exist in several forms
within the database engine.
1. Standalone methods - These methods are not associated with a database class.
2. Base class methods
3. Aggregate class methods
However, more complex methods can be coupled to their target objects. For
example, an order_form object might contain a method called
check_payment_history which performs detailed checks into the prior payment
history for the customer who is placing the order.
Now, let's take a look at our analysis of the methods that might be associated
with these objects. Whenever a method of the same name appears in more than one
class definition, the database will look first at the object, and traverse up
the class hierarchy at runtime, looking for the method.
Methods for student:
Methods for graduate_student;
Methods for non_resident_students;
Methods for foreign_students;
Here we see that some methods that are unique to the sub-class appear only
within the sub-class definition. For example, update_thesis_status would not
have any meaning to an undergraduate student.
This should now provide a general method for the mapping of processes to
database objects. As we have repeatedly stated, it is critical to the design of
an object database that careful planning of the methods take place before the
database schema is defined.
It cannot be overemphasized that it is critical to the design of a database
object system that careful attention be given to the placement of methods. The
concept of overloading can be very powerful, since new code can be introduced
into the system with absolute certainty that no unintended side-effects will be
introduced. This is because the new method will only be known to objects within
that class of sub-classes. Objects that belong to other class will never know
that the new method exists.
Now that we understand the issues relating to the placement of methods, let's
take a look at how the object/relational model allows for the definition of
aggregate objects, that is, objects that are composed of other objects.