comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Need advice about inheritance
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Need advice about inheritance [message #44182 is a reply to message #44098] Mon, 23 May 2005 08:34 Go to previous messageGo to previous message
Antonio Santiago is currently offline  Antonio Santiago
Messages: 201
Registered: February 2004
Senior Member
> ADD returns a new instance. I use OBJ_NEW("data",...) to create the new
> instance. How do I get the ADD method of the DATA class to return a
> TIMEDATA without copying the code to the TIMEDATA class and changing
> the OBJ_NEW call? Is it proper to get the current class type string
> (OBJ_CLASS(self)) and use that in the OBJ_NEW call, or is there a
> better way?
>
Sorry, but I don't understand well (perhaps because I am a bad english
reader).

I suposse when you want to create a new object you know what type of
object create, no? Then if you want to create a TIMEDATA object the call is:
OBJ_NEW('TimeData', x, y)

Why do you need to create an OBJ_NEW('Data', ...) to create an
TIMEDATA?? On a DATA object you can't invoque TIME operation, this is
responsability of TIMEDATA class.

Inside TIMEDATA class (I suposse) you invoke the DATA::Init method, also
I suposse the DATA class is more closely to be an storage site (stores
x, y) where its subclases retrieves the x, y values and interprets on
its own way.

Then the TIMEDATA::Add method gets x, y values and makes a time
addition. If the code of TIMEDATA::Add is the same as the DATA:Add then
you dont need to write the code, simply when you invoke TIMEDATA::Add
really you are invoqing the DATA:Add method.


> For the "data" class, all parameters have names that include "X" and
> "Y" (like "MAXX", "XVALUES", etc.). For the "timedata" class, I
> overwrite many functions to modify the parameter names to include
> "TIME" and "VALUE" (like "MAXTIME", "TIMES", etc.). That's why the
> init parameters are different. Is there a better way to handle this?

Finally, in my own opinion, you shouln't put this names to your methods.
When you creates a TIMEDATA object you known this is related with time
and then Add method makes an addition with time values. This notation
can complicate your code when use polymorphym (I think this is what you
want with you ADD method in DATA and TIMEDATA classes).

Bye Mr. W. :)
(from Mr. A)


--
-----------------------------------------------------
Antonio Santiago P�rez
( email: santiago<<at>>grahi.upc.edu )
( www: http://www.grahi.upc.edu/santiago )
( www: http://asantiago.blogsite.org )
-----------------------------------------------------
GRAHI - Grup de Recerca Aplicada en Hidrometeorologia
Universitat Polit�cnica de Catalunya
-----------------------------------------------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: array of pointers inside a structure
Next Topic: Re: mosaic two images in direct graphics

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 02:37:12 PDT 2025

Total time taken to generate the page: 1.85070 seconds