Linked Questions
26 questions linked to/from Factory Pattern. When to use factory methods?
14 votes
4 answers
11k views
Why should one use factory method to create objects [duplicate]
Possible Duplicates: Factory Pattern. When to use factory methods? Why do static Create methods exist? Though I know what is Factory Design Pattern. But I am unable to comprehend what are the ...
-2 votes
2 answers
2k views
What is factory method in java? [duplicate]
I am a student and I had this question asked in my viva voce today and I hadn't even heard about it before. I have searched over the internet about it and I always found the results to be very ...
2 votes
2 answers
387 views
Any advantages using a factory to get a particular object? [duplicate]
Lighten a specific aspect of: Factory Pattern. When to use factory methods? At my team there was a discussion about the factory design pattern. In our project we have some Factories that are ...
0 votes
2 answers
449 views
Factory Pattern and dependencies [duplicate]
The factory method is used to avoid violation of Open-closed principle. Instead of creating an object by inheritage: Product myProd = new ConcreteProduct1; // concreteProduct extends abstract product ...
-1 votes
1 answer
384 views
Value of Factory Classes [duplicate]
I can appreciate the value of factory methods, but I'm struggling with the value of using dedicated factory classes. This will work: class Brady { int age; String name; static Brady ...
2034 votes
39 answers
1.4m views
What is the difference between an interface and abstract class?
What exactly is the difference between an interface and an abstract class?
549 votes
31 answers
493k views
How should I have explained the difference between an Interface and an Abstract class? [closed]
In one of my interviews, I have been asked to explain the difference between an Interface and an Abstract class. Here's my response: Methods of a Java interface are implicitly abstract and ...
644 votes
16 answers
174k views
When to use: Java 8+ interface default method, vs. abstract method
Java 8 allows for default implementation of methods in interfaces called Default Methods. I am confused between when would I use that sort of interface default method, instead of an abstract class (...
39 votes
8 answers
31k views
"Program to an interface". What does it mean? [duplicate]
I keep coming across this term: Program to an interface. What exactly does it mean? A real life design scenario would be highly appreciated.
18 votes
3 answers
11k views
When to use the abstract factory pattern?
I'm trying to succinctly describe when to use a factory, for both myself and my team. I ran across the following related questions, which helped somewhat: When to use factory patterns? (useful pdf ...
5 votes
5 answers
13k views
Factory Method Pattern Example in Java troubles
I'm trying to create a really simple Factory Method design pattern example in Java. I don't really know Java, I am new to programming in general but I need to come up with a a basic FactoryMethod ...
16 votes
2 answers
3k views
Performing unit testing with nested dependencies and Factory classes
I'm new to unit testing and PHPUnit, but I've reading a lot lately about design patterns and isolated tests and I've decided to refactor an application I'm working on to get rid of static classes, ...
4 votes
4 answers
2k views
C# How to make a factory method return of the subclass type
[MAJOR EDITS, my first post was somewhat misleading. My appologies] Given a class such as: public class DatabaseResult{ public bool Successful; public string ErrorMessage; //...
4 votes
3 answers
315 views
Object Allocation through new operator or some interface
I was going through a Java code and I saw that objects have been allocated using some interface and this interface contains some methods to allocate objects using new operator. I am unable to think ...
3 votes
6 answers
3k views
Returning an interface object from a method without instantiating an (unknown) concrete type
I'm sure there's some solution or pattern to this but i'm having trouble articulating the question to find the right answer. I have an interface, ICar: public interface ICar { void SetMake(String ...