Discussion:
Over-riding System Generated Constructor, Mutators and Observers for a UDT
(too old to reply)
t***@grapevine.com.au
2007-09-28 02:02:09 UTC
Permalink
I've been doing some investigation into UDTs as implemented by DB2 for LUW. One of the proported benefits of UDTs (and OO in general) is encapsulation. As long as the interface remains the same, the internals can be changed without impact. I take this to mean that both logic and data are "hidden". However, DB2 system generated constructor, mutators and observers (C-M-O) can't be over-ridden. So the internal representation (attribute data types) of the UDT are exposed. For instance, I might choose to represent a date using a db2 integer datatype within my UDT, but to expose it as db2 date datatype. But if you can't over-ride the system generated C-M-O, then I haven't really encapsulated anything, even if I've implemented my own methods / functions.
Knut Stolze
2007-10-02 18:15:29 UTC
Permalink
Post by t***@grapevine.com.au
I've been doing some investigation into UDTs as implemented by DB2 for
LUW. One of the proported benefits of UDTs (and OO in general) is
encapsulation. As long as the interface remains the same, the internals
can be changed without impact. I take this to mean that both logic and
data are "hidden". However, DB2 system generated constructor, mutators
and observers (C-M-O) can't be over-ridden. So the internal
representation (attribute data types) of the UDT are exposed. For
instance, I might choose to represent a date using a db2 integer datatype
within my UDT, but to expose it as db2 date datatype. But if you can't
over-ride the system generated C-M-O, then I haven't really encapsulated
anything, even if I've implemented my own methods / functions.
You should revoke all EXECUTE privileges on the observers and mutators. Then
you can add your parameterized, overloaded versions and grant EXECUTE
privileges only on those functions/methods. (That's the same as in other
OO-languages, where you have direct access to attributes within the class
itself and making them "private" actually hides them from the rest of the
world.)
--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
t***@grapevine.com.au
2007-10-05 05:08:07 UTC
Permalink
Many thanks for your comments Knut.

Loading...