Arch Forum 2024-11-14¶
Participants: Backend devs, Magnus, Victor and Zak
Agenda¶
- Contracts (Api, Service and Domain)
- Dotnet format (Rasmus)
Notes¶
Contracts (Api, Service and Domain)¶
Service.Contracts and Api.Contracts type sharing¶
Lars asked, can/should *.Api.Contract use types from *.Service.Contract? And if so, what types should be reused? Today we often reuse Enums, but not other types.
Looking at the current projects, almost everywhere we have this dependency: https://dev.azure.com/MAJORITY/Bank/_search?action=contents&text=file%3A*Api.Contract.csproj%20AND%20%22Minority.%22&type=code&lp=code-Project&filters=ProjectFilters%7BBank%7D&pageSize=25
Service.Contracts and Domain.Contracts¶
When should *.Domain.Contract be used?
Domain.Contracts are today in bank-core-platform, but we recently decided to try and move them to each area Arch Forum 2024-10-17. However, at that time we did not discuss/clarified what should be there.
Existing usages:¶
Only Enums:
- Kyc.Domain.Contract
- SalesTool.Domain.Contract
- FeesAndPromotions.Domain.Contract
- Cashback.Domain.Contract
Interface:
- Cde.CardIssuer.Contract
- Cde.TransactionProcessor.Contract
Others:
- Core.Shared.Contract Contains Enums, Models (Api and Service), Events, Exceptions, Attribute and a constant.
- Sms.Domain.Contract Contains Enums and an Event.
- Transactions.Domain.Contract Contains Enums, Models, Events, Exceptions, helper extension methods and Service/Api contracts for Transaction Details.
- User.Domain.Contract Contains Enums and a helper extension method for one of the Enums.
- Wallet.Domain.Contract Contains Enums, Models and Events.
Guideline:¶
Minority.[AreaName].Service&Minority.[AreaName].Apishould contain all implementation code. Area-internal Interfaces and Events (and related Models) should also be contained here.Minority.[AreaName].Api.Contractshould contain the public Api interface including its Models (Api that apps and other external third parties use).Minority.[AreaName].Service.Contractshould contain the backend internal Interfaces and Events (and related Models) if possible.Minority.[AreaName].Domain.Contractshould contain as little code as possible. Only code that cannot reasonably be in the area Api or Service contract should be put here.- Enums can be shared, e.g. by importing
Service.ContractinApi.Contract, if it make sense. (Ideally this would not be the case, but it would be a big task to update everywhere)
A typical use case of Domain.Contract is circular dependencies
A.Service.Contract references B.Enum
B.Service.Contract references A.Enum
Now
B.Enum and A.Enum cannot both be in their respective service areas, since that would create a circular dependency.
Comments¶
The above guideline mainly clarifies what we already do. If everything started from scratch a different setup could very well be better. During discussion it was not full agreement of how much should ideally be in the Domain contracts, but given the current state of the code, the above guidelines are reasonable.
Dotnet format (Rasmus)¶
Rasmus demoed how dotnet format with .editorconfig works, and showed how running jb locally took 50s while dotnet format 12s. There were no time for discussion afterwards, but this is a promising "modernization" of our formatting/linting tools. Victor and Rasmus will follow up and present a concrete suggestion at a later time.
Presentation here: Majority Code Formatting