Skip to content

Parallel Architecture

Dennis C. Mitchell edited this page Mar 11, 2019 · 4 revisions

The EDennis.AspNetCore.Base library supports two abstraction patterns which, in multi-tier applications, represent a parallel architecture of sorts.

The first abstraction pattern, the repository, provides a light wrapper around Entity Framework operations. With the repository pattern, read and write operations on a database are exposed as regular POCO methods. Operations such as inserting, updating, and deleting and automatically saved. When relevant, temporal operations (e.g., saving to a history table) are performed automatically. In web applications or APIs, repositories are dependency injected into controllers, which invoke the repository methods. For more information on the repository pattern, see Pro ASP.NET Core MVC and Pro Entity Framework Core 2 for ASP.NET Core MVC by Adam Freeman.

The second abstraction pattern, the API client (sometimes called a service proxy), provides a wrapper around HttpClient operations. With the API client pattern, calls to GET, POST, PUT, and DELETE endpoints of an API are exposed as regular POCO events, just like repository methods. In web applications or APIs, API clients are dependency injected into controllers, which invoke the API client methods. For more information on API clients, see Steve Gordon's post on HttpClientFactory and Typed Clients.

The benefits of abstraction in programming are well-known. By hiding implementation details behind a functional interface, abstractions such as repositories and API clients make it much easier for consuming code (e.g., controller methods) to perform various actions and also allow implementation details to change without changing the consuming code. Moreover, developers can help team members (and their future selves) by creating and thoroughly testing abstractions, allowing these abstractions to represent trusted code that can simply be used -- like a car can be used without knowing what is going on behind the dashboard.

Parallel Architecture Image

Clone this wiki locally