I am using the decorator pattern and am decorating a class with a constructor that has parameters.
Below is the constructor of the class decorating;
Public Sub New(ByVal repository As ISchedulingRespository)
Me.repository = repository
End Sub
Because my decorator class inherits from the decorated class I need to declare it's constructor as follows;
Public Sub New(ByVal schedulingService as SchedulingService, ByVal repository As ISchedulingRespository)
MyBase.New(repository)
Me.instance = instance
End Sub
So when I create the decorator class I pass in an instance of the class decoratoring as well as the parameter required for the class going to decorate. This can be seen below;
Dim schedulingServiceDecorator As New SchedulingServiceEventDecorator(schedulingService, schedulingRepository)
This does not seem correct to me. Am I missing something with this pattern?
I could simply not pass in the decorating class in the decorator constructor, but every article seen on this pattern passes an instance of the class being decorated, into the decorator.
Is this a case of modifying a pattern to meet your needs?
Many Thanks