みんなのオブザイヤーオブザイヤーを募集中!今年のツイート今年のうちにまとめよう!

Scalaのコミッターの人が「Cake Patternはアンチパターンだ」と言って話題に!

https://github.com/gkossakowski/ gkossakowskiさんはtypesafeの中の人です。 Scalaコンパイラ内部は超巨大なCake Patternでできていることで有名です。たとえば最近ではdjspiewakさんが 続きを読む
プログラミング SCALA
7954view 0コメント
13
Grzegorz Kossakowski @gkossakowski
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.
Ross MacLeod @dridus
@gkossakowski @debasishg perhaps more specifics and elucidation of the problems you experienced would be to the benefit of all?
Grzegorz Kossakowski @gkossakowski
@dridus @debasishg Cake pattern leads to very complicated path-dependent types that are extremely hard to reason about and debug.
Grzegorz Kossakowski @gkossakowski
@dridus @debasishg Cake pattern combined with wildcard imports encourages people to not really control their dependencies.
Ross MacLeod @dridus
@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
Grzegorz Kossakowski @gkossakowski
@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.
Ross MacLeod @dridus
@gkossakowski @debasishg and thanks! I’m not a big proponent of the cake pattern though I have used it in smaller applications, just curious
Grzegorz Kossakowski @gkossakowski
@dridus @debasishg Cake pattern encourages you to nest classes heavily and that hurts performance due to chains of outer pointers.
Grzegorz Kossakowski @gkossakowski
@SeanTAllen Yeah, sounds like I should write one because Twitter is not the best medium for sharing in-depth analysis.
Debasish (দেবাশিস্) Ghosh 🇮🇳 @debasishg
@gkossakowski @dridus anything as an alternative for managing dependencies across components ?
Grzegorz Kossakowski @gkossakowski
@debasishg @dridus Good question. My pragmatic side tends to say go with classical, lightweight IoC container like Guice.
David R. MacIver @DRMacIver
@gkossakowski @natpryce I do agree, but it's also worth noting that scalac is an especially egregious (ab)use of the pattern.
Grzegorz Kossakowski @gkossakowski
@DRMacIver @natpryce I think the real test for any software engineering practice is how resilient is it against programmer's mistakes.
Grzegorz Kossakowski @gkossakowski
@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.
Ross MacLeod @dridus
@debasishg @gkossakowski functional version would be the Reader monad, though juggling monad stacks can get annoying
Grzegorz Kossakowski @gkossakowski
@dridus @debasishg Yes. Actually, I tend to agree with @odersky that OOP is great for modularization and FP for algorithms.
David R. MacIver @DRMacIver
@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.
David R. MacIver @DRMacIver
@gkossakowski @natpryce also IIRC scalac has a few weird twists on the classic cake pattern
残りを読む(23)

コメント

ログインして広告を非表示にする
ログインして広告を非表示にする