Someone in a Stackoverflow post (I didn't bookmark the question unfortunately) commented, that Factories that only return one type of object are a code smell.
I find myself writing these kinds of factories pretty often. Sometimes because i don't want to bloat my code with constructor overloads and sometimes because i just want to give a name to an object with specific attributes. A factory would then look like this:
class CarFactory {
public static Car createDefault() { return new Car(0, 0, 0, 0, 0, Color.BLACK) }
public static Car createFancy() { return new Car(1, 1, 1, 1, 1, Color.RAINBOW) }
...
}
This is just a general example, but i think the calls look much better in the code than the constructor calls with a load of ominous values.
However these kinds of factories usually don't do runtime decision making (like factory methods often do). And i probably won't create interfaces either (Like the Abstract Factory Pattern uses). It's just a class that provides static creation methods, so that my code doesn't get cluttered and i have only one method to change if i think, that a fancy car should be red with stripes.
Are these kinds of Factory Classes necessarily bad?