Timeline for Should interface names begin with an "I" prefix?
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 29, 2023 at 14:52 | comment | added | Tigerware | Character waste does not hurt! Often it is actually usefull to have more descriptive names. | |
Nov 17, 2023 at 9:32 | comment | added | sashok_bg | You can have a DefaultLog, and you should almost never be calling it directly. That's the idea of an interface - to sit between the caller and the implementation | |
Jun 28, 2021 at 19:55 | comment | added | Seph Reed |
Personally, I don't use I to denote things because I prefer to be explicit. In this case, I'd likely do interface LogRaw or interface LogArgs and class Log . One denotes args, the other (raw) means "it can be directly saved to disk"
|
|
Jul 30, 2019 at 12:30 | comment | added | Juri | @SebastianRedl you can have abstract Log class i guess. | |
Oct 3, 2018 at 13:27 | comment | added | ruffin |
@RichardTingle But I think the common usage there is simply so that MyClass has a mockable variation, right? That is, we often use interfaces to essentially make public methods really public in a fashion that allows for testing. (Not saying that's good or bad, but understanding that the motivation for interfaces is often simply to make classes that are dependencies easily mockable does explain the 1-to-1 MyClass to IMyClass mappings.)
|
|
Sep 20, 2017 at 7:14 | comment | added | sergut | The name of the class is used once (to instantiate), the name of the interface is used everywhere. Adding a letter to the interface to save letter on the class name is false economics (of characters). | |
Feb 29, 2016 at 14:27 | comment | added | Richard Tingle | Personally this is exactly why I hate seeing ITheClassName, are you just creating an interface for no reason, is it just noise on top of TheClassName. If your interface has a purpose it should be possible to give it a better name than ITheClassName | |
Feb 29, 2016 at 10:05 | comment | added | Sebastian Redl |
"Imagine you have public interface ILog with a default implementation public class Log." - Then you have a poor name for your default implementation. What does Log do? Log to the console? To syslog? To nowhere? Those should be called ConsoleLog , SyslogLog and NullLog , respectively. Log is not a good name for a concrete class, because it is not a concrete name.
|
|
Nov 6, 2014 at 16:11 | comment | added | levininja | This is also mentioned in the .NET documentation | |
Apr 8, 2014 at 9:55 | history | answered | CodeART | CC BY-SA 3.0 |