Scala Functional Programming Patterns
暫譯: Scala 函數式程式設計模式
Atul S.Khot
- 出版商: Packt Publishing
- 出版日期: 2015-12-24
- 售價: $2,220
- 貴賓價: 9.5 折 $2,109
- 語言: 英文
- 頁數: 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 的 FP 慣用語所帶來的價值
- 使用函數式編程慣用語解決日常編程問題
- 減少樣板程式碼,使用 Scala 簡潔的語法簡單而優雅地表達模式
- 通過減少可變部分來駕馭系統複雜性
- 使用 Actor 範式和 Akka 函式庫編寫更易於推理的並發程式碼
- 應用遞歸思維,理解如何在不變更狀態的情況下創建解決方案
- 重用現有程式碼以組合新行為
- 結合物件導向和函數式編程方法,使用 Scala 進行有效編程
## 詳細內容
Scala 用於構建優雅的類層次結構,以實現最大程度的程式碼重用和可擴展性,並使用高階函數實現其行為。其函數式編程(FP)特性有助於設計“易於推理”的系統,以控制日益增長的軟體複雜性。了解如何以及在哪裡應用許多 Scala 技術是具有挑戰性的。將 Scala 的最佳實踐放在您已知的背景下來看,有助於您快速掌握這些概念,並幫助您了解何時以及為何使用它們。
本書首先介紹模式背後的理由,以幫助您理解每個模式的應用場景和原因。您將發現尾遞歸為您帶來的好處,並理解如何在不變更狀態的情況下創建解決方案。接著,我們解釋了記憶化和無限序列的概念,以便按需計算。此外,本書還將帶您了解 Scala 的可堆疊特徵和依賴注入,這是一種流行的技術,用於生成鬆耦合的軟體系統。
您還將探索如何通過柯里化來優化程式碼,以及如何通過模式匹配進行解構來簡化程式碼。我們還將展示如何使用高階函數進行管道轉換,例如管道和過濾器模式。然後,我們將引導您了解並發編程日益重要性及傳統程式碼並發的陷阱。最後,本書將進行範式轉變,展示函數式編程為您帶來的不同技術。
這本書是幫助您理解和執行函數式編程的寶貴資源,並使用 Scala 的編程模式解決常見的編程問題。
## 風格與方法
這是一本針對 Scala 改變遊戲規則的編程特性的實用指南。
書中充滿了許多程式碼範例和圖示,說明各種 Scala 慣用語和最佳實踐。