Let's look at our six magic questions.
- Is code included directly in my question? (See Make sure you include your code in your question below.) 2. Am I an owner or maintainer of the code? 3. Is it actual code from a project rather than pseudo-code or example code? 4. Do I want the code to be good code? (i.e. not code-golfing, obfuscation, or similar) 5. To the best of my knowledge, does the code work? 6. Do I want feedback about any or all facets of the code?
For the sake of argument, we can assume that the code is embedded in the question, OP maintains the code, wants it to be good code, and wants feedback on all facets of the code.
That leaves us with just two things to ponder on.
- Is it actual code from a project rather than pseudo-code or example code?
- To the best of my knowledge, does the code work?
The prior is often referred to as "real code", so is an Interface real code? Well, it's certainly not pseudo-code. Let's also assume, again for the sake of argument, that the code in question does not contain classes or methods named Foo, Bar, and the like. Therefore, not being example code. That leaves just one last test to pass.
Does this code work?
To determine if code works or not, first we have to understand what it means "to work". I could not find a meta post clearly defining what working code is, so I'll refer to Meriam-Webster. Irrelevant definitions omitted.
Work intransitive verb 1 b : to perform or carry through a task requiring sustained effort or continuous repeated operations 2 : to function or operate according to plan or design 4 : to produce a desired effect or result : succeed
Definition 1b is the only place an Interface fails to meet the definition of "working code". It does indeed meet the definition of "to function or operate according to plan" and to "produce a desired effect". Which, I would argue, is our intent by asserting that code must "work" to be posted as a question here. What we really mean is that the code must be functional. It must compile and produce the intended results. An Interface creates a contract that implementing classes must abide by. They do not execute code, but that does not make them broken. That's what we really care about here. Is the code broken? No, interfaces are (obviously) not broken code by mere virtue of their nature. By that measure and logic, Interface only questions are indeed on topic.
Furthermore, Interface questions have been well received in the past. Some examples: