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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 24.02.2009, 08:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
X++: Is the X++ Compiler Too Flexible?
Источник: http://blogs.msdn.com/x/archive/2009...ible-font.aspx
==============

In Microsoft Dynamics AX 2009, the X++ compiler is sometimes too flexible in its rules for code. It is likely at some of these flexibilities will be eliminated in future releases.

This blog entry describes some flexibilities of the X++ compiler that we recommend you not utilize.





[1] Sequence of Default Parameters



Recommendation: In a method declaration, declare parameters that have default values after the last parameter that has no default.



The X++ compiler and runtime currently allows you to disregard this recommendation, as the following code example demonstrates.





class MyClass

{

static public int AddTwoNumbers

(int _firstNum = 4

,int _secondNum)

{

return (_firstNum + _secondNum);

}

}





The following job calls the above AddTwoNumbers method. Notice there is no way to accept the default value of the _firstNum parameter.





static void Job1(Args _args)

{

int iAnswer;

iAnswer = MyClass::AddTwoNumbers(8 ,16);

print( IAnswer );

pause;

}







[2] Access Modifier on Methods



Recommendation: Each time you create a new method on a class, explicitly add an access modifier to the method declaration, meaning public, protected, or private.

If no access modifier is given, the default behavior is public.







[3] No Access Modifier on Classes



Recommendation: Do not add an access modifier to any class declaration.

The X++ compiler ignores the keywords public and protected and private on classes, so adding an access modifier can only confuse other programmers. In effect, all X++ classes are public.







[4] Put TODO First



Recommendation: The TODO should be the first non-whitespace after the start of the comment.



When the X++ compiler detects the string TODO in a comment, it lists a task on the Tasks tab of the compiler output window. The compiler goes a little too far in trying to detect a TODO. For instance, the TODO is detected in each of these two examples:





// Remember TODO Remove the diagnostic prints.





/* Important TODO:

Rewrite this SQL as a more efficient set operation.

*/





The two above examples would be fine if the first words were removed: it would be better to remove the first words Remember and Important.





Источник: http://blogs.msdn.com/x/archive/2009...ible-font.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axaptapedia: Macro Blog bot DAX Blogs 1 16.11.2007 09:48
Issues concerning X++: Macros - Definitions and Pitfalls Blog bot DAX Blogs 0 15.11.2007 09:20
Issues concerning X++: Correction guide - Compiler warnings Blog bot DAX Blogs 0 30.08.2007 04:41
mfp: New blog from the X++ compiler team Blog bot DAX Blogs 0 25.06.2007 20:40

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

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

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