4 ms·
> for not embracing religion of OOP and FactoryFactory Not the case today. Of course, crappy code (or questionable patterns) can be found in all languages, and
by lucketone 7mo ago
> for not embracing religion of OOP and FactoryFactory
Not the case today. Of course, crappy code (or questionable patterns) can be found in all languages, and java community had made some innovations in the area early on, but today we have a different picture.
FactoryFactory has gone mostly extinct, the most likely place to see it is “dailywtf.com”.
We now know that we prefer composition over inheritance, we have stream api - language and community evolved, old patterns are not neccessary anymore to solve same/similar problems.
Sample of one - junit (testing lib) source code, from quick glance it seems more procedural than dogmatic OOP: https://github.com/junit-team/junit-framework/blob/main/junit-jupiter-api/src/main/java/org/junit/jupiter/api/AssertArrayEquals.java#L434 https://github.com/junit-team/junit-framework/blob/main/juni...
- dmix 7mo agoIt's still going to be hard to overcome the stigma of ex-Java developers coming into other languages and bringing their overly complex ideas with them. But I am happy to hear Java itself is evolving and I hope that limits the downstream effects of it being one of the most popular language a lot of devs start on.
- owlstuffing 7mo ago> We now know that we prefer composition over inheritance When people say "composition over inheritance" in Java discussions, they usually mean the trivial modeling rule: prefer has-a over is-a. But that’s not what composition is really about. The deeper idea is interface composition -- building types by composing multiple behavioral contracts behind a single cohesive surface. Java provides inheritance and interfaces, but it doesn’t provide first-class delegation or traits. So most developers never really practice interface composition. They either subclass, or they wire objects together and expose the wiring. The slogan survived. The concept mostly didn’t. The manifold project, for example, experiments with language-level delegation to make interface composition practical with Java. https://github.com/manifold-systems/manifold/blob/master/manifold-deps-parent/manifold-delegation/README.md https://github.com/manifold-systems/manifold/blob/master/man...
- gf000 7mo agoWell, what mainstream language has better tools for composition?
- fingerlocks 7mo agoRust with traits and Swift with protocols
- gf000 7mo agoSo just type classes? How does a type class help with composition? They do help with the expression problem (adding support for an "interface" after definition), and via parametric polymorphism they might give you a bit with regards to composing two traits.. but you do also have generics in Java, even if not as good as type classes. So anyways, I don't see as big of a change here. But there was a Brian Goetz mail/presentation somewhere where he talked about adding "basically type classes" to Java? But unfortunately I couldn't find it for you now.
- joe_mwangi 6mo agoHere it is https://youtu.be/Gz7Or9C0TpM?si=Rk5pTeAC6ibqS-M- https://youtu.be/Gz7Or9C0TpM?si=Rk5pTeAC6ibqS-M-
- megapoliss 7mo agokotlin
- owlstuffing 7mo agoKotlin's "delegation" feature isn't true delegation, it's just call forwarding, which is better than nothing, but it falls down pretty quickly as an alternative to implementation inheritance. The manifold project provides true delegation[1] for Java. 1. https://github.com/manifold-systems/manifold/blob/master/manifold-deps-parent/manifold-delegation/README.md https://github.com/manifold-systems/manifold/blob/master/man...
- chii 7mo ago> FactoryFactory has gone mostly extinct it really depends on your project, and what framework(s) and libraries you choose to use. Java still has a tonne of legacy projects using old(er) frameworks that rely on such patterns - spring has some old versions which is like that, and i am certain plenty of java projects are retaining those old versions due to lack of desire to upgrade. If you're starting a greenfield development in java, you surely would not befall into that factoryfactory pattern (unless you're just copy/pasting old projects around...). But i imagine there's way fewer greenfield projects compared to older projects requiring maintenance.
- deleted 7mo ago[deleted]