Preface
Software engineering and design has existed for many years now. We use software almost everywhere in our lives, and this makes programs distinct in terms of the problems they solve.
Regardless of the number of things that can be done with programming, there are still some specific features that repeat over and over again. Over time, people have come up with some best practices that help to tackle specific patterns that emerge in programs. These are called design patterns.
Design patterns solve not only commonly occurring problems, but also deal with language limitations. No matter what the specific design patterns are and what single issue they solve, all of them in the end aim at producing better software. This includes improved readability, simplicity, easier maintainability, testability, extendibility, and efficiency. Today, design patterns are an important part of every good software engineer's arsenal.
Together with the large number of problems that we tackle with programming, there are also many languages that we can use. Every language is different and has its strengths and weaknesses, so we also need to take this into consideration when doing something. In this book, we will look at design patterns from the point of view of Scala.
Scala has become extremely popular in the last couple of years, and the numbers using it keep growing. Many companies use it in production for various purposes—big data processing, writing APIs, machine learning, and so on. Switching to Scala from popular languages, such as Java, turns out to be quite simple because it is a hybrid of an object-oriented language and a functional programming language. Using Scala to its full potential, however, requires us to be familiar with not only the object-oriented features, but also with the functional ones. The use of Scala could improve performance and the time it takes to implement the features. One of the reasons is the really high expressivity of Scala.
The fact that Scala is close to object-oriented languages means that many of the design patterns for object-oriented programming are still applicable here. The fact that it is also functional means that some other design patterns are also applicable, and some of the object-oriented ones could be modified to better fit the paradigm of Scala. In this book, we will be focusing on all of them—we will go through some specific features of Scala and then look at the popular Gang of Four design patterns viewed from the Scala perspective. We will also become familiar with design patterns that are exclusive to Scala and understand different functional programming concepts, including monoids and monads. Having meaningful examples always makes learning and understanding easier. We will try to provide examples that you can easily map to real problems that you would potentially be solving. We will also introduce some libraries that will be useful for anyone who writes real-world applications.