“Flat is better than nested” - for data as well as code?

前端 未结 6 455
不知归路
不知归路 2021-01-31 16:05

This question got me thinking: should we apply the principle that \"flat is better than nested\" to data as well as to code? Even when there is a \"logical tree structure\" to t

6条回答
  •  轮回少年
    2021-01-31 16:32

    This question can't be answered "in general" - there is no right answer.

    For this particular example, I actually like the tree structure better. Without knowing anything about the original application, and just looking at the structure, the relationship between the items is obvious. With the flat structure, I have to read some documentation, or application code to "know" that your tuple of children refer to id's.

    The tree structure is self-documenting - the flat structure isn't.

提交回复
热议问题