Design patterns for functional-OO hybrid languages?

前端 未结 5 822
逝去的感伤
逝去的感伤 2021-01-29 19:33

Is there already any collection of best practices for languages like Scala?

I\'ve found a work on design patterns for functional languages, Design patterns for funct

5条回答
  •  广开言路
    2021-01-29 19:57

    Two patterns from Bill Venners; I think both are heavily used in ScalaTest:

    Stackable Trait (similar in structure to the decorator pattern, except it involves decoration for the purpose of class composition instead of object composition).

    Selfless Trait (allows library designers to provide services that their clients can access either through mixins or imports).

    Type safe builder

    Independently Extensible Solutions to the Expression Problem - just like the "Scalable Component Abstraction", it's not a pattern catalog, but it also deals with similar problems (e.g. the Visitor pattern)

    Deprecating the Observer Pattern - an alternative to the Observer.

    We can also consider the Scala emulation of Haskell type classes a design pattern. The first description (that I could find at least) is in Poor Man's Type Classes. Quite some blog entries are also available with this topic.

    And I think I'm not completely wrong if I also mention the various monads. You can find a lot of resources dealing with them.

提交回复
热议问题