Read with me what the Microsoft Dynamics NAV 2009 Developer and IT Pro Documentation phrases on BEGIN/END, i.e. compound, statement:
In some cases, the C/AL syntax only allows you to use a single statement. If however you have to execute more than one simple statement, the statements can be written as a compound statement by enclosing the statements between the BEGIN and END keywords.
Typically these cases can be:
So, as the quoted sentence states, the compound statement is applied when more than one statement is needed where the structure of the conditional, repetitive or WITH statement expects - or should I say: allows - only a single statement. Note that there is no explicit mentioning that you should use the compound statement, i.e. en-wrapping BEGIN/END, only in case of multiple statements. However, looking at the standard application, it has been the intention that this is part of the best practices. In spite of what others might argue - see for example this post: IF Without BEGIN and END Considered Harmful.
Comparing NAV 2013 Beta en NAV 2013 RTM I dare to assert that this best practice has been affirmed as many redundant BEGIN/END wrappers have been cleared out of the code. With many I mean many. I am not sure enough to say all.
See some examples in the screen shot.
Click on the images to get a full view that's readable.
This beta to RTM information is for IT students and this give you give that to how to deal with striking codes. I have dissertation help for academic assignments and article work. I hope you people enjoy this amazing service.
Thanx, Erik. One more battle field where we join arms. ;-)
When I started in college learning programming our first and primary development language was Pascal (first Poly Pascal - created by Anders Hejlsberg - the brother of Thomas Hejlsberg - later Turbo Pascal).
At that time it was the most used development language on PC's in Denmark, and also the same language they used to create Navision and which later also was used to create AL - Application Language (later C/AL). The basic syntax of C/AL has always been Pascal. Whenever I have been writing code in Navision the Pascal syntax has always been important. Code have to follow the syntax to continue to be as simple as possible to read.
And this is where the BEGIN/ENDs come in. So I really loved reading this post! Because over the last 5-6 years we have seen more and more code coming from Microsoft which had lots of unnecessarily BEGIN/END's and therefor was not correct (in my mind). BAD CODE! Lol.
I hope the next they start looking at is the correct indention of the remaining BEGIN/END's!