What's the difference between data and code?

前端 未结 13 744
青春惊慌失措
青春惊慌失措 2020-12-13 10:52

To take an example, consider a set of discounts available to a supermarket shopper.

We could define these rules as data in some standard fashion (lists of qualifyin

13条回答
  •  执念已碎
    2020-12-13 11:09

    It all depends on the requirement. If the data is like lookup data and changes frequently you dont really want to do it in code, but things like Day of the Week, should not chnage for the next 200 years or so, so code that.

    You might consider changing your topic, as the first thing I thought of when I saw it, was the age old LISP discussion of code vs data. Lucky in Scheme code and data looks the same, but thats about it, you can never accidentally mix code with data as is very possible in LISP with unhygienic macros.

提交回复
热议问题