Skip to content

Suggestion: Rename Composite* classes to Chain* or Delegating* for GoF accuracy #214

@alanbem

Description

@alanbem

Currently, the framework uses the name Composite for several structural classes like CompositeFactory, CompositeHandler, and CompositeConverter.

While these classes structurally resemble the Gang of Four (GoF) Composite pattern (they implement an interface and hold a collection of children that also implement the interface), their behavior often aligns more closely with the Chain of Responsibility or a Delegator/Router.

For example, when CompositeFactory::create($id) is called, it loops through its child factories, catching InvalidAggregateIdGiven until one succeeds, and then it stops and returns. It essentially asks: 'Can you handle this? No? Next.'

A true GoF Composite typically forwards a method call to all of its children (like a tree of UI components drawing themselves). CompositeUnitOfWork is actually a great example of a true Composite, as commit() flushes all underlying UoWs.

Proposal:
For clarity and architectural precision, consider renaming the classes that loop-and-stop to better reflect their behavior in a future major version:

  • ChainFactory (or DelegatingFactory) instead of CompositeFactory
  • ChainHandler (or DelegatingHandler) instead of CompositeHandler
  • ChainConverter instead of CompositeConverter

This aligns with common framework naming conventions (e.g., Symfony's ChainRouter) and makes the mechanical intent of the class immediately obvious to developers reading the source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions