Book Image

Scala Functional Programming Patterns

By : Atul S. Khot
Book Image

Scala Functional Programming Patterns

By: Atul S. Khot

Overview of this book

Scala is used to construct elegant class hierarchies for maximum code reuse and extensibility and to implement their behavior using higher-order functions. Its functional programming (FP) features are a boon to help you design “easy to reason about” systems to control the growing software complexities. Knowing how and where to apply the many Scala techniques is challenging. Looking at Scala best practices in the context of what you already know helps you grasp these concepts quickly, and helps you see where and why to use them. This book begins with the rationale behind patterns to help you understand where and why each pattern is applied. You will discover what tail recursion brings to your table and will get an understanding of how to create solutions without mutations. We then explain the concept of memorization and infinite sequences for on-demand computation. Further, the book takes you through Scala’s stackable traits and dependency injection, a popular technique to produce loosely-coupled software systems. You will also explore how to currying favors to your code and how to simplify it by de-construction via pattern matching. We also show you how to do pipeline transformations using higher order functions such as the pipes and filters pattern. Then we guide you through the increasing importance of concurrent programming and the pitfalls of traditional code concurrency. Lastly, the book takes a paradigm shift to show you the different techniques that functional programming brings to your plate. This book is an invaluable source to help you understand and perform functional programming and solve common programming problems using Scala’s programming patterns.
Table of Contents (19 chapters)
Scala Functional Programming Patterns
Credits
About the Author
Aknowledgement
About the Reviewers
www.PacktPub.com
Preface
Index

Aknowledgement

A big thanks to my late mother, Sushila S. Khot. Aai, you taught me human values. You were a teacher all your life, and felt very deeply for young girls and their education. I remember those countless occasions when you helped needy girls with school supplies. You gave so much to the blind school and countless others. Looking back, I feel so proud that you never differentiated between me and my sisters. I will always be human, my dear mother, and will never let you down. I know in my heart of hearts that you are just a prayer away!

A big thanks to my late father, Shriniwas V. Khot. Anna, to me you will always be a hero who fought for a free and united India. I learned from you that freedom is invaluable and life is not meant to be easy. Always a fierce fighter all your life, you wanted me to stand up for what's right and just. You always encouraged me to take the road less traveled. You are no more, but there are so many cherished moments. Memories keep flooding back and I marvel at what gem of a father I had! You will always live on in my memories!

I want to deeply thank the technical reviewers of this book, Rui Gonçalves, Steve Perkins, Hawk Weisman, Zahidul Islam, and Shubhajit. I was continually amazed by the depth of knowledge and insight your feedback carried. Needless to say, I learned a lot from you all. It was simply great working with you all—y'all rock!

Hearthfelt thanks to the wonderful Scala community for all the support. I am continually amazed by the spirit to help budding Scala programmers!

A special mention of my draft reviewer and editor, Divij Kotian. He has a super sharp eye for detail, immense dedication, and has been a pillar of strength. In addition to the meticulous reviews, Divij also coordinated all the review and publishing phases. Divij you are a gem—you know your stuff!

A special thanks to Pranjali, Joanna, and Neha. I am continually amazed by all your attention to detail in making sure that the book is error free. I feel privileged working with you! Ever indebted.

Big thanks to Nikhil Karkal! Nikhil, you got us all together and gave me the opportunity to work with all these amazing people. Without your support and help, this book would not have been possible. Big thanks! You are the best!

Last but not least, thanks to my wife, Rupali. It is comforting to know you are there always! And to Kalyani, my daughter—my precious, thanks for keeping my hopes alive!

I would like to thank my colleagues at Webonise Lab for the wonderful environment, support, and understanding. Working with you all has been a privilege!