I know that design patterns are set by the design and not by specific code yet sometimes I get concerned that I bent the pattern too much and no longer follow the design.
For Example Specification Pattern looks like this:
public interface ISpecification<T>
{
bool IsSatisfiedBy(T candidate);
}
But to me this isn't very readable:
_customerAccountIsActive
.And(_hasReachedRentalThreshold)
.And(_customerAccountHasLateFees)
.IsSatisfiedBy(this);
So I changed it to pass the candidate inside the constructor:
public abstract class Specification<TEntity> : ISpecification<TEntity>
{
protected TEntity _candidate;
public Specification(TEntity candidate)
{
_candidate = candidate;
}
public bool IsSatisfied()
{
return IsSatisfiedBy(_candidate);
}
}
And I even Overloaded The bool operator so I can write something like this:
_customerAccountIsActive
&& _customerAccountHasLateFees
&& _hasReachedRentalThreshold
Now I'd like to know from someone more experienced with design patterns whether I'm twisting this too much and what are the risks I should be aware of.