Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy should you ever have to care whether an object reference is an interface or a class?
    primarykey
    data
    text
    <p>I often seem to run into the <a href="https://stackoverflow.com/questions/681700/interface-naming-convention">discussion</a> of whether or not to apply some sort of prefix/suffix convention to interface type names, typically adding "I" to the beginning of the name.</p> <p>Personally I'm in the camp that advocates no prefix, but that's not what this question is about. Rather, it's about one of the arguments I often hear in that discussion:</p> <blockquote> <p>You can no longer see at-a-glance whether something is an interface or a class.</p> </blockquote> <p>The question that immediately pops up in my head is: apart from object creation, why should you ever have to care whether an object reference is a class or an interface?</p> <p>I've tagged this question as language agnostic, but as has been pointed out it may not be. I contend that it is because while specific language implementation details may be interesting, I'd like to keep this on a conceptual level. In other words, I <em>think</em> that, conceptually, you'd never have to care whether an object reference is typed as a class or an interface but I'm not <em>sure</em>, hence the question.</p> <p>This is not a discussion about IDEs and what they do or don't do when visualizing the different types; caring about the type of an object is certainly a necessity when browsing through code (packages/sources/whatever form). Nor is it a discussion about the pros or cons about either naming convention. I just can't seem to figure out in what scenario, other than object creation, you actually care about wether or not you're referencing a concrete type or an interface.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload