官术网_书友最值得收藏!

  • Scala Design Patterns
  • Ivan Nikolov
  • 217字
  • 2021-07-16 12:57:25

How to choose a design pattern

As we already saw, there is a huge number of design patterns. In many cases, they are suitable to be used in combinations as well. Unfortunately, there is no definite answer about how to choose the concept of designing our code. There are many factors that could affect the final decision, and you should ask yourselves the following questions:

  • Is this piece of code going to be fairly static or will it change in the future?
  • Do we have to dynamically decide what algorithms to use?
  • Is our code going to be used by others?
  • Do we have an agreed interface?
  • What libraries are we planning to use, if any?
  • Are there any special performance requirements or limitations?

This is by no means an exhaustive list of questions. There are a lot of amount of factors that could dictate our decision in how we build our systems. It is, however, really important to have a clear specification, and if something seems missing, it should always be checked first.

In the rest of the chapters, we will try to give specific recommendations about when a design pattern should and should not be used. They should help you ask the right questions and take the right decision before going on and writing code.

主站蜘蛛池模板: 景泰县| 乐安县| 青田县| 阿拉善右旗| 定陶县| 唐山市| 东港市| 永川市| 郯城县| 崇阳县| 马关县| 五莲县| 大姚县| 蒙阴县| 玛纳斯县| 久治县| 金塔县| 井研县| 渭南市| 苍溪县| 全南县| 云阳县| 宜都市| 邻水| 治县。| 韶山市| 井研县| 噶尔县| 南雄市| 宁陵县| 赤壁市| 娄烦县| 侯马市| 乃东县| 奉贤区| 龙江县| 砚山县| 通许县| 乐安县| 谢通门县| 双牌县|