Navision naming conventions

DenSterDenSter Member Posts: 8,307
I am really interested in this topic, and it started to pop up as an off-topic discussion in another thread. It's been discussed before and it wil be discussed again, but I felt like putting in my 2 cents :whistle:

I personally think that any naming convention is ok, as long as they are clear and as long as they are consistently used. That is the heart of the problem, every developer has their own little 'standard' and they all believe passionately in it. Personally I really don't care if a variable is called grecSalesLn or SalesLine, I get the jist of it by looking at the name, plus I check the scope anyway, I just think 'SalesLine' is a LOT more clear than 'grecSalesLn'.

At some point we had a developer conference and came up with a beautiful naming convention, for variables as well as function names and ways in which to comment code. We even created a form that would name variables for you with selectors for scope and type and everything. The problem was however, that after a short period of 'this is cool' nobody used them anymore, because it took away brainpower from solving the problem to thinking up a correct variable name, so it was nothing more than a brain excercise. It should probably be enforced by some sort of Q&A process, but who has the time for that nowadays if the program works right.

I don't think it is necessary to prefix a SalesLine variable with 'rec' because everybody knows it's a record type variable, but it also does not bother me when somebody does the prefix. Regardless of what anybody calls it, I STILL check the variable declaration when I am troubleshooting other people's code, to make sure I understand the scope of the variable.

You wouldn't believe the kind of crap I've seen, where a sales line variable was called SL3 or something, or where someone had copied some code for invoicing to apply to a shipping process, and forgot to rename the variable. You HAVE to check variable scope, no matter what you call it, so why clutter variable names for 'most used' cases.

I always declare most variables as globals, because that is the way that most standard Navision code is written. I only put 'loc' or 'par' prefixes in there if they are not global.
«1

