Options

Naming Variables

eromeineromein Member Posts: 589
SalesLineRec ?

Why not call it SalesLine, just like standaard Navision does?

Before you know it people will post fix everthing... I've even seen:

SaleLineRecGlb or SalesLineRecPar! Never seen this in standard Navision though. So why start doing it????

But still, it's better the pre fixing. Imagine these kinds of variables:

GlbRecSalesLine or even better LclDecQty.

I know Qty is a variable, IT SHOULD ALWAYS BE DEFINE LOCALLY and don't tell me you need to know that QTY is of the type decimal. I MUST BE A DECIMAL! If this is a Integer a new training is needed!

Conclusion: Qty is the only right way yo define this variable. You don't even have to have good arguments for this, the best reason is STANDARD NAVISION!

Maybe this should be a new topic on the forum...




ANSWER janpieter !!

somehow off topic but i totally disagree.

Dont tell me navision standards are highly readable.

Now people can see it is a record whilst otherwise it could just as well be an automation variable for example. I know there would not be any confusion in this topic but just as well.

Oh well and it is not really our conventions but i see a lot of people juse it like this and thats why i posted it here like that.

(There is nothing wrong with having an own convention as long as it is done companywide.)

oh in fact we use:
lrecSalesLine (local record sales line)
grecSalesLine (globar record sales line)
liCount (local integer)

so 1 letter for the variable being local or global and 1 letter for simple variable types or 3 letters for complex variable types.

So more in the direction of C++ style conventions.
"Real programmers don't comment their code.
If it was hard to write, it should be hard to understand."

Comments

  • Options
    eromeineromein Member Posts: 589
    Right, a bit off topic

    Tell me, ain't a “bitch” to find your variables in your symbol menu? As you can only jump to a specific variable using the first letter of the variable? All variables starting with a L or and G… Must make programming hard, I’m sure…

    Variables always need to be defines locally unless... That’s a Navision guide line rule. (I'm not quite sure why Navision doesn't apply this rule themselves.)

    I do tell you, Navision standard is highly recommended. If everybody would code according Navision Guide Lines and as the Navision standard, I’m sure the general quality will increase. I’m not saying Navision is perfect, but why do something completely different from the rest of Navision?????

    Tell me, what do you do if you need to use a Navision default variable?

    1.) Rename a Navision standard variable?
    2.) Use the standard variable? Which means you are not consequently using the same variable names.
    3.) The worst option of all, create a brand new variable just because you do not want to use Standard Navision Guide Lines?

    You are right, company rules are good… In fact, every company should have them even if the rules are not right. But… Navision code, as you know, does not know company boundaries. Some day, this code could travel all over the world. I think therefore it should comply to world standards… Post and Pre fixes in variables is not world standard Navision.

    Not?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Options
    janpieterjanpieter Member Posts: 298
    1. When you decalere variables locally no it is not hard to find them in the symbols menu (which i hardly use) but you see it sorted firstly by global and local variables and secondly by type.

    2. Because of reasons alreadt described. Navision is the only language that lacks variable type convention in variable names (which is the only convention of navision i dont use).

    3. I don't rename navision default variables. In fact with the system you can easally see what is standard navision and what is custom.

    Prefixes are world standard but only not applied by navision. In the future C/Al will disappear and then probably we will program C-sharp and thes conventions are widely applied by current c/sharp c++ and vb developers. So if you are planning to hire C/sharp programmers they will be verry happy with you.

    I agree it is a problem when code goes accros boudaries. Therefore we should develop a global system. But i'm sure this will not work either.
    In a world without Borders or Fences, who needs Windows and Gates?
  • Options
    janpieterjanpieter Member Posts: 298
    oops now there are 2 threads. Please move this to Navision Naming Conventions.
    In a world without Borders or Fences, who needs Windows and Gates?
  • Options
    AdministratorAdministrator Member, Moderator, Administrator Posts: 2,496
    I can't move topics to another thread, I can only move topics to another forum. Therefore I'm closing this one.
This discussion has been closed.