which GOF Design pattern(s) has entirely different implementation (java vs Scala)

前端 未结 3 1052
终归单人心
终归单人心 2021-01-29 18:59

Recently I read following SO question :

Is there any use cases for employing the Visitor Pattern in Scala? Should I use Pattern Matching in Scala every

3条回答
  •  故里飘歌
    2021-01-29 19:43

    I suppose, Command pattern not needed in functional languages at all. Instead of encapsulation command function inside object and then selecting appropriate object, just use appropriate function itself.

    Flyweight is just cache, and has default implementation in most functional languages (memoize in clojure)

    Even Template method, Strategy and State can be implemented with just passing appropriate function in method.

    So, I recommend to not go deep in Design Patterns when you tries yourself in functional style but reading some books about functional concepts (high-order functions, laziness, currying, and so on)

提交回复
热议问题