So...I've started a new job where we have to follow what the "Architect" says without questioning.
And I see we have hundreds of empty interfaces in our (large) project.
For example:
public interface ISupportsDirectOpen<TDirectOpenQuery> where TDirectOpenQuery : IDirectOpenQuery
{
}
or
public interface ISupportsUpdate<TCommandType> where TCommandType : ICommand
{
}
and so on.
Then, most of our (Web Forms) pages inherit those interfaces in some way or other:
public partial class Detail : GAEntityDetailsViewBase<ClassificationAttribute>,
IViewDetailClassificationAttribute,
ISupportsUpdate<ICommandUpdateClassificationAttribute>,
ISupportsCreate<ICommandCreateClassificationAttribute>
{
...
Now why do we have those empty interfaces?
Because somewhere in the base base base class for pages, there is contrived code checking for interface implementation in this pattern:
if (GetISupportsContract(typeof(ISupportsDirectOpen<>)) != null)
{
var openByIdControl = new DirectOpen();
openByIdControl.Open += DirectOpen_Open;
_layout.PageTitlePane.Add(openByIdControl);
}
and such...
var supportsOptimisticConcurrency = data as ISupportsOptimisticConcurrency;
if (supportsOptimisticConcurrency != null)
{
ConcurrencyToken = supportsOptimisticConcurrency.OptimisticConcurrency.ConcurrencyToken;
}
and such.
I find this totally crazy and I believe it is not at all how interfaces should be used. Am I missing something? Is this a good usage of interface? What would be the more correct way to use this pattern? Class attributes?
Aucun commentaire:
Enregistrer un commentaire