cancel
Showing results for 
Search instead for 
Did you mean: 

Best Practice; Short vs Long Namespaces in code

simon_white
Champ in-the-making
Champ in-the-making
Hello all,

When referencing entities stored in Alfresco, particularly when using the Javascript APIs (in Java we can often use the rich QName object to model qualified names), we frequently have a choice about how we refer to the qualified name of an aspect, property, path element etc - we can use the full namespace, say, {http://surevine.com/alfresco/aclient/foobar}myentity or a shortened version, perhaps sv:myentity.

My question is fairly simple: Is the use of one form generally preferred over the other?

I've just updated our internal coding standards to suggest that developers use the shorter form rather than the longer one to improve readability, but I'd be interested to know what others thoughts were.

Thanks in advance,

Simon
1 REPLY 1

mrogers
Star Contributor
Star Contributor
One important difference is that the "short name" is your prefix, whereas the full URI is global and fixed forever.     The picture does get a little muddy where APIs don't specify their own namespace resolvers or like the java script API are perhaps over simplified.

The short name prefix is for your convenience, I suggest you use that one.