Should I represent database data with immutable or mutable data structures?

后端 未结 3 2181
清歌不尽
清歌不尽 2021-02-13 23:13

I\'m currently programming in Scala, but I guess this applies to any functional programming language, or rather, any programming language that recommends immutability and can in

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-13 23:52

    In the trading app I'm currently working on, almost everything is immutable - certainly the model is.

    Our experience is that this has greatly simplified how we work with the model, including persistence.

    I don't understand yet why things have become simpler, it just has. I need to ponder on this more. Reasoning about the code and working with it is simpler.

    Yes, you need to use things like lenses but I tend to write them - a mechanical process - and move on. It's a tiny part which I am sure can be finessed.

提交回复
热议问题