Nectar
Program to an Interface means in Head First Design Patterns book
thanks for answering. I think it's another meaning of program to interface, but it doesn't answer why the illustration questions the author's decision that clearly the author implements program to interface.
6 replies
✅ Confused when try to implement Factory Method
Sorry, I have another question. My first question: after the changes you suggested, can my code still be called a factory method? because it changes the structure of the UML diagram.
Second: what does initialization mean when you say my code implements abstract factory?
After you mentioned abstract factory I tried to understand and compare the two, but it raised a third question.
Third: can you give an example and explain when to use one over the other in an easy to understand sentence?
Thank you very much and sorry for responding so late, I thought no one would respond.
14 replies
ELI5 : Abstract Class vs Interface
what if there is a scenario where some derived classes will have some methods with the same implementation, but these methods are from some different abstract classes, but due to the single inheritance rule the derived classes cannot inherit from both the abstract classes. what solutions are available?
11 replies
ELI5 : Abstract Class vs Interface
i think i can make them in one interface like this :
interface IBase
{
int Id { get; set; }
DateTime CreatedDate { get; set; }
string CreatedBy { get; set; }
}
cmiiw, but that probably break the DRY principle, cuz they will have the same implementation on every models that inherited from it
11 replies