Scalaのコミッターの人が「Cake Patternはアンチパターンだ」と言って話題に!
After working for a month with #scala cake pattern in #scalac I came to conclusion that cake is an anti-pattern. Don't use it.
2013-07-27 02:16:10@gkossakowski @debasishg perhaps more specifics and elucidation of the problems you experienced would be to the benefit of all?
2013-07-27 02:58:48@dridus @debasishg Cake pattern leads to very complicated path-dependent types that are extremely hard to reason about and debug.
2013-07-27 03:01:45@dridus @debasishg Cake pattern combined with wildcard imports encourages people to not really control their dependencies.
2013-07-27 03:02:47@gkossakowski @debasishg I’m of the mind that wildcard imports are an anti-pattern, though I can see how the cake can make them implicit
2013-07-27 03:03:31@dridus @debasishg In regular DI frameworks there's no equivalent of wildcard import or it's clearly a code smell. In cake it's too easy.
2013-07-27 03:03:33@gkossakowski @debasishg and thanks! I’m not a big proponent of the cake pattern though I have used it in smaller applications, just curious
2013-07-27 03:04:12@dridus @debasishg Cake pattern encourages you to nest classes heavily and that hurts performance due to chains of outer pointers.
2013-07-27 03:05:13@SeanTAllen Yeah, sounds like I should write one because Twitter is not the best medium for sharing in-depth analysis.
2013-07-27 03:06:14@gkossakowski @dridus anything as an alternative for managing dependencies across components ?
2013-07-27 03:08:26@debasishg @dridus Good question. My pragmatic side tends to say go with classical, lightweight IoC container like Guice.
2013-07-27 03:10:04@gkossakowski @natpryce I do agree, but it's also worth noting that scalac is an especially egregious (ab)use of the pattern.
2013-07-27 03:15:16@DRMacIver @natpryce I think the real test for any software engineering practice is how resilient is it against programmer's mistakes.
2013-07-27 03:20:03@gkossakowski @dridus Was a very satisfied user of Guice when I did Java ..
2013-07-27 03:20:19@DRMacIver @natpryce Or in other words, I don't see how the cake pattern nudges you in the right direction. You need a lot of discipline.
2013-07-27 03:20:52@debasishg @gkossakowski functional version would be the Reader monad, though juggling monad stacks can get annoying
2013-07-27 03:23:47@dridus @debasishg Yes. Actually, I tend to agree with @odersky that OOP is great for modularization and FP for algorithms.
2013-07-27 03:27:06@gkossakowski yeah. I hated the cake pattern. Rather than creating modularity it conceals the lack of it. It's just usually a bit less bad.
2013-07-27 03:28:50@gkossakowski @natpryce also IIRC scalac has a few weird twists on the classic cake pattern
2013-07-27 03:35:49