Before delving into the Scala design patterns, we have to explain what they actually are, why they exist, and why it is worth being familiar with them.
Software is a broad subject, and there are innumerable examples of things people can do with it. At first glance, most of these things are completely different—games, websites, mobile phone applications, and specialized systems for different industries. There are, however, many similarities in how software is built. Many times, people have to deal with similar issues, no matter the type of software they create. For example, computer games, as well as websites, might need to access a database. And throughout time, by experience, developers learn how structuring their code differs for the various tasks that they perform.
A design pattern is a reusable solution to a recurring problem in software design. It is not a finished piece of code but a template that helps to solve a particular problem or family of problems.
Design patterns are best practices at which the software community has arrived over a period of time. They are supposed to help you write efficient, readable, testable, and easily extendable code. In some cases, they can be the result of a programming language not being expressive enough to elegantly achieve a goal. This means that more feature-rich languages might not even need a design pattern, while others still do. Scala is one of those rich languages, and in some cases, it makes the use of some design patterns obsolete or simpler. We will see how exactly it does that in this book.
The lack or existence of a certain functionality within a programming language also makes it able to implement additional design patterns that others cannot. The opposite is also valid—it might not be able to implement things that others can.