Timeline for Should interface names begin with an "I" prefix?
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 17, 2021 at 23:52 | comment | added | Deduplicator | @jsj C++ has full MI, so the distinction is even more academic. | |
| Feb 29, 2016 at 11:59 | comment | added | Tulains Córdova | Interface members cannot have access modifiers (all members are "public"); I've designed many interfaces with methods like public String getX(); and `public void setX(String x);" | |
| Jan 22, 2015 at 22:54 | comment | added | jsj | I have one concern. In C++ if you open a header and see that class Foo already extends class Bar, it is not immediately obvious if class Bar is being extended or implemented. So now you have to go and look in the class Bar header to decide whether it's okay to modify class Foo to extend class Baz. Furthermore, the I prefix gives an obvious visual clue if the "single base class" is being violated or not - so you get a sanity check every time you open up a header. | |
| Jan 13, 2014 at 18:16 | comment | added | supercat | Another difference in .NET (but not in Java) is that many .NET languages do not allow interfaces to contain static methods, so hacking the I off an interface can give a good name for a class to hold static methods associated with the interface (e.g. Enumerable<T>.Empty or Comparer<T>.Default). | |
| Sep 3, 2012 at 11:47 | comment | added | Aidos | As someone who writes both Java and C# the statement "All of this being said, I tend to prefix my C# interfaces with I anyway because that is the .NET convention used and advocated by Microsoft" cannot be understated - it's one of the things that helps me remember which language I'm working in, | |
| Nov 4, 2011 at 17:00 | comment | added | Robotsushi | +1 for "All of this being said, I tend to prefix my C# interfaces with I anyway because that is the .NET convention used and advocated by Microsoft". This is reason enough for me in C#. By following this common standard it is more likely that other .NET programmers with identify the interface. | |
| Nov 2, 2011 at 16:10 | vote | accept | Charles Sprayberry | ||
| Nov 2, 2011 at 16:10 | vote | accept | Charles Sprayberry | ||
| Nov 2, 2011 at 16:10 | |||||
| Nov 2, 2011 at 1:20 | history | answered | Aaronaught | CC BY-SA 3.0 |