Skip to content
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

Contracts should be defined by interface rather than abstract classes #2

Closed
stof opened this issue Aug 26, 2014 · 8 comments
Closed

Comments

@stof
Copy link

stof commented Aug 26, 2014

A good example is the EventDispatcher component (I haven't reviewed other components yet). The contact is defined by the AbstractEventDispatcher, which contains only public abstract methods.
Such abstract class does not have any benefit over an interface IMO (there is no implementation code in it, only a contract), but it imposes a strong constraint on the actual implementation (PHP does not support multiple inheritance).
why not using interfaces for the contracts ?

thus, using a typehint on AbstractEventDispatcher looks weird IMO, it is likely that some devs could end up typehinting the implementation instead (I would be in favor of using EventDispatcher as the name of the interface and finding a different name for the simple implementation provided, but this is a separate topic for which http://verraes.net/2013/09/sensible-interfaces/ explains it well)

@stof
Copy link
Author

stof commented Aug 26, 2014

The ReadModel component is affected as well.

wjzijderveld referenced this issue in wjzijderveld/broadway Aug 27, 2014
i2398: Create Scenario stub
wjzijderveld referenced this issue in wjzijderveld/broadway Aug 27, 2014
initial docs (migrated)
@asm89
Copy link
Member

asm89 commented Aug 27, 2014

There are cases where we use abstract classes to define contracts on our internal projects. For this open source project we see that adding some flexibility by using interfaces is probably better.

So +1 for refactoring the contracts towards interfaces. We'll try to do it ourselves in the upcoming time, but a pull request would be very welcome!

@sstok
Copy link

sstok commented Aug 27, 2014

👍

1 similar comment
@mbadolato
Copy link
Contributor

👍

@kelvinj
Copy link
Contributor

kelvinj commented Aug 28, 2014

I'm going to take this unless someone else has started.

@wjzijderveld
Copy link
Member

We haven't started yet, so go for it :)

@wjzijderveld
Copy link
Member

On a sidenote (we still need to update the README's), on freenode we have #qandidate where we can discuss stuff when slow-chatting on github doesn't work :)

@wjzijderveld
Copy link
Member

Fixed by #26

othillo added a commit that referenced this issue Feb 13, 2020
* Feature/phpunit8 (#1)

 - PHPUnit ^8.0 ready
 - php 7.4 ready
 - code sniffer fixes

* Feature/phpunit8 (#2)

php 7.4, phpunit 8.0

* rollback to phpunit ^6.0

* rollback to phpunit 6

* back to phpunit 8

Co-authored-by: rppgorecki <rppgorecki@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants