liveBook · Manning

Imperative approach

As explained in Spring Security in Action, Second Edition

An imperative approach processes a bulk of available data as a whole rather than incrementally as data arrives.

An imperative approach processes the bulk of available data as a whole. A client sends all data required for an operation to a server endpoint, which then processes it. section 17.1

Typical applications include:

  • Uploading several selected files after the backend receives them all. section 17.1
  • Processing a complete request payload before producing the result. section 17.1

Unlike a reactive approach, it does not process data in fragments as it arrives. It waits until the required data is available, making the distinction useful when choosing an application model. section 17.1

Milk bottling

A non-reactive factory receives all its milk in the morning and delivers the bottled orders in the evening. This models bulk processing before delivery. section 17.1

Figure 17.1 Non-reactive vs. reactive. In a non-reactive approach, the milk factory gets all the milk to be packaged in the morning and delivers all the boxes in the evening. In a reactive approach, as the milk is brought to the factory, it’s packaged and then delivered. For this scenario, a reactive approach is better as it allows milk to be collected throughout the day and delivered sooner to the clients.

Compare whole-batch processing with processing that begins as data arrives. section 17.1

How Spring Security in Action, Second Edition covers it

How deep it goes
Defines bulk processing and contrasts it with incremental processing through file-upload and factory analogies, without implementation details.
Examples
Uses client file uploads and a milk-bottling factory to illustrate complete-input processing.
What you can do after
Evaluate whether an application waits for complete input or processes data incrementally as it arrives.
How it connects
Contrasts imperative processing with reactive processing and motivates the Reactive Streams specification.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring Security in Action, Second Edition. The section links point to the parts of the book it draws on.