What does “level of indirection” mean in David Wheeler's aphorism?

后端 未结 2 2049
伪装坚强ぢ
伪装坚强ぢ 2020-12-23 09:55

I\'ve read this quote in a book:

There is no problem in computer science that can\'t be solved using another level of indirection.

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-23 09:56

    One of the potential big advantages of indirection is reduced coupling. It's another way of saying that things should be compartmentalized appropriately. This often helps significantly with testing, maintainability, and flexibility over the long term.

    As an example, if your application needs to read some persisted data, instead of having the specific knowledge of where (and how) to read it scattered all throughout the application, you isolate it (put that reading of data into a method) and then let all of the other parts of your application call that method to get the data instead of each part of the app having to deal with those details itself.

提交回复
热议问题