編集可能
2013年7月27日

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

https://github.com/gkossakowski/ gkossakowskiさんはtypesafeの中の人です。 Scalaコンパイラ内部は超巨大なCake Patternでできていることで有名です。たとえば最近ではdjspiewakさんが 続きを読む
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.

2013-07-27 02:16:10
Ross MacLeod @dridus

@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
Grzegorz Kossakowski @gkossakowski

@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
Grzegorz Kossakowski @gkossakowski

@dridus @debasishg Cake pattern combined with wildcard imports encourages people to not really control their dependencies.

2013-07-27 03:02:47
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

2013-07-27 03:03:31
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.

2013-07-27 03:03:33
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

2013-07-27 03:04:12
Grzegorz Kossakowski @gkossakowski

@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
Grzegorz Kossakowski @gkossakowski

@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
Debasish (দেবাশিস্) Ghosh 🇮🇳 @debasishg

@gkossakowski @dridus anything as an alternative for managing dependencies across components ?

2013-07-27 03:08:26
Grzegorz Kossakowski @gkossakowski

@debasishg @dridus Good question. My pragmatic side tends to say go with classical, lightweight IoC container like Guice.

2013-07-27 03:10:04
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.

2013-07-27 03:15:16
Grzegorz Kossakowski @gkossakowski

@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
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.

2013-07-27 03:20:52
Ross MacLeod @dridus

@debasishg @gkossakowski functional version would be the Reader monad, though juggling monad stacks can get annoying

2013-07-27 03:23:47
Grzegorz Kossakowski @gkossakowski

@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
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.

2013-07-27 03:28:50
David R. MacIver @DRMacIver

@gkossakowski @natpryce also IIRC scalac has a few weird twists on the classic cake pattern

2013-07-27 03:35:49
残りを読む(23)

コメント

コメントがまだありません。感想を最初に伝えてみませんか?