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

Опции темы Поиск в этой теме Опции просмотра
Старый 10.03.2017, 11:11   #1  
Blog bot is offline
Blog bot
19,641 / 663 (62) +++++++
Регистрация: 28.10.2006
Navigate Into Success: More about ISEMPTY

I had much second thought about whether I should even blog this one. You know, it so profoundly belongs in the Duh! category that I have actually created the Duh! category specifically for this post.

Now, fasten your seatbelt. I apologize for what you are about to see, but apparently people do write code as the example below. And I sh*t you not, you can’t really make this crap up, but this is what people do:

UNTIL Cust.NEXT = 0;


Let’s start with a disclaimer. As unbelievable as it may seem, code with along the lines of the “pattern” above did find its way into runtime, so I have to state this as directly as I possibly can: it is stupid. If you can’t see why it is stupid right away, then read about ISEMPTY first, and then read on.

As I said, this belongs to the Duh! category, and if you think so too, then there is no need to reed further, you won’t learn anything new.

I owe you a little background now. I would have never ever even thought of writing this post, not in my craziest dreams because I could never ever even have imagined that someone could do something as, well, sorry again, but something as stupid as this. But right after Waldo’s, Gary’s and my NAV TechDays 2016 session on Bad Habits of NAV Developers, a good friend of mine, who happens to be an escalation engineer with NAV support team (and those folks get to see more code than you and I will ever read, squared), approached me and told me: you should be careful with ISEMPTY!

“In what ways exactly should I be careful with ISEMPTY?” I said in disbelief.

And then she told me.

She told me that I couldn’t believe how many people complained to support about problems that arise from using ISEMPTY along the lines of the “pattern” from the beginning of this post. And she was dead serious.

So, this is why this post is here, and if you are still here with me, reading, in disbelief or otherwise, I hope you now agree with me that I simply had to write it.

And since I politely asked all the Duh! folks to not read further, if you are still here, it means that you are waiting for explanation why the example above was so incredibly stupid that it made me sleep an hour less just to be able to write this. So, here we go.

First of all, as you know now, ISEMPTY doesn’t really retrieve anything from the database. There is a universe-size difference between what Cust variable contains after this:


… and after this:


I hope you understand that. If not, then go back to my ISEMPTY post again and REPEAT reading UNTIL clear.

I believe that “I have heard that I should use ISEMPTY instead of FINDFIRST” postulate comes from “you should use ISEMPTY instead of FINDFIRST when you want to check if there are records there”. But people not always listen throughout, so the first part sticks, the second doesn’t.

Yes, people not only do IF COUNT = 0 to check if there are records there. They sometimes do IF FIND(‘-‘) instead (because they think that this still behaves as it used to in year
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Navigate Into Success: C/AL internals: Some more invalid object states Blog bot NAV: Blogs 0 19.10.2016 11:11
Navigate Into Success: From C/AL to executable: how NAV runs your C/AL code Blog bot NAV: Blogs 0 06.10.2016 13:11
Navigate Into Success: TempBlob Façade: a pattern proposition Blog bot NAV: Blogs 0 03.10.2016 09:11
Navigate Into Success: Getting more insight into exceptions in NAV Blog bot Dynamics CRM: Blogs 0 15.10.2014 08:00
Navigate Into Success: I had a dream: decoupled NAV Blog bot Dynamics CRM: Blogs 0 19.06.2013 05:44
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

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

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

Часовой пояс GMT +3, время: 02:42.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.