-
Notifications
You must be signed in to change notification settings - Fork 0
Extends or encapsulate queue layers
Walter Dal Mut edited this page Jan 22, 2017
·
3 revisions
Typically i prefer encapsulation over extensions but if you want to pass around the Corley\Queue\Queue
in your application in order to drop-out the proxy whenever you want maybe extensions is more interesting
<?php
use Corley\Queue\Queue;
class MyService
{
public function __construct(Queue $queue) { }
/** ... */
}
class QueueProxy extends Queue {} // valid as Queue object
class QueueProxy // not a Queue object
{
public function __construct(Queue $queue) {}
}
If you consider the Queue
object as a project boundary probably encapsulation is more interesting.
If you have a serializer component, you want to abstract queue options and wrap the queue instance, probably encapsulation is more interesting
class QueueProxy
{
public function __construct(Queue $queue, Serializer $serializer) {}
// the send operation uses the serializer to normalize the incoming message object
// the receive operation uses the serializer to denormalize the outcoming message representation
// the serializer could also be used to normalize options for different queue adapters
}
This project is sponsored by Corley SRL