Skip to content

Conversation

Copy link

Copilot AI commented Jan 5, 2026

Documents the architecture decision to introduce CalculatorBase and CalculatorFactoryBase classes, separating calculator creation from state management as proposed in draft PR #181.

Structure

  • docs/adr/README.md - ADR index and format explanation
  • docs/adr/0001-calculator-factory-pattern.md - Complete decision record following MADR format

ADR Content

Context: Legacy InterfaceFactoryTemplate couples calculator creation with state management, inconsistent with other EasyScience factories (e.g., minimizers)

Decision: Introduce stateless factory pattern with three components:

  • CalculatorBase - Abstract calculator interface with calculate(), model/instrumental parameter management
  • CalculatorFactoryBase - Abstract factory with dynamic calculator discovery via _try_register_calculator()
  • SimpleCalculatorFactory - Concrete dictionary-based registry implementation

Deprecation: InterfaceFactoryTemplate marked deprecated with migration path documented

Additional: Map._storeMap.__store for proper encapsulation

Migration Example

# Before
class MyFactory(InterfaceFactoryTemplate):
    def __init__(self):
        super().__init__([BackendA, BackendB])

# After
class MyFactory(SimpleCalculatorFactory):
    def __init__(self):
        super().__init__()
        self._try_register_calculator('backend_a', 'pkg.backend_a', 'BackendA')
        self._try_register_calculator('backend_b', 'pkg.backend_b', 'BackendB')

calculator = factory.create('backend_a', model, instrument)

References

Original prompt

Create an ADR proposal based on this draft pull request


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 5, 2026 08:11
Co-authored-by: rozyczko <8266281+rozyczko@users.noreply.github.com>
Co-authored-by: rozyczko <8266281+rozyczko@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ADR proposal for project architecture Add ADR-0001: Calculator Factory Pattern from PR #181 Jan 5, 2026
Copilot AI requested a review from rozyczko January 5, 2026 08:16
@rozyczko rozyczko closed this Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants