What is it about?

Initializing complex objects in programming is a tedious, error-prone and often ambigous task that requires a high cognitive load and/or looking at the documentation frequently. The Sequential Initializer Pattern makes this process simple and error-free. We achieve this by enforcing a series of function calls which are responsible for initialization of the semantically different parts of the complex object. This improves both readability and writeability of code and reduces the cognitive load of the programmer as well as the documentation lookups.

Featured Image

Why is it important?

There are many errors a programmer can make when initializing a complex object with many parameters. A wrong number of parameters could be passed, false default values could potentially be set, parameters can be mixed up, or it does not become clear to the programmer which parameter is for what without looking at the documentation and many more. The same happens when reading code where a complex object gets initialized. What do the parameters stand for? Was a default value used somewhere? All this becomes clear and unambiguous using the Sequential Initializer pattern and modern IDEs support the pattern naturally resulting in a smooth workflow.

Perspectives

This pattern helps in so many ways and prevents so many errors that I don't see why anyone wouldn't want to use it.

Martin Eisemann

Read the Original

This page is a summary of: The Sequential Initializer Pattern, July 2022, ACM (Association for Computing Machinery),
DOI: 10.1145/3551902.3551967.
You can read the full text:

Read

Resources

Contributors

The following have contributed to this page