Horde3D

Next-Generation Graphics Engine
It is currently 27.04.2024, 15:11

All times are UTC + 1 hour




Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Namespaces
PostPosted: 08.06.2009, 06:22 
Offline

Joined: 22.01.2009, 19:49
Posts: 14
Location: Germany
magv wrote:
Expandable wrote:
Anyway, why not just use enums the standard C++-way?
That actually was my first impulse also, but unfortunately there are conflicts: MeshNodeParams::MaterialRes is 300, while LightNodeParams::MaterialRes is 500, so you can't just use MaterialRes everywhere, you have to use the prefix.


Hmm... in that case, why not make them both 300? Is there a reason they differ from each other?


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 08.06.2009, 08:15 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
marciano wrote:
magv wrote:
Regarding naming of things, is there anything that can be done to make enum names shorter?
The advantage of having the enums wrapped in a struct is that you can easily see what enum values are available for a given parameter. If you just have the enums as in GL, you need to look at the documentation to see which enums are allowed.
I'm a fan of the self documenting nature of this approach.

Shortening of enum names can be done at the user/application-level if desired:
Code:
const static MeshNodeParams::List eMeshMat= MeshNodeParams::MaterialRes;
const static LightNodeParams::List eLightMat = LightNodeParams::MaterialRes;
func(..., eMeshMat);


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 09.06.2009, 20:07 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Expandable wrote:
Hmm... in that case, why not make them both 300? Is there a reason they differ from each other?

The enums have different values/numbers since they have different semantics (although the name is the same). Using different numbers for all enums gives some form of type safety to the whole system. For example, you will get an error when you try to give a ModelNodeParam to a Emitter since the ModelNodeParam enum has different values than the EmitterNodeParam enum.

If we use pure enums (not wrapped in structs), we would still require some prefix to make the code understandable without having to check the documentation all the time. D3D has such prefix as well, for example D3DBLEND_ZERO which is in the D3DBLEND enum. So in the end we would not win much over having the enum in a struct.

What we could do though is trying to find shorter names and more abbreviations, for example TexData instead of TextureResData. That would already help.


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 13.06.2009, 12:13 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
This is a quite subtle thing but I think the prefix h3d makes the code slightly harder to read. I think the reason is that all letters are "tall", so it is more difficult to quickly spot the following capital letter of the function name which is more important than the prefix of course. I would propose to use the prefix hg instead which stands for "horde graphics". I think that makes sense as well, is even shorter and the code looks just a bit nicer.
Code:
h3dAddResource( .. );
h3dSetNodeParamF( ... );

hgSetNodeParamF( ... );
hgAddResource( .. );


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 13.06.2009, 14:24 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
marciano wrote:
I would propose to use the prefix hg instead which stands for "horde graphics"
"hg" is easier to type than "h3d" :)

IMHO it's better to use "hgGetResParam" instead of "hgGetResourceParam" [shortening the "Resource" to the "Res"] and following changes will make the api easier to learn/remember :
Code:
getResourceType --> getType_Res
getResourceParami/f/str --> getParami/f/str_Res

getNodeType --> getType_Node
getNodeParami/f/str --> getParami/f/str_Node


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 13.06.2009, 14:28 
Offline

Joined: 22.01.2009, 19:49
Posts: 14
Location: Germany
Siavash wrote:
"hg" is easier to type than "h3d" :)

IMHO it's better to use "hgGetResParam" instead of "hgGetResourceParam" [shortening the "Resource" to the "Res"] and following changes will make the api easier to learn/remember


I agree with "hg" and "Res" instead of "h3d" and "Resource" - but I really don't like your other proposal; there are no underscores in the API, and none should be introduced.

Edit: I just realized that there actually are underscores in the new enum names. That doesn't look good. And what meaning do "E", "PF", "PS", etc. have anyway? I think that naming scheme should be re-thought.


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 13.06.2009, 18:19 
Offline

