Why so many structures instead classes?
Why so many structures instead classes?
Hi,
is there a reason why using a structure for Vertex?
Why not using a class for Vertex?
Is there a technical reason or is it just design style of the coder?
Same for Materialstructure.
thx
is there a reason why using a structure for Vertex?
Why not using a class for Vertex?
Is there a technical reason or is it just design style of the coder?
Same for Materialstructure.
thx
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Eh, I expect it's probably just that if you want a class with all of its methods and members public, then it saves you typing 6 characters.
I didn't say that was a good reason. You know, unless those are the last 6 bytes of storage on your hard drive, and Alyson Hannigan has just given you her phone number and you need to write it down somewhere. Then you'd be glad you used a struct.
I didn't say that was a good reason. You know, unless those are the last 6 bytes of storage on your hard drive, and Alyson Hannigan has just given you her phone number and you need to write it down somewhere. Then you'd be glad you used a struct.
-
- Posts: 206
- Joined: Thu Sep 01, 2005 9:26 pm
- Location: France
-
- Posts: 206
- Joined: Thu Sep 01, 2005 9:26 pm
- Location: France
Very funny.rogerborg wrote:
I didn't say that was a good reason. You know, unless those are the last 6 bytes of storage on your hard drive, and Alyson Hannigan has just given you her phone number and you need to write it down somewhere. Then you'd be glad you used a struct.
You don't have to held account for something if someone just asks for a technical reason of an implementation.
Just say nothing if you don't know the answer or the reason.
But please don't try again to simulate a good thought behind it.
Because you speak about bytes and performance but not even a vertexbuffer has been used at this time in the engine.
So who is glad about what?
@all
Please don't misunderstand the vertexbuffer comment.
But if someone is talking about saving bytes or having better performance on other parts in the code.
But for many other things, that are much more important the performance was not recognized, then such explanations and codingtheories about saving bytes or having better performance doesn't sound credible for me ...
Because if we talk about saving bytes or performance we should be consistent ... Everything else is just Mickey Mouse.
And thx gfxstyler and vitek your answers confirmed my thoughts that this was just a design style reason.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
You should always try to use the optimal code. That does not mean that you should always save the last dozen of bytes, but choose the proper structures for the requirements of that special part of your code. And if you just want some simple structuring element and also communicate this property to the code user you should use the struct. The fact that you might save some bytes with this decision makes it reasonable (otherwise you might not really want it), but it should not be the only reason. Architecture and clean structures is more important.