Is there a different usage rationale for abstract classes/interfaces in C++ and Java
According to Herb Sutter one should prefer abstract interfaces (all pure virtual functions) to abstract classes in C++ to decouple the implementation as far as possible. While I personally find this rule very useful, I have recently joined a team with many Java programmers and in the Java code this guideline does not seem to exist. Functions and their implementations are very frequently located in abstract classes.
So did I get Herb Sutter all wrong even for C++ or is there a general difference in the usage of abstract functions in C++ compared to Java. Are abstract classes with implementation code more sensible in Java than in C++ and if yes why ?
Help to understand the abstract factory pattern
I’m learning the 23 design patterns of the GoF.
What are the differences between abstract classes, interfaces, and when to use them
Recently I have started to wrap my head around OOP, and I am now to the point where the more I read about the differences between abstract classes and interfaces the more confused I become. So far, neither can be instantiated. Interfaces are more or less structural blueprints that determine the skeleton and abstracts are different by being able to partially implement code.
Liskov substitution and abstract classes / strategy pattern
I’m trying to follow LSP in practical programming. And I wonder if different constructors of subclasses violate it. It would be great to hear an explanation instead of just yes/no. Thanks much!
What are abstract classes and abstract methods?
I got several explanations but so far I’m not able to understand that what are the abstract classes and methods in Java.
Some said it has to do something with the security of the program, other said it isn’t anything like that.
Even from the Dietel & Dietel’s book I don’t get it’s purpose.
When, where and why do we use it?
Should I implement an interface directly or have the superclass do it?
Is there a difference between
Questions about Polymorphism
So I understand the importance of Polymorphism, including how vital it is. But something I don’t quite understand is what about the Constructor
and any inherited Class
the initial Base Class
may have.
In C++ why and how are virtual functions slower?
Can anyone explain in detail, how exactly the virtual table works and what pointers are associated when virtual functions are called.
Is there any difference between interfaces and abstract classes that have abstract methods only?
Let’s say we have an abstract class and let this class has only abstract methods. Is this abstract class different from an interface that has same methods only?
Refactoring an existing abstract class and its parameters
I have an abstract class A
which declares an abstract method doStuff
. Currently there are many classes that inherit from A
and implement doStuff
.