Skip to content

Code duplication inside messages #96

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

Closed
Koc opened this issue May 22, 2017 · 9 comments
Closed

Code duplication inside messages #96

Koc opened this issue May 22, 2017 · 9 comments

Comments

@Koc
Copy link
Contributor

Koc commented May 22, 2017

The files

are almost identical. How it possible reuse code, like trait or something else?

@makasim
Copy link
Member

makasim commented May 23, 2017

That true, but I do not want to couple transports in any way. and I do not want to put more stuff to psr-queue lib.

@Koc
Copy link
Contributor Author

Koc commented May 23, 2017

It is ok put some common implementations to psr-layer. Something similar available for cache https://github.com/php-fig/cache-util/tree/master/src

@makasim
Copy link
Member

makasim commented May 23, 2017

Let's try it then.

@Koc
Copy link
Contributor Author

Koc commented May 23, 2017

Does messages implementations is different for different transports? Message is like value object, similar to cache item.

@makasim
Copy link
Member

makasim commented May 23, 2017

They are different. It may have additional stuff to what it the message interface require.

For example. AMQP message has a delivery tag which is used while ack\reject.

@bendavies
Copy link
Contributor

@makasim
Copy link
Member

makasim commented May 23, 2017

Yeap, that's my favorite.

@makasim
Copy link
Member

makasim commented May 23, 2017

DRY is not a silver bullet and could do harm as well

@makasim
Copy link
Member

makasim commented May 25, 2017

I give it a thought and me decided not to introduce a trait. There are the reasons:

  1. The most important. If we do a change in the trait because we need it in AMQP but at that time it breaks another Message from completely different transport.
  2. We remove duplication in easy to use and understand the code. Almost getters and setters
  3. The code is not expected to change often.

The solution: Provide a spec test case for messages so every implementation could be tested against it. This is addressed here: https://github.com/php-enqueue/enqueue-dev/pull/102/files

@makasim makasim closed this as completed May 25, 2017
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

No branches or pull requests

3 participants