What does 'low in coupling and high in cohesion' mean

前端 未结 14 548
粉色の甜心
粉色の甜心 2020-11-30 16:18

I have problems understanding the statement low in coupling and high in cohesion. I have googled and read a lot about this, but still finding it hard to underst

14条回答
  •  攒了一身酷
    2020-11-30 16:55

    An example might be helpful. Imagine a system which generates data and puts it into a data store, either a file on disk or a database.

    High Cohesion can be achieved by separate the data store code from the data production code. (and in fact separating the disk storage from the database storage).

    Low Coupling can be achieved by making sure that the data production doesn't have any unnecessary knowledge of the data store (e.g. doesn't ask the data store about filenames or db connections).

提交回复
热议问题