Skip to main content

Posts

Featured

Using Java Lambdas to implement a chain processor

Chain of Responsibility is a well-known design pattern, some people hate it, some people love it  [Wikipedia] . I use a variation of the chain of responsibility to create a processing pipeline. In this variation, there are still a series of processing objects but the key difference is that the command object is passed through the chain of processors each applying its specific logic to the data in the command object and passing that command object to the next processor.   A processor can stop the chain if something has gone wrong, either by returning false from the interface method or by throwing an exception which can be caught by the caller of the chain's execute method. I will go through this variation step by step.  Step 1: Create the Link Interface This is the only interface that will be necessary for this variation. The chain interface is a functional interface and defines two items. First, a method definition that will be used in each link of the chain, I

Latest Posts

How to emulate a Java map using FlatBuffers

Initial Commit