mardi 15 octobre 2019

PHP Document Factory Design Patterns

I have a system structured out. It works exactly as I want it to work, but I'm curious if I'm using the right naming conventions for the structures involved.

Base classes:

  • Report classes: Encapsulates criteria for querying data from the database. Also uses the database connection to fetch its base data.
  • Document class: Represents a file (Excel, PDF, etc.) with filesystem, filename/url, etc.
  • ReportDocument class: Extension of Document contextualized for a Report
  • DocumentFactory class: Creates the appropriate Document based on need.

Structural classes:

  • DocumentStrategy classes: Handles the actual saving mechanism while being worked on (saving to temp based on needs defined by whatever library handles the saving) and informs the Document where it's located in the temporary filesystem.
  • ReportHydrator classes: Specific Hydrators for specific Reports and Strategies with a defined hydrate method that receives some kind of handle from the Strategy, which the Hydrator uses to do more specific processing (i.e. an Excel strategy establishes a base spreadsheet, but the Hydrator writes specific data to specific cells)

Is there a better way of naming these structures? Should I move around responsibilities of these at all?

Aucun commentaire:

Enregistrer un commentaire