Тёмный

Thursday nugget - Interfaces in Business Central 

Dennis Fredborg
Подписаться 497
Просмотров 377
50% 1

In this Thursday nugget, we will take a look at how to use interfaces in Business Central, all the source code can be found here: dev.azure.com/...

Опубликовано:

 

18 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 2   
@blja
@blja 3 года назад
Hi Dennis, do i understand this correctly there is no code written inside the function that are in the interface? So you just implement it in the CU and call the function. Can you change the parameters of the function inside the CU? And why would we use an interface in the first place instead just write the logic in the CU?
@dennisfredborg
@dennisfredborg 3 года назад
Hi, The idea behind an interface vs a codeunit is that an Interface it a strong contract, which means that if you wish to extend some code though an interface you must implement all the functions, this helps to avoid writing code that will break because it expects a function that is not there. So the idea is that if you create an interface I can then implement this interface knowing that whom ever might change code in your underlying functions, my code will still work because I have subscribed to your interface and not the underlying code. A good example of this is in the base app if you look at the Price Calculation, because it is written based on an interface you can safely change between the different implementations, because there is a strong contract, so I would know that everything is handled in one way or another. I know that the concept of interface can seem very abstract, but if you are interested you should try to look at how interfaces work in C# since there is much more documentation, and the concept is the same for AL.