Speaking with developers, I’m always surprised to find a surprising percentage are surprised and baffled by the “Fluent API”. This object-oriented convention is based on the Builder Pattern, and involves call chaining to construct a configured object. So, for example, if you needed to configure a SystemHandler object to have a series of LinkHandler objects, you might have something like this:

    Handlers = SystemHandler.builder()

Each method of the builder object modifies the builder and then returns the modified instance, giving Object-Oriented programs a sort of composability. Compared to passing a thousand parameters to the constructor, it also offers a nice bit of readability.

I bring this up, because Mireille’s co-worker is likely the sort of person that would be confused by a Fluent API.

public HandlerChain()
        Handlers =
                new SystemHandler(
                        new Link1Handler(
                                new Link2Handler(
                                        new Link3Handler(
                                                new Link4Handler(
                                                        new Link5Handler(
                                                                new Link6Handler(
                                                                        new Link7Handler(
                                                                                new Link8Handler(
                                                                                        new Link9Handler(
                                                                                                new Link10Handler(
                                                                                                        new Link11Handler(
                                                                                                                new Link12Handler(
                                                                                                                        new Link13Handler(
                                                                                                                                new Link14Handler(
                                                                                                                                        new Link15Handler(
                                                                                                                                                new Link16Handler(
                                                                                                                                                        new Link17Handler(
                                                                                                                                                                new Link18Handler(
                                                                                                                                                                        new Link19Handler(
                                                                                                                                                                                new Link20Handler(
                                                                                                                                                                                        new Link21Handlerx(
                                                                                                                                                                                                new Link22Handler(
                                                                                                                                                                                                        new Link23Handler(
                                                                                                                                                                                                                new Link24Handler(
                                                                                                                                                                                                                        new Link25Handler(
                                                                                                                                                                                                                                new DefaultHandler(
                                                                                                                                                                                                                                        new Link26Handler(
                                                                                                                                                                                                                                                new link27Handler(
                                                                                                                                                                                                                                                        new Link28Handler(
                                                                                                                                                                                                                                                                new Link29Handler(
                                                                                                                                                                                                                                                                        new Link30Handler(
                                                                                                                                                                                                                                                                           new Link31Handler(
                                                                                                                                                                                                                                                                                   new Link32Handler(
                                                                                                                                                                                                                                                                                          new Link33Handler(
                                                                                                                                                                                                                                                                                                 new Link34Handler(
                                                                                                                                                                                                                                                                                                        new Link35Handler(
                                                                                                                                                                                                                                                                                                                new Link36Handler(
                                                                                                                                                                                                                                                                                                                        new Link37Handler (
                                                                                                                                                                                                                                                                                                                                new Link38Handler(
                                                                                                                                                                                                                                                                                                                                        new Link39Handler(
                                                                                                                                                                                                                                                                                                                                                new Link40Handler(
                                                                                                                                                                                                                                                                                                                                                        new Link41Handler(
                                                                                                                                                                                                                                                                                                                                                                new Link42Handler(
                                                                                                                                                                                                                                                                                                                                                                        new Link43Handler(
                                                                                                                                                                                                                                                                                                                                                                                new Link44Handler(null))))))))))))))))))))))))))))))))))))))))))))));

Much cleaner and simpler than my original solution. I stand corrected.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!