Is using empty interfaces a bad design?

I am considering creating an interface and applying it to all objects in a specific namespace.

The scenario in which I will use this: I want to create a common handler for these objects, and I would like to provide a general parameter to accept only types that implement this particular interface.

Is this a bad design or are empty interfaces acceptable?

+5
source share
6 answers

What you are saying is called Marker Interfaces .

, , , , . , , , .

+2

, . () .

+1

, . , , . , , . , .

+1

, . . , , .

+1

, ? ? ? , ?

, , . , - , .

0

There is nothing ... I don’t know, using the empty interface, I think. Similarly, an interface point is to define a common set of functions that may differ in how it is implemented.

This will not make coding simpler, since you are effectively working with a black box ( objectas some may call it).

Honestly, if I implemented such an open-end architecture, I would just go with the usual old one object.

0
source

All Articles