Expand my Community achievements bar.

SOLVED

Naming convention for fields?

Avatar

Level 2

What's the rule of thumb when it comes to naming fields?

I have been been naming like the following:  ' TFLastName '    TF for Text Field and then what the field is.

Is it really necessary for me to begin the field in that manner?

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

No it is not but it is good practice in that when you are reading code you can tell what the object type is simply by looking at the name.

Paul

View solution in original post

4 Replies

Avatar

Correct answer by
Former Community Member

No it is not but it is good practice in that when you are reading code you can tell what the object type is simply by looking at the name.

Paul

Avatar

Level 2

Thank you, you confirmed what I was thinking.

Avatar

Former Community Member

Hi,

If you're adding the field type to each field name, you might also want to consider adding the field length to each field as that is even more crucial when populating forms. If the field expects special formatting as well, in order to avoid the form rejecting mal-formed data.

So eventually you'll end up with field names like num_ZipCode_6_XXX_XX, and what I'm really trying to say is: do not to mix in any meta data at all into the field name. The meta data, such as field type, field length or formatting already has a natural place: inside the schema. That's what it's for.

On the contrary, my experience is that prefixing each and every field name will add clutter and actually reduce readability of the xml.

As pguerett points out, it is good practise when writing Java or JavaScript. The reason is that Java code doesn't have schemas, but instead strict rules of how a variable can be typed (string, long, int, double, unsigned and so on). A developer just needs to know if a variable is a string or, in case of a number, if it has a sign.

The convention is usually called Hungarian notation (google it), but as I said, you don't need that in field names since they should have a schema.

Avatar

Level 2

I'm not mixing any meta data in the field names, strictly alpha characters, example: 'TFLastName'.

Yhanks.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----