3 ms·
That factory code you mentioned isn't _just_ a Java thing, but a very well-known and wonderful design pattern. Wikipedia says it best: "[The] Factory pattern d
by exception_e 10y ago
That factory code you mentioned isn't _just_ a Java thing, but a very well-known and wonderful design pattern.
Wikipedia says it best: "[The] Factory pattern deals with the instantiation of object without exposing the instantiation logic."
Practical benefits:
- Can help rid of excessive switch and if/elseif statements and splits up your logic
- Eliminates new keyword to improve testability
- anonymousab 10y agoAs with most language jokes/prejudices, I think the hate comes from seeing the misguided, incorrect or unnecessary uses of that pattern. Java's prominence in the corporate world means sturgeon's law is more apparent.
- exception_e 10y agoNever heard of that law. Brilliant.