Comments

  • KowaKowa Member Posts: 925
    There should be naming convention for record variables of temporary tables. I always use a 'temp'- suffix for these to distinguish them from the normal ones.
    It would also be nice if this property were visible in the symbol menu.
    Some years ago I overlooked an "Item.deleteall" which was non-temporary...
    :wink:
    Kai Kowalewski
  • janpieterjanpieter Member Posts: 298
    I totally agree that any convention is OK as long as anoyone uses them. The problem is nobody uses them. And honestly - coming from a 4GL world - this seems to be a navision developer problem only. Most 4GL developers i know have no problems applying conventions. (dont get mad at me now)

    It takes a little time to get use to but if you know the convention i think it does not take your mind of the problem and i think of it as a bad excuse. When i apply conventions (it took time too learn for me as well) this is an automatich thing just as giving direction when you change the lawn you are driving in on the high way (which is hard for people as well but only because they think it is not necesarry).

    The biggest problem is that developers are not keen to learn them and i think this is a drawback in delivering professional coding where every developer uses his/her own style. (still not mad at me?)

    Also i do think that local, global (and public for 4Gl languages) need a prefix, why are these conventions applied in other languages but not in Navision !?! Because - when you are used to them - they make code more readable. And prefix a variable with the type name i think of the same. So i definitly think that the prefix rec for a record var makes the code more readable. Only exception for me is fieldnames of a table they should be used according to navision standards.

    Oh and using abbreviations for names is a big "NONO".

    How do you convince people? Fire them if they don't apply to company policy :twisted: (just kiddin) (ough you must be mad at me now)

    Oh and why not use navision standards? because - try reading navision code -.
    In a world without Borders or Fences, who needs Windows and Gates?
  • HalMdyHalMdy Member Posts: 429
    janpieter wrote:
    Oh and why not use navision standards? because - try reading navision code -.

    Yep fuly aggreed with that and the rest of your post...

    In my NSC, we have clearly define some rules that everybody SHOULD respect . Like you, prefix code to separate local, global, fields and parameters. Our experience demonstrates that this is the best solution. With that, we could also directly identify our customization ( + with Tags, of course).

    We know that is not STD Navision. But Navision is the first who not respect the rules (cf local variables).
  • eromeineromein Member Posts: 589
    I really love mibuso and I love the mibuso forum. And one of the biggest reasons why I love the forum is because the forum works. It works because everybody is using the same language. Sometimes a German or somebody from Spain tries to ask something in their own language, but… check it out, they never get answers.

    I think one of the most important things in live is speaking the same language. Not only reading and writing English but in other things as well. Like a traffic light, the blue, brown and yellow cables in electrical installations and much more other rules that are the same over the world.

    I think it’s absolutely necessary for all Navision programmers in the world to use the same guide lines. Without this the end of the world is near, the apocalypse is coming, Mad Max flashes…

    Now, we could make a new guide line right here, right now… But this is already done by people how really know this stuff. And they called it Navision. I refer to this before, maybe you remember.

    I’m really astonished so many developers are using own, house made, rules. Impossible to believe… I’m sure I wasn’t the only one doing the Navision exam. How can it be I’m the only one actually applying the learned knowledge in practice?

    Click this link to download the Navision Bible!

    Btw, Navision code is perfecty readable. Perfect!
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • jesamjesam Member Posts: 100
    Oh and using abbreviations for names is a big "NONO".

    I agree, but as long as Navision has this stupid limit to the length of variablenames of fieldnames, there is no other solution.

    And on the other subject of why people in Navision refuse to apply a uniform codeing convention, I think there are two main reasons :
    1. The Standard Navision code (as said before) has no uniform coding convention (nor does it scope it's variables correctly). And the localized code for the various countries also has no uniform coding convention and doesn't scope it's avriables correctly either.
    2. Most of the people coding in Navison are not informatician's but business people, and don't see the point in applying coding conventions.
    If I install electricity in my own house, I could get it to work correctly without following all the conventions that an official craftsman would follow (off course my electricity would never pass the mandatory inspection, but that's another point, there is no mandatory inspection for NSC code). As long as the house is mine, I could maintain it and there would be no need for following the conventions. But when I sell the house, the owner after me would either have to find out how everything worked (and that would cost a lot of time if it were possible at all) or rewire the place, and all that just because I didn't see the point in following conventions.
    Along with major technical shortcomings, this is one of my major gripes with Navision.
  • janpieterjanpieter Member Posts: 298
    No it is not readable especially when you know programming but dont know navision then you think it sucks. Takes a long time before you get to know your way into navision coding.

    I think the fault is that Navision does not use conventions like 4GL tools. I think these conventions have been giving more thought then Navision conventions (just speaking about variable naming here).

    I think everyone agrees we should use common conventions but most people also believe that this is not the way navision does it.

    Oh yes, and please all UK people reading this ... could you please start driving on the right (the opposite of left) side of the road starting ... today ... so you comply with our world standard :mrgreen: (sorry its my bad mood today ... )
    In a world without Borders or Fences, who needs Windows and Gates?
  • DenSterDenSter Member Posts: 8,307
    aaaahhhhhh now we're getting somewhere....
    jesam wrote:
    2. Most of the people coding in Navison are not informatician's but business people, and don't see the point in applying coding conventions.
    I agree with this, in fact most of our developers have a background in accounting or some other business function, me included. It used to be that any selfrespecting 'real developer' would only work with C, or Visual Studio or something. Heck, even VB programmers are not regarded as 'real developers'. It's because of the proprietary nature of C/AL code that development is mainly done by very smart people who understand the business process, but who don't think applying a code standard is worth their time. It's all about priorities.

    In fact, I thought there was nothing wrong with Navision standard code until I started using C# myself, and saw how you are basically forced into scoping your variables correctly, because it simply won't work otherwise. It's because of the 'flexibility' of the Navision IDE that you can do whatever you want.

    Also a very good point is that there is no inspection. Without some kind of Q&A process that also looks at the coding standards, I don't think it will happen any time soon that coding standards will appear in Navision. Personally, the fact that now that Microsoft is in charge of Navision, and there STILL are no true coding standards in 4.0, speaks volumes about their intentions with the product.
  • janpieterjanpieter Member Posts: 298
    eromein wrote:
    I’m really astonished so many developers are using own, house made, rules. Impossible to believe… I’m sure I wasn’t the only one doing the Navision exam. How can it be I’m the only one actually applying the learned knowledge in practice?

    Yes i passed the navision exam and it was hard because i had to start to think different then i was used to. Doesn't mean i have to agree with it.
    In a world without Borders or Fences, who needs Windows and Gates?
  • janpieterjanpieter Member Posts: 298
    Agreed denster.

    Yes i think too many functional educated people are developers. Has advantages but with this topic the disadvantage of this is explained.

    Just cant wait until Green is there and how it will be \:D/
    In a world without Borders or Fences, who needs Windows and Gates?
  • jesamjesam Member Posts: 100
    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

    This is not really correct. There are official MS coding conventions for .NET languages (http://msdn.microsoft.com/library/defau ... elines.asp - there even is a tool called FXCop that can check your own code for compliance), and they specifically state (among other things) that no prefixes should be used. In fact, given the fact that VS.NET is a real and workable editor which has all these handy things that all modern editors have, there is no need for the use of prefixes. Need to know which is the type of your variable ? Just hover the mousepointer above it and you see a tooltip with this information. Need to find where or hwo the variabke is defined ? Select 'Go to definition' form the context menu.
    Off course, given the fact that what Navision dares to call an editor is as much worthy of the name editor as a butchers knife is worthy of the name scalpel, using prefixes to cover for the lack of a real editor is currently the only workable solution.
  • DenSterDenSter Member Posts: 8,307
    janpieter wrote:
    No it is not readable especially when you know programming but dont know navision then you think it sucks. Takes a long time before you get to know your way into navision coding.
    See I do not agree that this is only because of bad naming conventions, but because Navision is simply a very complicated product. I don't want to say there is no 'bad coding', but I do want to say that there is a lot of 'good coding' that is just extremely difficult to understand because of the underlying business processes.

    You can't understand a product of this complexity in a few days, and having one standard applied to all code would still not make it easier to understand.

    It's because you have to open a friggin globals list to see the scope of a variable that makes it cumbersome. It would be a lot easier if there would be a simple declaration within the function. I doubt that there would be half the complaints about naming conventions.

    I don't believe for a second that ALL C++ code has clear naming conventions, it's the fact that you can see the scope of a variable right where it is created that makes it more readable.

    Navision code:
    SalesLine.INIT;
    
    and you go 'hmm... what the heck is SalesLine... a rec variable? is it local? is it global?'. You'd have to open the globals window and hope that you can find it, or else open the locals window, even though the variable name is very clear for an experienced Navision developer.

    C# code:
    public SalesLine SL = new NavisionTables.SalesLine;
    
    or something like that, and you immediately see what it is and what the scope is, even though the name SL is an absolutely horrid variable name.
  • eromeineromein Member Posts: 589
    I disagree so bad, I’m almost crying!

    1.) In the Netherlands, if you do your own electricity it MUST be checked by a professional. This means you handle as the rules are… Navision has rules, you should handle to them.
    2.) Navision reads very good. Good code, the same though out whole Navision. Not always perfect code, but… the same though out Navision. In fact, I can estimate the working of Navision code or functionality without ever seeing it before. THAT THE POWER OF GUIDELINES! If you can’t read Navision, own guide lines are not the answer! Just learn to read Navision and apply it.
    3.) If you use Navision guidelines I guarantee your code will be better in the end. I’m sure!

    I’m programming as much as standard Navision as possible. I even copy and past variable names. And in many, many, many times Navision standard forced me to think about my solution and maybe change the solution I was building. This means, if using the guidelines your application will be better. I’m sure! That alone is reason enough to use nothing but standard.

    Off course I have a couple of additional guidelines, but no way!!! I’m using pre and post fixes. And I’ll never will!
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • eromeineromein Member Posts: 589
    You can't understand a product of this complexity in a few days, and having one standard applied to all code would still not make it easier to understand.

    I will take a programmer about 3 years to actually program without any big boundaries. 5 years to really go at it and program really big applications. No much time compared to the total time spend on Navision. Sum all Navision developers hours ;)

    And still after that you will learn new stuff every day.

    I'm a developer since 1997, and I can read Navision code like a book. As many others, I’m sure. And in these years I’ve obtained knowledge about the product Navision. I know what to code where but most important, what not to code where.

    I’ve seen the worst code. And all these code had one thing in common. No guidelines.
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • janpieterjanpieter Member Posts: 298
    @jesam: hmm there are different worldwide standards. i'm not really sure which it was i was using. Can't really make a lot of your link doesnt tell me what i was looking for. It is some convention when building classes? And you are saying that MS tells us not to use prefixes?

    I think tooltips are helpfull but i dont think of it as the sollution of finding variable types. Some of the most basic things ... i feel ... should be visible directly. And really if you apply it consequent and are used to it, then you will love it.

    :arrow: The strange thing in our company:
    * all (ex)-4GL code writers vote for using prefixes.
    * all non 4GL code writers vote against prefixes.

    I think this statistic tells us something ...
    In a world without Borders or Fences, who needs Windows and Gates?
  • janpieterjanpieter Member Posts: 298
    When you see SalesLine you probably would think it is a record variable. Although it could also be a form or a report variable!

    compare these code snippets (really stupid coding i know but just as example:
    SalesLine.GET('1');
    SalesLines.SETRECORD(SalesLine);
    SalesLines.RUN();
    
    lrecSalesLine.GET('1');
    lfrmSalesLines.SETRECORD(lrecSalesLine);
    lfrmSalesLines.RUN();
    

    Yes as experience Navision developer you know in the first snippet that SalesLines probably has to be a form because a form has the SETRECORD function and a report does not. Because navision does not have a lot of complex variable types experienced people would understand the code.

    But i still think that the 2nd snippet is more readable.

    In C-sharp with all different class library types this problem only gets worse.
    In a world without Borders or Fences, who needs Windows and Gates?
  • DenSterDenSter Member Posts: 8,307
    I don't think there is anything wrong with calling a Sales Line variable SalesLine. I would call the form variable 'SalesLineForm' and the report 'SalesLineRpt', and all of a sudden it is perfectly readable. I would want to keep the SalesLine part at the front of the variable, so I can find it easily in the object browser.

    If you don't understand Navision code, no naming convention will change the readability (sheesh is that a word? :-k ) of the code, unless you start using funky abbreviations, or simply misnaming them (like calling a Sales Line variable PurchHdr, which I have actually seen [-X ). By seeing the statement SalesLines.RUN, you immediately know that it is something that you can RUN, so it's not a table.

    I agree that you need some kind of convention, but I agree with Emiel that the Navision standards are perfectly readable. It took a while to learn, but I am really comfortable with it now.
  • janpieterjanpieter Member Posts: 298
    But then you are using a convention different then standard Navision for the same reason. Except you choose not to pre/post fix record variables only forms and reports.

    The point for me is hats any convention has its positive point and its drawbacks. And any convention is good but only when you use it strictly.

    I dont see the symbols menu as a disadvantage. Its just another way of searching. When i press l i almost surely am at the local variable section which is almost never more then 10 variable and i can easally pick the right one out. I can assure you that it is fast searching.

    Its just a matter of what system you are used to, and if you are used to a system it is hard to do get used to other system.
    In a world without Borders or Fences, who needs Windows and Gates?
  • DenSterDenSter Member Posts: 8,307
    Absolutely, and that's always the case isn't it, you always feel comfortable with what you're used to :). I guess we all have our own way of making it work. Myself I use the object browser all the time.

    And you're right, the SalesLineForm name is not Navision standard. I guess I use the standard unless it looks confusing. Like if I have a global Sales Line, and I have a Sales Line as a parameter, I call the global SalesLine, and the parameter parSalesLine, and if I had a local I'd call that one locSalesLine, since both parameters and locals are always at the top of the list that's easy to find for me.

    Other than that, if I have more than one Sales Line, I put the purpose of the variable in the name, so I guess I dont use Navision standard there either. So if I need to check a value of one sales line for some process with another one, I would have my main global SalesLine, and another global called SalesLineToCheck or something to do the check. I have found that using Navision standard SalesLine2 is very easy to make mistakes with.

    I don't believe in having types like integer or decimal or boolean as part of the variable names. In Navision you know that Quantity is a decimal, so I don't need it to be called decQuantity. Other than that, I kind of cheat in giving the variable a name that gives it away, like a boolean called 'CheckIsOK'.
  • ShenpenShenpen Member Posts: 386
    I think naming conventions are not important in Navision as code is usually short and very simple "REPEAT do sumthin' with a record var UNTIL" code.

    I myself call General Ledger Entry GLE, Sales Header SH, "Quantity (Phys. Inv.)" PhysQty. etc. I think no reason to be verbous, I expect the ones who go after me and modify it to be professionals.

    A much more important thing is documentation. It is very impotrant to
    write the documentation trigger like "2005.05.26 HM added new field Bar Cod, with OnValidate Code (copy-paste)". (HM is my monogram.)


    Then I have a Perl script that extracts documentation from objects saved as txt.


    Another important thing is to do modifications like:

    //HM+ 2005.05.25 changed line
    //GeneralLedgerEntry.INSERT;
    GeneralLedgerEntry.INSERT(TRUE);
    //HM-

    The reason is to easily merge it when installing a service pack.

    Do It Yourself is they key. Standard code might work - your code surely works.
  • kinekine Member Posts: 12,562
    Hello all,

    I must agree with eromain that Navision code is well readable (but sometime I am missing some memo or simple info about the code for FASTER reading...:-)

    ad. what type is the variable etc:
    Did you ever look to the status bar when you have cursor on some variable? (why than use some prefix for var type?) :-)

    For myself the code with prefixes (lre etc.) is worse readable than without it with good names. Why? Because there is too much informations in the code, which I do not need. Why I must see them everywhere, when I do not need them all the time?

    But of course, there are pros:
    If you use prefixes, you will have no conflict for example with some field from rec. which have same name (somewhere in standard app. is problem that there is var. Currency and within WITH xxx construction is field called Currency and application does not know if it is variable or field...) and you can say - yes, this is added code, because there is used our variable...

    It is better to teach your programmers (which are not "profi" programmers) some naming policy than let them create horrible names...

    Cons (only my opinion):
    for me the code is not fast readable because too many informations in the code (which are not needed) which I do not need all the time (when I need them, I can find them out very quickly)

    The points, where my code is connecting to standard code look terrible if part of the code use prefixes and the standard not...

    I am compactible with the rest of the application - it will have unified visage

    When I sent the code to someone, I do not need to describe the convention for him...


    Of course, I am using pre or postfixes for some variable too, but I am trying to be as near as possible to the Navision standard...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • jesamjesam Member Posts: 100
    1.) In the Netherlands, if you do your own electricity it MUST be checked by a professional. This means you handle as the rules are… Navision has rules, you should handle to them.
    But there is nobody that checks Navision code. You *should* follow the guidelines, but if you don't, nobody will come and forbid to publish your code.
    Navision reads very good.
    I beg to differ. *Every* pragramminf 101 class tells tou that you should not make funtions too long. Navison contains functions that are like 20 A4 pages long. You wouldn't pass in any school/university with such code. And even if variables were defined and scoped in the source (which I would welcome very much, and maybe we could also get rid of having to define procedures through the symbol menu, if you want to code you should at least know how to declare variables and functions, if you want to install electricity you should at least know how to connect wires) instead of through some retarted symbol menu, it wouldn't help. You would have to search for the definition of the variable through 20 pages of code.

    Another thing that is a real nono is the way that in Navision code there is screen interaction littered through the code modules. What genius thought of that ? If I want to use some procedure in a code unit, I have to make sure that I change the code so that it doesn't throw op messageboxes.
    If you use Navision guidelines I guarantee your code will be better in the end. I’m sure!
    If only Navision themselves and the NSCs did that...
    Off course I have a couple of additional guidelines, but no way!!! I’m using pre and post fixes. And I’ll never will!
    I'm not af an of prefixes either, but given the state of things, they are the only workable solution to make clear how the code works.
    I will take a programmer about 3 years to actually program without any big boundaries. 5 years to really go at it and program really big applications.
    This is the part no NSC tells you when you start with a Navision project. It takes you this long because a) the code is a mess, b) the code editor is a mess, c) the debugger is a mess, d) there is hardly any documentation to be found on how things work and which module does what, and e) Navison is riddled with bugs.
    And on the other hand, NSCs hardly ever can keep their people for that long, so if it takes this long to master Navision, 80% of the people working at an NSC are amateurs.
    I would never ever choose some product that takes this long to master and that I don't even control myself.
    Can't really make a lot of your link doesnt tell me what i was looking for. It is some convention when building classes? And you are saying that MS tells us not to use prefixes?
    There are lots of documents on the MS site that talk about coding conventions, this is only one of them (but as any large software project (except for Navison of course) is made out of classes, this applies to most projects), but they all tell you the same ; don't use Hungarian Notation, don't use prefixes., don't use underscores.
    I think tooltips are helpfull but i dont think of it as the sollution of finding variable types. Some of the most basic things ... i feel ... should be visible directly.
    I also feel tha things should be visible directly, but if you have class (or module) scoped variables you really can't see their declaration when your in prcoedure X halfway through the code. Tooltips are just one off the many helpfull tools found in modern editors like VS.Net, or Eclipse, tools sadly not found in the Navision editor.
    I think naming conventions are not important in Navision as code is usually short
    Huh ? Ever looked at CU80 ?
    Did you ever look to the status bar when you have cursor on some variable?
    I was full of hope so I tested this immediately, but alas, no luck in 3.10.
  • kinekine Member Posts: 12,562
    Ok, look into 3.70... sorry, I forgot that in the old C/SIDE it was not...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • eromeineromein Member Posts: 589
    I’m reading all your replies and I’m getting the feeling pre- and postfixes are generally used to compensate the lack of knowledge of Navision.

    Take for example:
    SalesLine.GET('1'); 
    SalesLines.SETRECORD(SalesLine); 
    SalesLines.RUN();
    

    The second I read the code I knew what was going on. SalesLine is a Table, SalesLines can ONLY be a form! Besides the correct naming of the variables you can see from the SETRECORD statement that it’s a form. And don’t tell the .RUN commands makes it confusing.

    I couldn’t even read the second piece of code.
    lrecSalesLine.GET('1'); 
    lfrmSalesLines.SETRECORD(lrecSalesLine); 
    lfrmSalesLines.RUN();
    

    I really needed to read this code line for line to see what is happening. This takes me 10 maybe 15 seconds. The first piece took me like 3 seconds. So, you could see it takes up to 5 times as much time to read non-Navision code.

    The first piece of code I read based on recognition, the second I need to compare variable names.

    And if that’s not reason enough… Why learn two guidelines if you can do all with just one?

    And one big important question. (I’ve asked it before.) What do you do when you want top use a standard Navision variable (SalesLine) in your code?

    1.) Use it as it is, so use two guidelines in your programming. (BAD SOLUTION)
    2.) Rename the standard variable name. (EVEN WORSE)
    3.) Create a new Variable name and copy it from the standard variable. (THE MOST BAD SOLUTION POSSIBLE, in most of the cases.)

    Maybe I should make a survey with this question…
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • janpieterjanpieter Member Posts: 298
    @Jesam
    You have some verry good points there. Hungarian convention, yes thanks now i remember the name of the convention. It isn't microsoft though but that is maybe why MS doesn't like it :D Worldwide i think it is the most used convention so that makes a point either.

    I find it hard to believe that MS is saying not to use pre and post fixes. I do think you shouldnt use them in class properties but surely you would like to scope variable. There are 3 types of scopes (navision only has 2) and that is local, private and public. Surely the last 2 you want to know :?:

    @Emil
    That is only because you are not used to these conventions. Everything takes time to learn.
    In a world without Borders or Fences, who needs Windows and Gates?
  • jesamjesam Member Posts: 100
    @janpieter
    As a matter of fact, Hungarian was invented at Microsoft :
    http://msdn.microsoft.com/library/defau ... aNotat.asp

    And yes, Microsoft is saying that you shouldn't use it anymore in .NET.
    It is hard to explain why there is absolutely no need for that anymore if you have never used VS.Net od a similar development environment. It's like trying to explain what the internet is to people somehwere in a jungle where they are happy if they get to read a newspaper from time to time. If you never ever develop in something else than Navision, you really don't know whatr you are missing.
    I stil feel that Hungarian Notation (or any other pre- and postfix notation) is ugly to read, but if you are working in an environment that is really crippled and does not give you a convenient way of getting to know all kinds of information about your variables (scope, type, value, ...) it is better to use it. It's like choosing between the Plague and the Cholera.

    @Emil
    In a good environment I would go for option 2 (why would that be bad ? After all it is me who is maintaining the code), but in Navison that's a recepy for disaster since there's no refactoring support. This would then force me to go for option 1 (which in fact we do here where I work). At least all code that I wrote would be easier to maintain and debug than the code I did not write.

    And if you say that you couldn't even read the second piece of code, you're not being consequent. You say that you know something is a form because of the SETRECORD function. This means that you read your codelines from the back to the front, so right before the SETRECORD you find lfrmSalesLines. How hard is it then to know that we are talking about the form( you already know that) SalesLines ?

    It is also very striking to see how you ignore all the other remarks I've made. I hate Hungarian just like you do, I don't like pre and postfixes, but given the development environment in Navision we would be better of if everybody just used them, that would make the code at least a bit comprehensible and maintainable.
    It would also help if Navision followed all the good practices any programming course teaches you.
  • janpieterjanpieter Member Posts: 298
    I do program VS.NET althoug i must admit where i can i use VB6.

    In many ways i agree with you Jesam, prefixes may look ugly its not that what counts for me. It really helps me in Navision but also in other development tools. All other means of helping (and i did know that clicking on variables in navision displays variable info in the bottom) i think are insufficient for quick code reading.

    Also a point i forgot to mention is when writing code i will detect possible type conflicts early.

    So lets take 2 snippets again:
    Quantity := Amount / 10;
    
    liQuantity := ldAmount / 10;
    

    (ok it sais quantity = local integer and amount = local decimal)

    Is Quantity always an integer? Often it is in Navision but it doesn't have to be. In the 2nd snippet i can see a possible type conflict inmediatly in the first snippet i may think Quantity is a decimal. When reviewing code you do not easally look up type information for every variable you see.

    For the same i use them in 4GL development tools.
    In a world without Borders or Fences, who needs Windows and Gates?
  • DenSterDenSter Member Posts: 8,307
    99.9% of the time, Quantity is a decimal field or variable. Just to be sure, I ALWAYS check this when I do anything with code (and yes that involves opening the table designer to check the field datatype as well). I prefer not to have the prefix because it clutters what I see with letters that I don't use.

    Just because someone called a variable liQuantity, does not mean that it actually IS a local integer. Like I said before, I've seen a Purchase Header variable called SalesLine (in a report written by one of our customers), which only compiled because the code used fields that are present in both tables. I ALWAYS check types, and therefore I don't need prefixes.

    I agree with Emiel that the code snippet with the prefixes takes longer to read than the code without it. Besides, once you know what the type and scope is, you don't need the prefix anymore.

    The only reason that I put postfixes in my variable names is to prevent double names. Most of the time if I need a local Sales Line for instance, or a parameter, there already is a global variable of that type.
  • jesamjesam Member Posts: 100
    @janpieter
    Also a point i forgot to mention is when writing code i will detect possible type conflicts early.
    Again, when coding in Navision, I agree, but when coding VB.NET, Option Strict takes care of that for you (as it should).
    When you set Option Strict On, the compiler would indicate an error if you tried to assign a decimal value to an integer.
    When you have an editor that does background compilation (like VB6 or VB.NET) the compiler will warn you the moment you type that illegal line of code, which in turn removes the need to use these type prefixes. Alas, Navision doesn't have any of that, so we better use prefixes if we want to be able to read the code and understand it without have to look up a definition of some variable that might be declared 20 pages ahead (when reading the code on paper), or having to hunt through the anoying Symbol Menu for the variable and then still having to write it down to be able to remember it.
  • ShenpenShenpen Member Posts: 386
    will take a programmer about 3 years to actually program without any big boundaries.

    Holy Jingo! :)

    I means the developer you met is either a) stupid a**hole b) not forced to do REAL work by a REAL client.

    I always envy you comfortable Western European and American consultants. You always seem to have so nice clients, so nice projects, so easy work... Didn't you really have a client saying " Navision s**ks, you cheated me selling me this s**t, so I want to change everything the way I work or I won't pay the licence, nor the service, and even will charge a lawsuit!!!!" 90% of my client said this.

    It seems the life is really different in Eastern and Western Euope.

    3 years for developer? Are your customers are really so nice, so forgiving? Really so?

    I started at my previous job as a Navision Sales. I learned the basics of Manufacturing to be able to demo it as a salesman. Later on it became evident that I am a horrible salesman, I became a Manufacturing consultant. I started my first project. Every other consultant was an accountant, learned only in Navison finance. I had to implement WMS. An I had to do many, many changes. And then I had to do changes everywhere else because no one was there who dared to change Navision code, but the client needed something really, really different thant Navision. It was back the time of 3.6 And this was not an industry add-on they needed, but a country add-on, or a regional add-on: Navision For The East. It meant a total, radical change: to turn a liberal "nordic" software into a totally strict and inflexible "eastern" software.

    I learned more on Navision development in those 3 months that any comfortable western consutlant learns in 3 years. I worked 16 hours a day, neck-deep in code. I did not want to do it, but had no other choice - it was impossible for the customer to use standard Navision.
    Yes, it was a bad sale - but the only sale we got in our first 9 months. We had no choice.

    If there would a kind of "Navision developmen competition" I would beat of my 2.5 years of experience any western consultant of 10 years of experience. It is not boasting and I don't want to be rude, please forgive me if I seem to be rude. I am not a genius, I simply had to learn it in 3 months because had no other choice - there were customers, there were Navision and there was a gap a of 100 miles between them.

    So, learning time is not static. It depends on your country, and your customers.

    In Eastern Europe, it must be around 3 months - or less.




    .

    Do It Yourself is they key. Standard code might work - your code surely works.
  • ShenpenShenpen Member Posts: 386
    When you set Option Strict On, the compiler would indicate an error if you tried to assign a decimal value to an integer.

    Yes, if you are rich enough to buy Visual Studio .NET.

    The rest of the world uses #develop (SharpDevelop).

    Please, don't forget the rest of the world!

    Do It Yourself is they key. Standard code might work - your code surely works.
Sign In or Register to comment.