POV-Ray : Newsgroups : povray.general : CSDL: C-like Simulation Description Language : Re: CSDL alpha 1 release Server Time
7 Aug 2024 09:18:55 EDT (-0400)
  Re: CSDL alpha 1 release  
From: Christopher James Huff
Date: 23 Jan 2002 17:53:06
Message: <chrishuff-DD8692.17540723012002@netplex.aussie.org>
In article <3c4f310d@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

>   I'm not completely sure what you are talking about, but that sounds a bit
> like very dubious coding.
>   Do you mean that your Copy() method allocates dynamically a new instance
> of its own type, copies itself to it and then returns a pointer to this new
> instance?
>   That really badly breaks modular OO design.

And how else am I supposed to get a copy?
That isn't exactly what it does, it relies on the constructor to copy 
the information, but a virtual Copy() method is the only way to make 
sure the correct constructor is called when I don't know the exact type.


> : Having to return void pointers and cast them to the 
> : correct types.
>   I never have to do this. It also breaks badly modular OO design.

Which is why I don't like it. I'll probably move to casting the data 
wrapper type to the right subclass, and having the subclasses return the 
data intact...that isn't really any prettier of a solution, but will let 
me get rid of the void pointers, which make me nervous.


> : Mostly having what I can do with an object being 
> : determined by the type of pointer to it I have, instead of what the 
> : object can do.
>   I don't understand this one.
>   Are you sure you fully understand object-oriented design?

In C++, if you have a derived object that implements a certain method 
not in its base class, but only have a base-class pointer to it, you 
can't call that method unless you cast to that type. It's a pain that 
produces ugly code, that's all. In Objective C, the methods you can call 
are determined by what the object itself responds to, at runtime, not by 
the type of pointer you have.


>   You are also talking too much about pointers. Sounds like you are using
> pointers for almost everything.

Pretty much.


>   This is C++, not Java. Here you can use true references and local 
> instances, true member instances. You don't need to use dynamic 
> allocation for everything, as in Java (in fact, it's usually a good 
> idea to not to use it unless it's justified).

I've been avoiding using references, I don't like them for the simple 
reason that a call passing a variable by reference looks exactly the 
same as one passing a variable by value, and I have a pointer most of 
the time anyway. Pointer syntax isn't that hard to figure out.
And I have to use dynamic allocation because the objects are going to 
stick around for an indefinite amount of time, they can't be deleted 
when the function goes out of scope. Local instances aren't that useful 
in this program, though I use them when I can.


> : Templates.
> 
>   What about them?

They make my head hurt. ;-)
They're fine unless there's a problem. If there's a problem, it's often 
very difficult to figure out what it is from the error messages. And the 
syntax looks like something just tacked onto the C language, but my 
complaint is mainly about the error messages they give. Fortunately, 
they haven't been causing me any trouble in CSDL...

-- 
 -- 
Christopher James Huff <chr### [at] maccom>


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.