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

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
主站蜘蛛池模板: 平潭县| 古蔺县| 泾源县| 淮滨县| 镇康县| 永仁县| 晴隆县| 吉木乃县| 迁西县| 隆尧县| 文化| 平武县| 乌拉特中旗| 离岛区| 清新县| 阿巴嘎旗| 沙湾县| 商水县| 庆城县| 嵊泗县| 会理县| 玉门市| 赞皇县| 乾安县| 富民县| 黄大仙区| 元朗区| 宝鸡市| 精河县| 临漳县| 保康县| 辉县市| 保山市| 彝良县| 平武县| 上思县| 凤凰县| 宾川县| 钦州市| 衢州市| 呼伦贝尔市|