expressiveness It enables developers and teams to change styles as they grow Procedural Object-Oriented Functional Scala は柔軟で表現⼒の豊かな⾔語。 開発者やチームの成⻑に合わせてスタイルを変えていくことができる。 8
is 3.2 years We want to minimize the time it takes for newcomers to maximize their performance Also, we want newcomers to remain with the team かつ、新メンバーが⻑く居続けてもらえるようにしたい 14
gaining a functional understanding of the skills and tasks required in their new role, helping them to develop new relationships with others in the workplace, and facilitating an understanding of the company culture and goals.”(Dr. Allison Ellis, Ph.D. ) 「新⼊社員が新しい役割に必要なスキルとタスクを機能的に理解し、職場で他 の⼈と新しい関係を築き、企業⽂化の理解を促進するプロセス」 16
employee to become fully productive, it takes eight months on average (AlliedHR) A new employee who had a sufficient onboarding programs gain full proficiency 34% faster than who didn't (Urbanbound) ⼗分なオンボーディングプログラムを受けた従業員は、そうでない従業員に⽐ べて最⾼のパフォーマンスに達するまでの期間が34% 短縮される 18
employee to become fully productive, it takes eight months on average (AlliedHR) A new employee who had a sufficient onboarding programs gain full proficiency 34% faster than who didn't (Urbanbound) Retention New employees who went through a structured onboarding program were 58% more likely to be with the organization after three years (Wynhurst Group) 構造化されたオンボーディングを経験した新規採⽤者は、そうでない採⽤者に ⽐べて3 年後の在職率が58% ⾼い 19
employee to become fully productive, it takes eight months on average (AlliedHR) A new employee who had a sufficient onboarding programs gain full proficiency 34% faster than who didn't (Urbanbound) Retention New employees who went through a structured onboarding program were 58% more likely to be with the organization after three years (Wynhurst Group) Organizations with a strong onboarding process improve new hire retention by 82% (Brandon Hall Group) 強⼒なオンボーディングプロセスを持つ組織は、新規採⽤者の在職率が82 %以 上向上する 20
capability for software professionals is like a three-legged stool” 1. Technology knowledge 2. Business domain knowledge 3. Software development best practices knowledge 3. ソフトウェア開発のベストプラクティスの知識 27
capability for software professionals is like a three-legged stool” 1. Technology knowledge 2. Business domain knowledge 3. Software development best practices knowledge オンボーディングでの問題は、テクノロジーの知識とビジネスドメインの知識 28
and patterns. We cannot cover all in OJT/Off-JT Therefore, we have to start with "Why we use Scala" What value do we see in Scala? What aspect affects our business? だからこそ「なぜ我々はScala を使うのか」から始める。どんな価値を⾒出して いるか?どんな性質が⾃分らのビジネスに影響を与えるのか? 33
and patterns. We cannot cover all in OJT/Off-JT Therefore, we have to start with "Why we use Scala" What value do we see in Scala? What aspect affects our business? Then, choose learning topics to concentrate on 問いへの答えをもとに、⼒を⼊れるトピックを選ぶ 34
of types Collections: Understand how the method works Composition of functions: How to express logic cleanly We'll introduce how we unpack these topics. これらの学習トピックを、新メンバーにどのようにお話しているかをご紹介し ます。 39
fetchId(...) // String: ∞ val name: String = fetchName(...) // String: ∞ val age: Int = calcAge(...) // Int: -2147483648 ~ 2147483647 It's very rare to have an unbounded string or integer in a real-world domain 現実の問題領域において、制限のない数値や⽂字列はほぼ存在しない。 44
fetchId(...) // String: ∞ val name: String = fetchName(...) // String: ∞ val age: Int = calcAge(...) // Int: -2147483648 ~ 2147483647 It's very rare to have an unbounded string or integer in a real-world domain There's no special meaning or domain-specific restriction in String or Int String やInt に特別な意味はない。 45
it Not to confuse arguments Creating value class takes no labor in Scala case class AccountId(value: String) extends AnyVal case class AccountName(value: String) extends AnyVal val accountId: AccountId = AccountId("@todokr") val name: AccountName = AccountName("Shunsuke Tadokoro") Value class: より特定的で情報量の豊かな型 50
of junctions sealed trait IP case class IPv4(value: String) extends IP case class IPv6(value: String) extends IP ip match { case IPv4(value) => // handle IPv4 case IPv6(value) => // handle IPv6 } アプリケーションは分岐の塊 52
of junctions sealed trait IP case class IPv4(value: String) extends IP case class IPv6(value: String) extends IP ip match { case IPv4(value) => // handle IPv4 case IPv6(value) => // handle IPv6 } The combination of ADT and pattern matching is a powerful way to express logic concisely ADT とパターンマッチングは、簡潔にロジックを表現する強⼒な⼿段 53
AccountIdRule = MinSize[3] And MaxSize[10] And StartsWith["@"] type AgeRule = NonNegative // "refine" String and Int type type AccountIdString = String Refined AccountIdRule type AgeInt = Int Refined AgeRule String やInt を"refine" する 56
AccountIdRule = MinSize[3] And MaxSize[10] And StartsWith["@"] type AgeRule = NonNegative // "refine" String and Int type type AccountIdString = String Refined AccountIdRule type AgeInt = Int Refined AgeRule val accountId: AccountIdString = "@uryyyyyyyyy" // Compile error! val age: AgeInt = -1 // Compile error! ルールを満たさない値はコンパイルエラー 57
which are easy-to- use, concise and universal. However, teaching what those methods do easily isn't easy "scala".groupMapReduce(identity)(_ => 1)(_ + _) // Map(a -> 2, c -> 1, s -> 1, l -> 1) しかし、メソッドの働きを易しく教えるのは簡単ではない 65
functions is important for evolving design and keeping it clean. How do we compose functions? How do we handle errors? 関数同⼠をどのように組み合わせるか? エラーハンドリングをどうするか? 73
can realize implementation Entity, Usecase, Query, Controller, routes, etc. Then check the rest of the tasks, replan, and get the job done individually Implementing a Repository/Query is a good starting point for newcomers その後に残タスクを確認して計画を修正し、個別に撃破する。 95
can realize implementation Entity, Usecase, Query, Controller, routes, etc. Then check the rest of the tasks, replan, and get the job done individually Implementing a Repository/Query is a good starting point for newcomers Newcomers can; Get technical knowledge through practice Reduce rework 新メンバーは⼿戻りを減らしつつ、⼿を動かして学ぶことができる。 96
Equal type class, etc. A good read before reading FP in Scala Scala with Cats and Essential Slick are also recommended ⽂法のツアーやジェネリックなfold 、Equal 型クラスの実 装。FP in Scala の前にやると丁度いいかも。Scala with Cats や Essential Slick などの姉妹編もおすすめ 104
Principles in Scala & Functional Program Design in Scala More than just how-to topics Side-effect and time, Functional loop, etc. Scala Exercises contains Typelevel's lib tutorials, such as Cats, Circe, Doobie, and so on Coursera のコースを元にしている。ただのハウツーでは なく、副作⽤や関数型のループなど深い内容。シリーズ には他にTypelevel のライブラリのチュートリアルも 105
by some interesting exercises Sorting algorithms, file manipulation, JSON serialization, etc. In the second half, practical lessons creating mini-applications Web scraping, chatting, and real-time synchronization of files, etc. ⽂法の解説から始まり、いくつかのエクササイズが続 く。後半はWeb スクレイピングや、リアルタイムファイ ル同期などを作る実践的な内容 106
with Play2 and Slick/ScalikeJdbc Amount that can be completed in a few hours to a day Play2 + Slick/ScalikeJdbc でCRUD アプリを作るチュート リアル。数時間~1 ⽇で完了できる分量 107
Stock tasks small enough to be done in a few hours ~ a day During the onboarding period, a new member's schedule is likely to be shredded. That's why small tasks matter 数時間~1 ⽇で完了するタスクを⽇頃からストックしておく。オンボーディング 期間中はスキマ時間ができがちなので、ほどよく⼩さいサイズが⼤事 109
Stock tasks small enough to be done in a few hours ~ a day During the onboarding period, a new member's schedule is likely to be shredded. That's why small tasks matter For example, updating dependent libraries that Scala Steward suggests 例えば、Scala Steword が作ってくれたライブラリアップデートPull Request の 検証など。 110
product knowledge Pair/mob programming: Product specs A tool: How domain knowledge is represented in source code 「ドメイン知識がどのようにプロダクトで表現されているか」を可視化するツ ール 114
Status of an order */ object OrderStatus { /** Placed Status */ case object Placed extends OrderStatus /** Completed Status */ case object Completed extends OrderStatus } /** An order */ case class Order( orderId: Id[Order], customerId: Id[Customer], status: OrderStatus, ) object Order { /** Place an order */ def place(customerId: Id[Customer]): Order = Order(Id("1"), customerId, OrderStatus.Placed) } 対象とするソースコードの例 116
knowledge is represented in source code As a glossary, a map of bounded context, an overview of usecases 図はドメインがどのようにコードで表現されているかの理解をサポートする。 ⽤語集、概念の地図、ユースケースの概観図として。 120
knowledge is represented in source code As a glossary, a map of bounded context, an overview of usecases Diagrams make it easier for newcomers to join design discussions Because newcomers can see the structure, it's easier to say "this part can be improved" 図で、新メンバーがデザインの議論に参加しやすくする。 構造が⾒えるので「どこそこの形が改善できそう」など発⾔しやすくなる。 121
code to newcomers, we sometimes feel uneasy about it As the product grows, the team notices the solution which the team chose has become insufficient "Using regex to parse query params became too complicated..." プロダクトが育ち、過去のソリューションでは問題が解けなくなっていること に気づく 124
code to newcomers, we sometimes feel uneasy about it As the product grows, the team notices the solution which the team chose has become insufficient "Using regex to parse query params became too complicated..." Conversely, using "too advanced" solutions to solve "everyday" problems "Is a finite state machine necessary for this tiny usecase?" 逆に、過度に⾼度なソリューションで⽇々の問題を解いていることに気づく 125
is concerned, it’s sometimes easy to lose focus on solving simple problems using simple code. The Scala language offers a number of features (...) This, in turn, can lead to complex code; but certainly doesn’t have to. We just need to keep in mind, what kind of problem are we solving “ “ 「Scala では時として、シンプルな問題をシンプルに解くことへのフォーカスを 失ってしまいがち」「どんな問題を解いているのかを⼼に留める必要がある」 126
Turn randomness into a chance for optimization, reconsider styles the team had previously chosen オンボーディングはオーバー/ アンダーエンジニアリングなどのunfit を発⾒す るチャンス。変化を逆⼿に取り、いままでのスタイルを⾒直す。 127
one-way communication, but co-creation Working together with a newcomer to find the best style to get 100% of the power of Scala Update team's awareness of the challenges Review the challenge-solution fit Scala の⼒を100% 引き出すために、チームにとって最適なスタイルを新メンバ ーといっしょに⾒つける 129
lead time to newcomers' maximum performance and increases retention rate This is an important issue for teams adopting Scala because of its learning costs 適切なオンボーディングプロセスは新メンバーのパフォーマンスを発揮するま でのリードタイム短縮と離職低下に効く。これは学習コストが⾼いとされる Scala を採⽤するチームには重要な問題 131
of topics about gaining technical knowledge So narrowing the topic down from "Why do we use Scala?" is important We introduced topics we highlight and techniques テクノロジーの知識に関するトピックは沢⼭ある。なので「なぜ我々はScala を 使っているのか?」の問いでトピックを絞り込むことが⼤事 132
of topics about gaining technical knowledge So narrowing the topic down from "Why do we use Scala?" is important We introduced topics we highlight and techniques Gaining business domain knowledge is also important Zugen: An architecture diagram generator for Scala project ビジネスドメインに関する知識も重要。理解をサポートするツールとして Zugen を紹介しました 133
sometimes easy to lose focus on solving simple problems using simple code. We need to keep in mind, what problem we are solving Scala では時として、シンプルな問題をシンプルに解くことへのフォーカスを失 ってしまいがち。どんな問題を解いているのかを⼼に留める必要がある 134
sometimes easy to lose focus on solving simple problems using simple code. We need to keep in mind, what problem we are solving Onboarding process is a great chance to find engineering unfit オンボーディングは、エンジニアリングのunfit を⾒つける絶好のチャンス 135
sometimes easy to lose focus on solving simple problems using simple code. We need to keep in mind, what problem we are solving Onboarding process is a great chance to find engineering unfit In that sense, the onboarding process is not just instruction but actually co-creation of the best style to utilize 100% of the power of Scala その意味で、オンボーディングは⼀⽅的な伝達ではなく、Scala の⼒を100% 引 き出すベストなスタイルを新メンバーと共に作るプロセス 136