4 ms·
> I think Java culture had something to do with the ridiculously verbose names People complain about this all the time but I'd rather take a verbose name than
by re-thc 2y ago
> I think Java culture had something to do with the ridiculously verbose names
People complain about this all the time but I'd rather take a verbose name than not knowing what is going on. Sometimes these naming conventions help.
Digging into older poorly named, structured and documented codebases is not fun.
- noduerme 2y agoDefinitely. If you have functions that only do one thing and are only called a few other place in the code, then by all means, name them explicitly. And I'd rather see that than a bunch of the same inlined anonymous function. I'm not really knocking the naming patterns as much as the data/logic patterns that required them. Factories are not a good thing. They usually imply that globals need to hold references. Obviously, so do Singletons. Global lifecycles in general are just easy to create and really hard to manage on your own. Good comments are better than good function names.
- motorest 2y ago> Factories are not a good thing. They usually imply that globals need to hold references. No. Your statements are fundamentally wrong at many levels. Factories are tools to instantiate objects of a specific type a certain way. They are constructors that don't suffer from the limitations of constructors. A factory does not impose any requirement on object life cycle.
- lurking_swe 2y agocorrect. i chuckle when someone talks so authoritatively on a topic they didn’t try to fully understand in the first place.
- noduerme 2y agoHow you use a factory matters. A factory that sits as a static function inside the same class it's creating is one thing. It may just be a nicer interface to instantiate the class than the constructor itself. On the other hand, it may do something with the object it's instantiating before passing it back. Such as putting it into global scope, or tying it to something outside its chain. Factories that sit outside the class file are often prone to all kinds of grotesque later mucking-with that causes the instantiated object to bind to other scope, and never be properly garbage collected. That's what I'm talking about. Build better constructors and you won't usually need factories. If you need factories as an API, build them next to the constructor.