Joined: 06.06.2009, 23:13
Posts: 7
DarkAngel wrote:
Shortening of enum names can be done at the user/application-level if desired
True. The only reason I brought this up instead of using that suits me better is that I really would like not to diverge from main distribution (and documentation).
marciano wrote:
What we could do though is trying to find shorter names and more abbreviations, for example TexData instead of TextureResData.
Consistent rename in similar style would solve my problems. Thanks!

About prefixes, for what it's worth, I'm using Horde from Scheme, and at first I tried using "h3d" prefix too, but eventually switched to just "h:". You can simulate this in C++ with "h::" prefix; it's pretty but I guess too generic.

Speaking about "hg" -- "hg" is the command-line name of mercurial DVCS, so you might not want to have this clash. Anyhow, "hg", "h_" "h3d" -- I'm ok with any choice.


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 13.06.2009, 18:42 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
magv wrote:
Anyhow, "hg", "h_" "h3d" -- I'm ok with any choice.
'h' strikes me as a little too generic, 'hg' doesn't really say 'horde' to me... 'h3d' is immediately recognisable as 'horde3d', so seems preferable.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 13.06.2009, 21:05 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Expandable wrote:
Edit: I just realized that there actually are underscores in the new enum names. That doesn't look good. And what meaning do "E", "PF", "PS", etc. have anyway? I think that naming scheme should be re-thought.

In general I am against underscores as well. But here we have a special case where the prefix indicates the data type. E_ means element, PI_/PF_/PS_ int/float/string parameter and S_ stream. I think that is an acceptable convention here but I am open for better suggestions.

magv wrote:
'h' strikes me as a little too generic, 'hg' doesn't really say 'horde' to me... 'h3d' is immediately recognisable as 'horde3d', so seems preferable.

Seems we have differern ways of thinking: When the pattern recognition matches, the name conversion is for free in my pipeline ;)
But honestly, what about the prefix hor like in horSetNodeParamF()? It would be something in-between.


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 13.06.2009, 22:00 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
marciano wrote:
But honestly, what about the prefix hor like in horSetNodeParamF()? It would be something in-between.
A literal pronunciation of 'hor' is identical to 'whore'.

To me, the cleanest approach (both by clarity and readability) would be 'h3d_', as in h3d_SetNodeParamF. This clearly delineates the namespace from the function name, allows the first letter of the function name to be immediately identified, and is very strongly related to 'horde3d'.

I don't think the overhead of typing additional 2 characters is a problem - all programmers are fast typists, right ;)

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 14.06.2009, 02:59 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
swiftcoder wrote:
I don't think the overhead of typing additional 2 characters is a problem - all programmers are fast typists, right ;)
"hg" without "_" is easier to type because "h" & "g" keys are near together. There is no need to search for the "3" & "d" keys and hold "Shift"+"-" most of the times :wink:


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 14.06.2009, 06:26 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
How about "hrd" (Horde3D)?


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 14.06.2009, 14:35 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
Siavash wrote:
"hg" without "_" is easier to type because "h" & "g" keys are near together. There is no need to search for the "3" & "d" keys and hold "Shift"+"-" most of the times :wink:
That is kind of what I meant, I don't think laziness is a good foundation for API design - learn to touch type, and you wont care either way :P

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 14.06.2009, 16:57 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
swiftcoder wrote:
Siavash wrote:
"hg" without "_" is easier to type because "h" & "g" keys are near together. There is no need to search for the "3" & "d" keys and hold "Shift"+"-" most of the times :wink:
That is kind of what I meant, I don't think laziness is a good foundation for API design - learn to touch type, and you wont care either way :P

Roger that ^_^


Top
 Profile  
Reply with quote  
 Post subject: Re: Namespaces
PostPosted: 14.06.2009, 19:52 
Offline

Joined: 05.03.2007, 19:38
Posts: 167
Location: Romania
imho h3d* is the best one. it's simple and descriptive in the same time

_________________
Paul


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group