Scala Functional Programming Patterns
Atul S.Khot
- 出版商: Packt Publishing
- 出版日期: 2015-12-24
- 售價: $2,170
- 貴賓價: 9.5 折 $2,062
- 語言: 英文
- 頁數: 298
- 裝訂: Paperback
- ISBN: 1783985844
- ISBN-13: 9781783985845
-
相關分類:
JVM 語言
海外代購書籍(需單獨結帳)
相關主題
商品描述
Grok and perform effective functional programming in Scala
About This Book
- Understand functional programming patterns by comparing them with the traditional object-oriented design patterns
- Write robust, safer, and better code using the declarative programming paradigm
- An illustrative guide for programmers to create functional programming patterns with Scala
Who This Book Is For
If you have done Java programming before and have a basic knowledge of Scala and its syntax, then this book is an ideal choice to help you to understand the context, the traditional design pattern applicable, and the Scala way. Having previous knowledge of design patterns will help, though it is not strictly necessary.
What You Will Learn
- Get to know about functional programming and the value Scala's FP idioms bring to the table
- Solve day-to-day programming problems using functional programming idioms
- Cut down the boiler-plate and express patterns simply and elegantly using Scala's concise syntax
- Tame system complexity by reducing the moving parts
- Write easier to reason about concurrent code using the actor paradigm and the Akka library
- Apply recursive thinking and understand how to create solutions without mutation
- Reuse existing code to compose new behavior
- Combine the object-oriented and functional programming approaches for effective programming using Scala
In Detail
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.
Style and approach
This is a hands-on guide to Scala's game-changing features for programming.
It is filled with many code examples and figures that illustrate various Scala idioms and best practices.
商品描述(中文翻譯)
深入理解並運用 Scala 的有效函數式編程
關於本書
- 通過比較傳統面向對象的設計模式,了解函數式編程模式
- 使用聲明式編程範式編寫強大、更安全、更優質的代碼
- 為程序員提供一個實用指南,以 Scala 創建函數式編程模式
本書適合對象
如果您之前有 Java 編程經驗,並對 Scala 及其語法有基本了解,那麼本書是您理解上下文、適用的傳統設計模式以及 Scala 方法的理想選擇。雖然不是必需的,但具有設計模式的先備知識將有所幫助。
您將學到什麼
- 了解函數式編程以及 Scala 的函數式編程範式的價值
- 使用函數式編程範式解決日常編程問題
- 使用 Scala 簡潔的語法簡單而優雅地表達模式
- 通過減少移動部件來控制系統複雜性
- 使用 actor 範例和 Akka 库編寫更易於理解的並發代碼
- 運用遞歸思維,了解如何在不使用變異的情況下創建解決方案
- 重用現有代碼以組合新的行為
- 結合面向對象和函數式編程方法,以實現有效的 Scala 編程
詳細內容
Scala 用於構建優雅的類層次結構,以實現代碼最大程度的重用性和可擴展性,並使用高階函數來實現其行為。它的函數式編程(FP)特性有助於設計“易於理解”的系統,以控制不斷增長的軟件複雜性。了解何時何地應用許多 Scala 技術是具有挑戰性的。通過將 Scala 最佳實踐與您已經了解的內容相結合,可以幫助您快速掌握這些概念,並幫助您了解何時以及為什麼使用它們。
本書首先解釋了模式背後的原理,幫助您理解每個模式應用的位置和原因。您將了解尾遞迴對您的幫助,並了解如何在不使用變異的情況下創建解決方案。然後,我們解釋了記憶化和無窮序列的概念,以實現按需計算。此外,本書還介紹了 Scala 的可堆疊特性和依賴注入,這是一種用於生成鬆散耦合軟件系統的流行技術。
您還將探索柯里化對代碼的幫助以及通過模式匹配進行解構簡化代碼的方法。我們還向您展示如何使用高階函數(例如管道和過濾器模式)進行管道轉換。然後,我們引導您了解並發編程的日益重要性以及傳統代碼並發的陷阱。最後,本書進行了範式轉變,向您展示函數式編程為您帶來的不同技術。
本書是一個寶貴的資源,可幫助您理解和執行函數式編程,並使用 Scala 的編程模式解決常見的編程問題。
風格和方法
這是一本關於 Scala 革命性特性的實踐指南。
書中包含許多代碼示例和圖例,說明了各種 Scala 慣用語法和最佳實踐。