Indeed, Max is right that my primary objective has been to keep it
simple. Initially, there was quite a lot of scepticism about the
usefulness of object-oriented programming for econometrics and
statistics (including myself!). I think that has changed now with the
spread of Ox packages.
The advantage of the current approach is that it can be undderstood in
about a day or so, while I'm still occasionally trying to understand
some new (to me) C++ features, after many years of using it.
Having said that, Ox has to be flexible enough to program effectively,
so perhaps it is time to consider adding some features to the language.
Further suggestions and ideas on this are very welcome. For example, I
would consider the public and protected keywords useful, but have a
strong dislike of private (which quite often turns out to be a design
error).
Jurgen.
[log in to unmask] wrote:
> Hi Marek,
>
> (I apologise for the lengthy email, but you have touched upon something
> that I have been thinking about.)
>
> I guess Jurgen's reason here is to keep the object-oriented part of Ox
> simple. Although he probably hasn't run into situations where he would
> want public member variables, he has run into situations where he would
> like private methods - at least that is how I interpret his prefacing
> functions with an underscore in some of the packages that come with
> Ox ;-P
>
> I think there are often other good reasons for using methods rather than
> accessing member variables directly - for example in something like the
> Observer - Property design pattern, for e.g. something like lazy
> evaluation of a formula. Suppose your class represents some complicated
> function that takes a lot of time to calculate, and you change a
> parameter. Doing this via a method (rather than accessing the member
> directly) allows the class to know that one of its parameters has
> changed. If you then request the value of the function, it knows it has
> to recalculate. If you requested the value of the function without
> having changed a parameter, the class would know that it doesn't have to
> recalculate, and it would save you some expensive calculations. This is
> superior to more messy ways of keeping track of what needs to be
> recalculated.
>
> You might also just want to validate input on SetX(somevalue) calls (e.
> g. make sure that the matrix has the right dimensions etc).
>
> Having said this, personally, I wouldn't mind a little bit of extra
> choice and complexity by having private, public and protected member
> variables (and methods!).
>
> Note that if you want to save yourself a bit of typing, you could use
> "polymorphic" properties like so:
> class myclass
> {
> decl X;
> X(...);
> }
> myclass::X(...)
> {
> args = va_arglist();
> if(0==sizeof(args))
> return X;
> else
> X = args[0];
> }
>
> You can then write myinstance.X() if you want to get the value, and
> myinstance.X(value) if you want to set it. People do this e.g. in C++,
> it just looks a little more clumsy in Ox because you can't define the
> same method for different numbers of arguments.
>
> My main gripe with the object-oriented bit of Ox actually is the lack of
> being able to separate implementation inheritance from interface
> inheritance (either multiple inheritance or "myclass(baseclass)
> implements interface" as in Java). Personally, I feel this is more of a
> problem than the fact that all member variables are private.
>
> Max
>
>
> On Tue, 2004-11-16 at 10:12 +0000, Marek Jarocinski wrote:
>
>>Dear Jurgen,
>>
>>Often I find myself mechanically typing functions interfacing to member variables, like MyClass::GetX() and MyClass::SetX(const x), when I would prefer to access them directly by myclassobj.x
>>What is the reason for making all member variables private? Have you considered relaxing this in the next version of Ox?
>>
>>Greetings,
>>
>>Marek
>>
>
> --
> [log in to unmask] <[log in to unmask]>
>
--
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
oxoxoxox 3rd OxMetrics user conference August 2005
oxoxoxox Cass Business School, London
oxoxoxox Dates still to be announced
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
Dr Jurgen A Doornik
Nuffield College, Oxford OX1 1NF, UK
tel. UK: +44-1865-278610 fax +44-1865-278621
http://www.doornik.com
http://www.oxmetrics.net
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
|