Timeline for Another "Why use Abstract/Interface" question. But I'm a solo developer. Why use it?
Current License: CC BY-SA 3.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 7, 2017 at 17:29 | comment | added | Frank Hileman | To get a true decoupling, you could use one of several methods, including delegates. But decoupling is not an advantage inherently. It makes code harder to debug and read. Strong coupling is preferable, unless you need weaker coupling for some reason. | |
Apr 6, 2017 at 16:02 | comment | added | Stefan Woehrer | that's the point. the caller is only coupled to the interface, not to the implementation. in fact, a caller can use many different implementations without even knowing it. yes, you can achieve the same behaviour with an abstract base class. but as languages like java or C# don't support multiple inheritance, we need to work with interfaces if we want this behaviour. this is why C++ doesn't support interfaces -> cause it supports multiple inheritance. thus, (bastract) base classes are the C++ equivalent to interfaces in java/C# | |
Apr 4, 2017 at 0:05 | comment | added | Frank Hileman | Strongly typed interfaces do not decouple anything. The caller is coupled to the interface, and the implementing class is coupled to the interface, the same way it would be if you used an abstract base class. | |
Apr 3, 2017 at 14:42 | history | answered | Stefan Woehrer | CC BY-SA 3.0 |