Game Development Community

IMO, ownedByMount default should be false

by Bryan Edds · in Torque Game Builder · 04/24/2005 (1:29 pm) · 6 replies

I feel the ownedByMount parameter in the fxSceneObject2D::mount method should be false by default. Making it true by default makes no contextual sense to me. Programmers should always assume responsibility for deleting their objects by default. Only in special circumstancse (like when they explicitly specify true for this parameter) should they expect their mess to be cleaned up for them. Making the reasonable assumption (based on the forementioned logic) for ownedByMount to be false can lead to program crashes when the object is improperly deleted twice in some cases.

Thanks for listening. :)

EDIT: Changed 'options' to 'objects' - lately I've been typing the wrong word from what I meant. Freudian!

#1
04/24/2005 (1:52 pm)
Quote:Programmers should always assume responsibility for deleting their options by default.

A good 50+% of software crashes come down to improper explicit memory management on the part of programmers. Clearly, us programmers have proven ourselves incapable of responsibly handling memory management, so the more management that can be automated the better.
#2
04/24/2005 (1:55 pm)
I disagree that statistics should govern program design except in the most extreme cases (this not being one of them). Reason and consistancy should be foremost in deciding programming issues. But that's a whole 'nother philosophical argument, isn't it?

I will now proceed to side-step the argument. It is not in my interest to argue with either the community or the developors in this thread. I'm simply throwing this suggestion as well as my personal reasoning out there for consideration, and haven't much more too add other than that.

Fo shizzle.
#3
05/04/2005 (12:44 am)
I tend to think it's best to let T2D manage things as much as possible. I still do checks for object existence and try to funnel things with ScriptObject wrappers, but overall T2D probably does a pretty good job managing objects. I'm only guessing, though.

More often than not, it seems useful that the mount should own the object since generally you won't want to have one around without the other. That's been my experience, at least. So for convenience sake, if no other reason, I agree with Melv's choice to make it default to true. Of course, we have the source, so it's easy to season to taste. :)

$0.02
#4
05/04/2005 (7:22 am)
I agree with Jason. The way I see it, in the majority of cases where you mount something to something else, you're likely going to want to get rid of the child by default if you get rid of the parent. I typically check anyways, as a rule of thumb, but still. It just seems logical that deleting the parent would delete the child.
#5
05/04/2005 (8:09 am)
I would agree, I beleive in most cases you would want ownedByMount to true, or at least for the majority of T2D developers...

if you find your changing it to false often then you could always change

// Calculate Owned by Mount.
	bool ownedByMount = argc >= 8 ? dAtob(argv[7]) : true;

to

// Calculate Owned by Mount.
	bool ownedByMount = argc >= 8 ? dAtob(argv[7]) : false;
:)
#6
05/04/2005 (9:16 am)
T2D is a high-level development environment, and in that sort of environment I think the default should be to let the system handle as much as it reasonably can.