3 ms·
And I thought I was the only only to go "wtf" when I first read about the magnet pattern. They claimed it to be "elegant", but it really is only "clever" in the
by MrBuddyCasino 9y ago
And I thought I was the only only to go "wtf" when I first read about the magnet pattern. They claimed it to be "elegant", but it really is only "clever" in the worst possible way and makes it hard to reason about the code.
I've got a theory that the type of people doing overly complex Java enterprise (see EJB 2.1) 15 years ago haven't vanished, they're just doing Scala now.
- doikor 9y agoMagnet pattern is purely about making the code you write nicer to look at. (for spray it had more reasons to exist but for akka-http it is purely a usability problem) Basically it allows you to write def f[T](fMagnet: FMagnet[T]): X => Y f(t) { x => // ... } instead of def f[T](t: T)(implicit tc: TC[T]): X => Y f(t).apply { x => // ... } so just about removing one ".apply" (see https://github.com/akka/akka-http/issues/100 https://github.com/akka/akka-http/issues/100 where i copy pasted the code bits from) But yeah first time I read up on the magnet pattern it was a wtf moment.