What is the REPR design pattern
The REPR pattern is a software design pattern for developing API Endpoints implementing a simple Request EndPoint Response flow.
The REPR Design Pattern defines web API endpoints as having three components:
- Request - The shape of the data the endpoint expects
- Endpoint - Logic the endpoint performs given a request
- Response - The shape of the data the endpoint returns
Providing a simplified concepts to enable the development REST API endpoints and enforcing the Single Responsibility Principle for endpoints. The only Models that the Developers need to care about are the Request and Response.
Not all endpoints will require data for their Request or Response, in some cases taking in no inputs or returning just an HTTP status code. But an empty request or response is still a valid one in this pattern.
Why the REPR pattern
For .net developers, the typical traditional approach to developing REST API endpoints was to make use of the MVC (Model View Controller) pattern, which inadvertently lead to a number of issues, most notably what has become known as the Swollen Controller Problem , whereby controllers usually end up with a number of disparate methods which dont’t really belong together and the result is often that developers start drift from the path of developing REST Based methods and invariably end up collating a loose set of functions that are made available over Http End points.
This approach was typically promoted by Microsoft, primarily as a mechanism to try and reuse and take advantage of all the investment that they originally sunk into the ASP.net MVC.