Scala Design Patterns.
Ivan Nikolov
- 396 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Scala Design Patterns.
Ivan Nikolov
About This Book
Learn how to write efficient, clean, and reusable code with ScalaAbout This Book• Unleash the power of Scala and apply it in the real world to build scalable and robust applications.• Learn about using and implementing Creational, Structural, Behavioral, and Functional design patterns in Scala • Learn how to build scalable and extendable applications efficientlyWho This Book Is ForIf you want to increase your understanding of Scala and apply design patterns to real-life application development, then this book is for you.Prior knowledge of Scala language is assumed/ expected.What You Will Learn• Immerse yourself in industry-standard design patterns—structural, creational, and behavioral—to create extraordinary applications • See the power of traits and their application in Scala • Implement abstract and self types and build clean design patterns • Build complex entity relationships using structural design patterns • Create applications faster by applying functional design patternsIn DetailDesign patterns make developers' lives easier by helping them write great software that is easy to maintain, runs efficiently, and is valuable to the company or people concerned. You'll learn about the various features of Scala and will be able to apply well-known, industry-proven design patterns in your work. The book starts off by focusing on some of the most interesting and latest features of Scala while using practical real-world examples. We will be learning about IDE's and Aspect Oriented Programming. We will be looking into different components in Scala. We will also cover the popular "Gang of Four" design patterns and show you how to incorporate functional patterns effectively. The book ends with a practical example that demonstrates how the presented material can be combined in real-life applications. You'll learn the necessary concepts to build enterprise-grade applications. By the end of this book, you'll have enough knowledge and understanding to quickly assess problems and come up with elegant solutions.Style and approachThe design patterns in the book are explained using real-world, step-by-step examples. For each design pattern, there are tips on when to use it and when to look for something more suitable. This book can also be used as a practical guide, showing you how to leverage design patterns effectively. We've designed the book to be used as a quick reference guide while creating applications.
Frequently asked questions
Information
Behavioral Design Patterns – Part One
- Value object
- Null object
- Strategy
- Command
- Chain of responsibility
- Interpreter
Defining behavioral design patterns
The value object design pattern
An example class diagram
A code example
case class Date(
day: Int,
month: String,
year: Int
)
object DateExample {
def main(args: Array[String]): Unit = {
val thirdOfMarch = Date(3, "MARCH", 2016)
val fourthOfJuly = Date(4, "JULY", 2016)
val newYear1 = Date(31, "DECEMBER", 2015)
val newYear2 = Date(31, "DECEMBER", 2015)
System.out.println(s"The 3rd of March 2016 is the same as
the 4th of July 2016: ${thirdOfMarch == fourthOfJuly}")
System.out.println(s"The new year of 2015 is here twice:
${newYear1 == newYear2}")
}
}
class BadDate(
day: Int,
month: String,
year: Int
)
object BadDateExample {
def main(args: Array[String]): Unit = {
val thirdOfMarch = new BadDate(3, "MARCH", 2016)
val fourthOfJuly = new BadDate(4, "JULY", 2016)
val newYear1 = new BadDate(31, "DECEMBER", 2015)
val newYear2 = new BadDate(31, "DECEMBER", 2015)
System.out.println(s"The 3rd of March 2016 is the same as the
4th of July 2016: ${thirdOfMarch == fourthOfJuly}")
System.out.println(s"The new year of 2015 is here twice:
${newYear1 == newYear2}")
}
}