AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 04.11.2012, 19:54   #1  
Blog bot is offline
Blog bot
Участник
 
25,644 / 848 (80) +++++++
Регистрация: 28.10.2006
This last item in my NAV2013 Beta to RTM - Some Striking Code Changes series is addressing code changes NAV core team made to get IF-THEN-ELSE statements coding standards compliant.

If you read the Microsoft Dynamics NAV 2009 Developer and IT Pro Documentation on IF-THEN-ELSE, and also on the use of parentheses, you'll notice that there are quite some conventions to take into account. Quite some to violate, isn't it?

Let's take some exemplar code changes that underline these conventions. It think it's a good way to refresh your coding standards knowledge, like most of the previous posts in this series could have done that somehow.


1. EXIT or ERROR as last statement in the THEN part of an IF-THEN-ELSE?
Do not continue with an ELSE statement

Correct

IF <Condition> THEN
<Statement Block ending with ERROR or EXIT>
<Statement>
Incorrect

IF <Condition> THEN
<Statement Block ending with ERROR or EXIT>
ELSE
<Statement>Click on the image to get a full view that's readable.




2. Compound or long expressions after IF?
THEN should be on a new line and aligned with IF

Correct

IF <Condition1> AND
<Condition2>
THEN
<Statement>
...
Incorrect

IF <Condition1> AND
<Condition2> THEN
<Statement>
...Click on the images to get a full view that's readable.






Note
This also applies to the DO part of a WHILE-DO statement


3. Use parentheses only to enclose compound expressions inside compound expressions
I.e. do not use redundant parentheses.

Correct

IF Boolean1 AND Boolean2 AND (x = y) THEN
<Statement>
...Incorrect

IF ((Boolean1) AND Boolean2 AND (x = y)) THEN
<Statement>
...Click on the images to get a full view that's readable.






Note
This also applies to WHILE-DO and CASE statements



Читать дальше
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 22:30.