Intent Callback is a piece of executable code that is passed as an argument to other code, which is expected to call back (execute) the argument at some convenient time. Explanation Real world example We need to be notified after executing task has finished. We pass a callback method for the executor and wait for it to call back on us. In plain words Callback is a method passed to the executor which will be called at defined moment.
Collection Pipeline
Intent Collection Pipeline introduces Function Composition and Collection Pipeline, two functional-style patterns that you can combine to iterate collections in your code. In functional programming, it’s common to sequence complex operations through a series of smaller modular functions or operations. The series is called a composition of functions, or a function composition. When a collection of data flows through a function composition, it becomes a collection pipeline. Function Composition and Collection Pipeline are two design patterns frequently used in functional-style programming.
Also known as Composition pattern Intent The functional pattern representing a style of organizing libraries centered around the idea of combining functions. Putting it simply, there is some type T, some functions for constructing “primitive” values of type T, and some “combinators” which can combine values of type T in various ways to build up more complex values of type T. Explanation Real world example In computer science, combinatory logic is used as a simplified model of computation, used in computability theory and proof theory.
Event Driven Architecture
Intent Send and notify state changes of your objects to other applications using an Event-driven Architecture. Class diagram Applicability Use an Event-driven architecture when you want to create a loosely coupled system you want to build a more responsive system you want a system that is easier to extend Real world examples Chargify, a billing API, exposes payment activity through various events ( Amazon’s AWS Lambda, lets you execute code in response to events such as changes to Amazon S3 buckets, updates to an Amazon DynamoDB table, or custom events generated by your applications or devices.
Fluent Interface
Intent A fluent interface provides an easy-readable, flowing interface, that often mimics a domain specific language. Using this pattern results in code that can be read nearly as human language. Explanation The Fluent Interface pattern is useful when you want to provide an easy readable, flowing API. Those interfaces tend to mimic domain specific languages, so they can nearly be read as human languages. A fluent interface can be implemented using any of
Intent Monad pattern based on monad from linear algebra represents the way of chaining operations together step by step. Binding functions can be described as passing one’s output to another’s input basing on the ‘same type’ contract. Formally, monad consists of a type constructor M and two operations: bind - that takes monadic object and a function from plain object to monadic value and returns monadic value return - that takes plain type object and returns this object wrapped in a monadic value.
Async Method Invocation
Intent Asynchronous method invocation is a pattern where the calling thread is not blocked while waiting results of tasks. The pattern provides parallel processing of multiple independent tasks and retrieving the results via callbacks or waiting until everything is done. Explanation Real world example Launching space rockets is an exciting business. The mission command gives an order to launch and after some undetermined time, the rocket either launches successfully or fails miserably.
Event-based Asynchronous
Intent The Event-based Asynchronous Pattern makes available the advantages of multithreaded applications while hiding many of the complex issues inherent in multithreaded design. Using a class that supports this pattern can allow you to: Perform time-consuming tasks, such as downloads and database operations, “in the background,” without interrupting your application. Execute multiple operations simultaneously, receiving notifications when each completes. Wait for resources to become available without stopping (“hanging”) your application. Communicate with pending asynchronous operations using the familiar events-and-delegates model.
Producer Consumer
Intent Producer Consumer Design pattern is a classic concurrency pattern which reduces coupling between Producer and Consumer by separating Identification of work with Execution of Work. Explanation Real-world example Consider a manufacturing process of item, the producer will need to pause the production when manufacturing pipeline is full and the consumer will need to pause the consumption of item when the manufacturing pipeline is empty. We can separate the process of production and consumption which work together and pause at separate times.