nfe / client-php

Official NFe.io API Client for PHP
https://nfe.io
MIT License
40 stars 18 forks source link

Prefer composition over inheritance #4

Closed renatonascalves closed 8 years ago

renatonascalves commented 8 years ago

Error reported here: https://github.com/nfe/woocommerce-nfe/issues/3

Currently Nfe_ServiceInvoice extends APIResource to make requests to the API. And APIResource extends Nfe_Object to use random utility methods. This makes the code very hard to understand, change and maintain.

The Service Invoice is not an API caller, it should use an API caller to send requests. So it should use composition. The first task I would start would be: Refactor APIResource to be used as composition instead of inheritance.

Some reference about composition over inheritance: https://www.thoughtworks.com/insights/blog/composition-vs-inheritance-how-choose https://en.wikipedia.org/wiki/Composition_over_inheritance

renatonascalves commented 8 years ago

Atualizado onde possível para composição.... Algumas heranças foram mantidas, pois não vi necessidade em alterar.