2 ms·
Yes, in the case where a Factory class contains one method that takes no parameters and just contains a "new" call, you can get rid of the class and pass in the
by AndrewDucker 15y ago
Yes, in the case where a Factory class contains one method that takes no parameters and just contains a "new" call, you can get rid of the class and pass in the method.
I was more thinking of the kind of thing I mentioned in my earlier comment, where you have an IWriter interface, a bunch of different classes that implement it, and a Factory class that passes back the correct one for different situations. I completely agree that a whole class that does nothing but call "new" is complete overkill, and almost certainly just there to fit into a pattern because someone thinks that Patterns Are Awesome.
The kind of thing I'm thinking of is this:
https://github.com/andrewducker/FeedThisToThat/blob/master/FeedThisToThat/src/feedthistothat/Writers/WriterFactory.java https://github.com/andrewducker/FeedThisToThat/blob/master/F...