Immutable views of mutable types

前端 未结 5 1518
隐瞒了意图╮
隐瞒了意图╮ 2021-01-05 10:14

I have a project where I need to construct a fair amount of configuration data before I can execute a process. During the configuration stage, it\'s very convenient to have

5条回答
  •  逝去的感伤
    2021-01-05 10:42

    I'm regularly working with a large, COM-based framework (ESRI's ArcGIS Engine) that handles modifications very similarly in some situations: there are the "default" IFoo interfaces for read-only access, and IFooEdit interfaces (where applicable) for modifications.

    That framework is fairly well-known, and I'm not aware of any widespread complaints about this particular design decision behind it.

    Finally, I think it's definitely worth some additional thought in deciding which "perspective" gets to be the default one: the read-only perspective or the full-access one. I would personally make the read-only view the default.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题