liveBook · Manning

Business logic

As explained in .NET MAUI in Action

Business logic is software logic that represents an application's business rules, processes, and decisions.

Business logic represents a real-world problem in code: its objects, rules, processes, decisions, and operations. It is different from UI logic and presentation logic, which control appearance, behavior, and screen state. section 9.3

In a .NET MAUI application, business logic can include:

  • Models representing real-world objects, such as products, users, or cars, together with operations that change their state. section 9.3
  • Rules for processing user input and methods that query a database or API using specific criteria. section 9.3
  • Services that provide reusable application functionality instead of placing that logic in XAML page code-behind files. section 8.1

MauiStockTake inventory workflow

The View handles controls, while the ViewModel exposes commands and state. A ProductService searches for products, and an InventoryService sends the submitted stock count to an API. Product and stock-count models hold domain data. This arrangement lets the UI change independently from the business logic and permits the API implementation to change without rewriting the rest of the app. section 9.5 section 9.6

Figure 9.3 With the MVVM pattern, UI logic, which includes layouts and UI behavior like animation and text formatting, belongs in the View. Presentation logic, which includes the UI state such as the values of properties in the UI and logic for responding to user actions, belongs in the ViewModel. Business logic, such as rules for processing user input, or communicating with an API, belongs in the Model.

Use the MVVM separation diagram to distinguish business logic in the Model from presentation logic in the ViewModel and UI logic in the View. section 9.3

How .NET MAUI in Action covers it

How deep it goes
Defines models, rules, queries, and services, then demonstrates their placement in an MVVM application without detailing implementation internals.
Examples
Uses product searches, inventory counting, user-input rules, domain models, and services communicating with REST or GraphQL APIs.
What it assumes
Assumes familiarity with application UI concepts but teaches the separation between UI, presentation, and business responsibilities.
What you can do after
Apply it via MVVM by placing domain behavior in models or services and exposing required functionality through ViewModels.
How it connects
Connects business logic with domain models, services, MVVM, dependency inversion, APIs, UI logic, and presentation logic.

Also explained in

Compare how 10 books explain business logic →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET MAUI in Action. The section links point to the parts of the book it draws on.