Browse Java Design Patterns & Enterprise Application Architecture

Adding Functionality at Runtime with the Extension Object Pattern

Add runtime capabilities in Java carefully so extension objects stay explicit and do not turn into hidden service locator behavior.

On this page

Extension Object is attractive because it allows capabilities to appear at runtime. That flexibility is useful, but it can also hide too much.

Good Uses

  • plugin capabilities
  • optional exporters or renderers
  • feature modules loaded conditionally

Risks

  • callers stop knowing which capabilities are available
  • capability lookup becomes implicit and fragile
  • the design drifts toward a service locator

Review Rule

Dynamic extension is strongest when capability discovery is explicit and failure to find an extension is treated as a first-class outcome.

Revised on Thursday, April 23, 2026