Design Patterns · Middle · Question 38 of 75

What is the Registry pattern, using plugins as an example?

const renderers = new Map();
export const register = (type, fn) => renderers.set(type, fn);
export const render = (block) => renderers.get(block.type)?.(block);

Explanation

This is how extensible systems are built: CMS editor blocks, dashboard widgets, validation rules. A new type is added by registration, without changing the core (OCP).

Further reading

Problem with a question

Design Patterns · Middle · question 38

Test yourself

Take the Design Patterns · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz