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

前端 未结 6 390
不知归路
不知归路 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:22

    should we apply the principle that "flat is better than nested" to data as well as to code?

    No.

    Even when there is a "logical tree structure" to the data?

    That's what "flat is better than nested" doesn't apply to data. Only to code.

    ... the tree structure is obscured. Does that contradict "explicit is better than implicit"?

    It's not even comparable. The "flat tree" is a common SQL implementation because SQL can't handle indefinite recursion of a proper tree.

    Comparing the Zen of Python (the language) with data structure design is nonsensical. The two are no more comparable than than the number "2" and splitting a brick of cheese into "2" pieces. One's a thing, the other's an action.

    Data structures are things.

    Python describes actions.

提交回复
热议问题