Hi Folks,
In this post let’s
learn about Friend packages in D365FO, which are part of the development model
and are configured via Visual Studio.
A friend package allows one model/package
to access internal members (classes/methods) of another package. Normally, only
public elements are accessible across models, but this feature extends
controlled visibility. They should be used carefully as part of a well-governed
architecture strategy.
This feature
allows controlled access between models/packages, specifically enabling access
to internal elements without exposing them as public APIs.
For instance, A core framework model contains internal helper classes for
integration. Instead of making them public, you declare integration models as
friend packages so they can reuse internal logic safely
Without
Friend Package: - Only public elements are accessible
With Friend
Package: - Both public and internal elements are accessible (controlled)
Why Use Friend Packages?
•
Maintain proper encapsulation
•
Avoid making everything public
•
Enable controlled reuse of
logic
•
Improve architectural
cleanliness
How to Configure
•
Open Visual Studio
•
Navigate to Extension menu → Dynamics 365 → Model Management → Update model
parameters
•
Select model
•
Proceed to ‘Select friend
packages’ step
•
Add required package
•
Finish and rebuild
Benefits
•
Better encapsulation
•
Controlled reuse
•
Cleaner architecture
•
Reduced duplication
Limitations
•
Not a replacement for APIs
•
Can introduce tight coupling if
misused
•
Requires governance
No comments:
Post a Comment
Thanks