However, BINDSUBSCRIPTION requires a codeunit variable of an exact codeunit subtype, and as soon as you declare such a variable, loose coupling is gone down the drain. Since one of the goals of this pattern is to allow state preservation between calls, the only way to achieve that is through BINDSUBSCRIPTION function. Infrastructure belongs into a separate codeunit: the module binder codeunit. Obviously, there is no infrastructure code here. NET API I invoked here are irrelevant, they are merely to illustrate some specific business logic and what a typical business logic codeunit would look like. The business logic above is obviously “logging” events into a Twitter account, with authorization information stored in a table. Module is a codeunit pair: one codeunit in charge of business logic, and one codeunit in charge of infrastructure. The infrastructure – which I said is completely separated from the business logic – will take care of properly binding a subscriber and making sure that the event was handled, and handled only once. We don’t set pass a boolean value indicating whether event has been handled, nor we pass any subscriber identification. What you can see here is that the published event does not have any parameters related to infrastructure, like the “handled” pattern used to have. Probably not, but I’ll complicate it a slight bit later on, just not quite yet. Unlike other facades we saw earlier, this one does not need to execute any business logic, like finding a correct dependency or anything, it merely needs to raise an event, like this: This public method is the façade that channels the call to the correct type of dependency. So, unsurprising, this interface is a codeunit that exposes a public method. Interface, or façade, is the same kind of a component as was used in other façade-based patterns I wrote bout in the previous posts (arguments table façade and TempBlob façade). Unfortunately, at a thin level it still has a sort of a gentlemen’s agreement, but at a thinner level, that’s easier to enforce.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |