定义一个接口,它是空白及其影响 [英] Defining an interface which is blank and its implications
问题描述
我最近碰到的地方,我想一组类被传递给方法的情况来(这样的方法把一个接口作为参数)。
I recently came across the situation where I wanted a set of classes to be passed into a method (so that method took an interface as a parameter).
然而,界面下的类的每个有一个不同的数目的方法,因此,接口本身是空白的。
However, the classes under the interface each had a different number of methods, so the interface itself was blank.
有什么东西,这是否说我的应用程序的设计?我本来打算在这种情况下使用抽象类,但我一直有这样的接口可能的东西阻止我使用抽象类(不记得是什么)。
What, if anything, does this say about the design of my application? I was going to use an abstract class in this case, but I kept with interfaces so something probably stopped me from using abstract classes (can't remember what).
语言:C#(虽然这是独立于语言的)
Language: C# (though this is independent of the language).
推荐答案
你所描述什么是标记接口。
What you've described is a 'Marker Interface'.
http://en.wikipedia.org/wiki/Marker_interface_pattern
对于任何设计模式,没有什么本质上的,只要它好还是坏,因为它是为手头的任务,正确的模式。
As with any design pattern, there's nothing inherently good or bad about it as long as it is the right pattern for the task at hand.
这篇关于定义一个接口,它是空白及其影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!