|No such thing as a small change|
Global Super Class (equivalent of java.lang.Object)by arunhorne (Pilgrim)
|on Sep 26, 2006 at 11:37 UTC||Need Help??|
arunhorne has asked for the
wisdom of the Perl Monks concerning the following question:
I have a question on good design practice/pattern that I would appreciate the inputs of others on...
Having started a new project from scratch I will be using Perl to implement an object based hierachy. If I look at a language such as Java I will see a class called java.lang.Object which is otherwise known as the "global superclass". The purpose of this class among other things is to provide some common functions (e.g. 'toString()' which provides a string representation of an instance which is useful for debugging).
My question, if you have not already guessed, is this. Although Perl does not explicitly provide such a global superclass (or correct me here if I am mistaken), it would seem like good design practice to create one called 'Object' and have all other classes inherit from it. Initially it may have no functions except 'to_str()', however, it provides a level of future proofing. Does anyone have any experience or advice on such an approach?