Quote:Original post by mikemanQuote:Original post by KestQuote:Original post by mikeman
But all of these methods named Foo.GetX() don't return X. For example, you don't write "mypixelshader=device->GetPixelShader()". They write the result to an OUT variable that is supplied in the argument list. Thus, if we assume that Foo.Y() is a good practice and in this case Y=GetX, D3D follows the same principle, since it returns a value indicating whether or not the method succededed. That is, the value they return is related to GetX(the method) and not X(the state).
Whether you want to..
return ObjectAddress;
..or..
*ptr = ObjectAddress;
return;
..you can't seriously think that one makes it okay to use Get in the function name and the other doesn't? If so, I give up. I don't even want to know why.
What are you talking about? We're not talking about what goes inside the function, we're talking how it appears to the outside,ie whether it's better to do:
(1)mytransformation=foo.GetTransformation();
or
(2)mytransformation=foo.Transformation();
You used the D3D example and I just pointed out that it doesn't help your argument, since it doesn't behave like (1) at all.
It bahaves like 3:
(3)foo.GetTransformation(&mytransformation);
Which behaves exactly like 1. It just doesn't look the same.
Also, it's not my argument. Get/Set is used by the majority. Heck, point out any popular game library that doesn't use them. It's the elites that keep changing the rules, even when they don't need changed.
edit:
I believe you should name a function to best describe it's behavior. If the function is sending back data, 'Get' makes sense. When I use Set in a function, I use it because it describes the action that the object is performing. Would SetMyPantsOnFire be a bad function? Nope. Because MyPantsOnFire is clearly not data. When I use SetPosition, I'm typing Position as in the object's coordinates on the map, not a variable named Position.
[Edited by - Kest on July 5, 2006 9:59:16 PM]