Code reuse means placing logic where multiple pages, applications, or platforms can use it instead of implementing the same behavior repeatedly. Moving business logic from page code-behind into services reduces UI coupling and makes the logic available wherever it is needed. section 8.1
Apply reuse progressively:
- Define the required functionality and describe it with interfaces before implementing services. section 8.1
- Share DTOs and client packages between projects so structural changes are visible across the solution. section 8.4.2
- Package reusable business logic, UI, and UX modules as NuGet packages for use across enterprise solutions. section 8.4.3
MauiStockTake
A product-search and inventory-counter app can put its functionality in services rather than page code-behind. The same logic can then support multiple pages, while shared client code can extend to cloud, mobile, desktop, web, and future enterprise applications. section 8.1 section 8.4.2
Figure 8.6 MauiStockTake is a full-stack solution written in C#. Therefore, there is no need to duplicate code as it can be shared across the stack. Code shared across the stack in this way is referred to as cross-cutting concerns.
Use the full-stack diagram to see how a C# solution shares code across cloud, mobile, desktop, and web layers without duplicating cross-cutting concerns. section 8.4.2
Figure 8.7 The MauiStockTake app becomes part of an ecosystem if Mildred introduces a customer portal as well, which may require (among other things) an indication of the availability of products. The customer portal would likely have its own API, which could query the MauiStockTake API for this information. The customer portal could be built in Blazor, which would allow its controls to be abstracted back to a Razor class library. The class library could be used by .NET MAUI Blazor to provide the customer portal as an app, too. The controls in the MauiStockTake app could be abstracted back to a .NET MAUI class library to be shared with future apps too, which would maintain the visual consistency of Mildred’s brand.
Use the ecosystem diagram to trace shared business logic and UI across applications, APIs, Blazor, .NET MAUI, and reusable class libraries. section 8.4.3





