-
-
Notifications
You must be signed in to change notification settings - Fork 180
Decompose entity inheritance hierarchy into traits and interfaces with composition #1172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: jbtronics <[email protected]>
Co-authored-by: jbtronics <[email protected]>
Co-authored-by: jbtronics <[email protected]>
Co-authored-by: jbtronics <[email protected]>
Co-authored-by: jbtronics <[email protected]>
Co-authored-by: jbtronics <[email protected]>
|
@copilot Adopt the existing entities to the new trait structure. |
Could you clarify what you'd like me to do? The existing entities (Category, Manufacturer, Supplier, etc.) already benefit from the trait-based structure through inheritance. Would you like me to:
The current implementation maintains backward compatibility - all entities work as before but the base classes now use traits internally. |
|
@copilot Remove the inheritance and replace it by composition of traits |
…ition - Remove inheritance from AbstractPartsContainingDBElement - Add explicit trait usage: DBElementTrait, NamedElementTrait, TimestampTrait, AttachmentsTrait, MasterAttachmentTrait, StructuralElementTrait, ParametersTrait - Implement all required interfaces directly - Initialize traits in constructor - Add custom __clone and jsonSerialize methods Co-authored-by: jbtronics <[email protected]>
Refactored remaining entities to use trait composition instead of inheritance: - MeasurementUnit - uses all structural traits directly - PartCustomState - uses all structural traits directly - Manufacturer - uses all structural traits + CompanyTrait - Supplier - uses all structural traits + CompanyTrait - AttachmentType - uses all structural traits directly All entities now use explicit trait composition with: - DBElementTrait, NamedElementTrait, TimestampTrait - AttachmentsTrait, MasterAttachmentTrait - StructuralElementTrait, ParametersTrait - CompanyTrait (for Manufacturer and Supplier) All entities implement required interfaces directly instead of inheriting them. Co-authored-by: jbtronics <[email protected]>
Done! All 8 concrete entities now use trait composition instead of inheritance: Commits:
Changes:
All entities removed deep inheritance chains in favor of explicit trait composition. |
Refactors the deep entity inheritance hierarchy into composable traits and explicit interfaces, replacing inheritance with trait composition in all concrete entities.
Changes
New Traits (5)
Extracted functionality from base classes into reusable traits:
New Interfaces (4)
Define explicit contracts for entity capabilities:
Refactored Base Classes
Replaced inline implementations with trait composition:
Refactored Concrete Entities (8)
Replaced inheritance with explicit trait composition:
Each entity now:
__construct(),__clone(), andjsonSerialize()methodsExample Usage
Entities now use explicit trait composition:
Impact
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.