4 ms·
100% agree. You can create a HammerFactoryFactory to churn out HammerFactories in any language. But the ecosystem in Java (and C# is similar imo) promotes and e
by _gabe_ 3y ago
100% agree. You can create a HammerFactoryFactory to churn out HammerFactories in any language. But the ecosystem in Java (and C# is similar imo) promotes and encourages this type of problem solving.
The one thing Java really does need is free standing (or namespaced) functions though. Sometimes I don’t want a class, what’s wrong with a function in a module or namespace in that case?
- MagicMoonlight 3y agoA class is a module/namespace. You can make a class just to have functions in it.
- _gabe_ 3y agoIt’s not though. In lots of languages a namespace can span multiple files, whereas a class must be declared in a single file[0][1]. Modules can usually contain a collection of functions and classes. And namespaces can also contain multiple classes/structure/functions and sometimes modules depending on the language[2]. [0]: https://www.typescriptlang.org/docs/handbook/namespaces-and-modules.html https://www.typescriptlang.org/docs/handbook/namespaces-and-... [1]: https://learn.microsoft.com/en-us/cpp/cpp/namespaces-cpp?view=msvc-170 https://learn.microsoft.com/en-us/cpp/cpp/namespaces-cpp?vie... [2]: https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/namespaces https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...