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

Chapter 2. Traits and Mixin Compositions

Before digging into some actual design patterns, we have to make sure that many of the Scala language concepts are clear to the reader. Many of those concepts will later be used in implementing the actual design patterns, and being aware of the possibilities, limitations, and pitfalls are the key factors that enable to correctly and efficiently write code. Even though those concepts are not considered as "official" design patterns, they could still be used to write good software. Even in some cases, due to the richness of Scala, some concepts could replace a design pattern by just using language features. After all, as we have already said before, design patterns are there because a programming language lacks features and is not rich enough to complete certain tasks.

The first topic that we will look into is about traits and mixin compositions. They provide the developer with a possibility to share already implemented functionality or to define interfaces for classes in an application. Many of the possibilities, which are provided by traits and mixin compositions to developers, are useful to implement some of the design patterns that we will focus on later in this book. We will go through the following main topics in this chapter:

  • Traits
  • Mixin compositions
  • Multiple inheritance
  • Linearization
  • Testing traits
  • Traits versus classes
主站蜘蛛池模板: 融水| 沁阳市| 肥西县| 都江堰市| 当阳市| 增城市| 山丹县| 大关县| 奇台县| 托克逊县| 托克托县| 保山市| 虞城县| 黄骅市| 那曲县| 五指山市| 阿尔山市| 正镶白旗| 贵德县| 乌海市| 常山县| 砚山县| 凯里市| 容城县| 那坡县| 靖安县| 于田县| 承德市| 林州市| 科技| 陇川县| 承德县| 赤壁市| 岫岩| 汨罗市| 界首市| 五台县| 金坛市| 原平市| 朝阳县| 台北县|