Slide 1

Slide 1 text

Onboarding Process for Scala Team ScalaMatsuri 2020 Scala チームのオンボーディング 1

Slide 2

Slide 2 text

The opinions expressed here are my own and do not reflect the view of any organization ここで⽰されている⾒解は私個⼈のものであり、いかなる組織の⾒解を反映す るものではありません。 2

Slide 3

Slide 3 text

About this talk This talk is for Scala teams welcoming newcomers aboard Why onboarding matters for Scala teams Onboarding practices technology knowledge business domain knowledge Onboarding also refines source code 新メンバーを迎え⼊れるScala チーム向けに、なぜオンボーディングが重要か、 私たちのプラクティス、オンボーディングがコードを洗練させるということに ついてお話しします。 3

Slide 4

Slide 4 text

Background This talk is based on experiences in 3 teams Team size Newcomers Their Experienced Lang 3 ~ 5 2 Mid-careers 1 Intern Java 10 ~ 15 3 Mid-careers 3 Newgrads Java, Ruby, Python, JS, Go 4 ~ 5 2 Newgrads 3 Interns Java, Python このセッションの内容は、3 つのScala チームでの経験を元にしています。 4

Slide 5

Slide 5 text

Who ? Shunsuke Tadokoro @todokr Software Engineer @ BizReach, Inc. Robert Devlin Software Engineer @ BizReach, Inc. ⽥所 駿佑: 株式会社ビズリーチ ソフトウェアエンジニア ロバート・デブリン: 株式会社ビズリーチ ソフトウェアエンジニア 5

Slide 6

Slide 6 text

6

Slide 7

Slide 7 text

Scala & Team Scala とチーム 7

Slide 8

Slide 8 text

Scala is a "scalable" language Unique in its flexibility and expressiveness It enables developers and teams to change styles as they grow Procedural Object-Oriented Functional Scala は柔軟で表現⼒の豊かな⾔語。 開発者やチームの成⻑に合わせてスタイルを変えていくことができる。 8

Slide 9

Slide 9 text

If the team chooses FP style Starts with procedural style... まずは⼿続き型のスタイルで始める... 9

Slide 10

Slide 10 text

If the team chooses FP style... As time goes by, the team applies FP style そして時は流れ、チームは関数型スタイルに 10

Slide 11

Slide 11 text

If the team chooses FP style... However, it's hard for newcomers to catch up with the team 新メンバーのキャッチアップが⼤変 11

Slide 12

Slide 12 text

Why catching up matters The average half-life for software engineers is 3.2 years 「ソフトウェアエンジニアの半減期」は平均で3.2 年 12

Slide 13

Slide 13 text

Why catching up matters The average half-life for software engineers is 3.2 years We want to minimize the time it takes for newcomers to maximize their performance 新メンバーが最⾼のパフォーマンスを発揮するまでの時間を最⼩にしたい 13

Slide 14

Slide 14 text

Why catching up matters The average half-life for software engineers 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

Slide 15

Slide 15 text

Employee Onboarding 従業員オンボーディング 15

Slide 16

Slide 16 text

Definition: Employee onboarding “The process of assisting new hires in 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

Slide 17

Slide 17 text

What is employee onboarding good for? Productivity For a new employee to become fully productive, it takes eight months on average (AlliedHR) 新規採⽤者が最⼤の⽣産性を発揮するまでに必要な期間は平均8 ヶ⽉ 17

Slide 18

Slide 18 text

What is employee onboarding good for? Productivity For a new 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

Slide 19

Slide 19 text

What is employee onboarding good for? Productivity For a new 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

Slide 20

Slide 20 text

What is employee onboarding good for? Productivity For a new 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

Slide 21

Slide 21 text

21

Slide 22

Slide 22 text

What this session focuses How to support newcomers to gain a understanding of the skills and tasks required in the team using Scala このセッションは「新メンバーがScala を使うチームに必要なスキルとタスクを 理解することをどうサポートするか」にフォーカスします。 22

Slide 23

Slide 23 text

How shall we support? A viewpoint: The Professional Development Ladder by Steve McConnell, the author of the Code Complete スキルとタスクの理解をどう⽀えるか? ひとつの切り⼝が The Professional Development Ladder 23

Slide 24

Slide 24 text

The capability for software professional “We have found that professional capability for software professionals is like a three-legged stool” 「ソフトウェア開発者のケイパビリティは三本⾜の椅⼦のようなものであるこ とが分かった」 24

Slide 25

Slide 25 text

The capability for software professional “We have found that professional capability for software professionals is like a three-legged stool” 1. Technology knowledge 1. テクノロジーの知識 25

Slide 26

Slide 26 text

The capability for software professional “We have found that professional capability for software professionals is like a three-legged stool” 1. Technology knowledge 2. Business domain knowledge 2. ビジネスドメインの知識 26

Slide 27

Slide 27 text

The capability for software professional “We have found that professional 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

Slide 28

Slide 28 text

The capability for software professional “We have found that professional capability for software professionals is like a three-legged stool” 1. Technology knowledge 2. Business domain knowledge 3. Software development best practices knowledge オンボーディングでの問題は、テクノロジーの知識とビジネスドメインの知識 28

Slide 29

Slide 29 text

Our practice in gaining Technology Knowledge 我々のプラクティス: テクノロジーの知識編 29

Slide 30

Slide 30 text

Our practice: Technology Knowledge Start from "Why we use Scala" Topics we choose Types Collection operation Composition of function 「なぜScala を使うのか」から始める。 私たちの場合は、「型」「コレクション操作」「関数の合成」。 30

Slide 31

Slide 31 text

Our practice: Technology Knowledge Start from "Why we use Scala" Topics we choose Types Collection operation Composition of function Patterns "Scaffolding" in Mob/Pair programming Introduce learning resources Quick-win tasks その他のオンボーディングでのテクニック。 モブ/ ペアでの"Scaffolding" 、学習リソースの紹介、クイックウィンタスク。 31

Slide 32

Slide 32 text

Start from "Why we do Scala" Scala has many features and patterns. We cannot cover all in OJT/Off-JT Scala にはたくさんの機能とパターンがある。全てをOJT/Off-JT でカバーする ことはできない。 32

Slide 33

Slide 33 text

Start from "Why we do Scala" Scala has many features 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

Slide 34

Slide 34 text

Start from "Why we do Scala" Scala has many features 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

Slide 35

Slide 35 text

Learning topics we highlight 私たちがハイライトする学習トピック 35

Slide 36

Slide 36 text

Learning topics we highlight Types: How to exploit the power of types 型: その⼒をどう引き出すか 36

Slide 37

Slide 37 text

Learning topics we highlight Types: How to exploit the power of types Collections: Understand how the method works コレクション: メソッドの働きを理解する 37

Slide 38

Slide 38 text

Learning topics we highlight Types: How to exploit the power of types Collections: Understand how the method works Composition of functions: How to express logic cleanly 関数の合成: ロジックをクリーンに表現する 38

Slide 39

Slide 39 text

Learning topics we highlight Types: How to exploit the power 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

Slide 40

Slide 40 text

Learning topic #1: Types トピック1: 型 40

Slide 41

Slide 41 text

Type: the set of possible values 型: とりうる値の集合 41

Slide 42

Slide 42 text

Type: the set of possible values val id: String = fetchId(...) val name: String = fetchName(...) val age: Int = calcAge(...) 型: とりうる値の集合 42

Slide 43

Slide 43 text

Type: the set of possible values val id: String = fetchId(...) // String: ∞ val name: String = fetchName(...) // String: ∞ val age: Int = calcAge(...) // Int: -2147483648 ~ 2147483647 String が取りうる値: ∞ Int が取りうる値: -2147483648 ~ 2147483647 43

Slide 44

Slide 44 text

Type: the set of possible values val id: String = 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

Slide 45

Slide 45 text

Type: the set of possible values val id: String = 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

Slide 46

Slide 46 text

Exploit the power of types 型の⼒を引き出す 46

Slide 47

Slide 47 text

Exploit the power of types Value class: not to confuse values Value class: 値を取り違えないようにする 47

Slide 48

Slide 48 text

Exploit the power of types Value class: not to confuse values ADT and pattern matching: to express control flow simply ADT とパターンマッチング: 制御フローをシンプルに表現する 48

Slide 49

Slide 49 text

Exploit the power of types Value class: not to confuse values ADT and pattern matching: to express control flow simply Refinment Type: more type-safety & declarative validation Refinement Type: さらなる型安全性 & 宣⾔的バリデーション 49

Slide 50

Slide 50 text

Value class Create a more specific, info-rich type and use 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

Slide 51

Slide 51 text

ADT and pattern matching An information system is a pack of junctions sealed trait IP case class IPv4(value: String) extends IP case class IPv6(value: String) extends IP アプリケーションは分岐の塊 51

Slide 52

Slide 52 text

ADT and pattern matching An information system is a pack 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

Slide 53

Slide 53 text

ADT and pattern matching An information system is a pack 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

Slide 54

Slide 54 text

Refinement Type Handy techniques to harden type safety. refined A library refining types with type-level predicates より型安全性を⾼めるテクニック。refined というライブラリで実現。 54

Slide 55

Slide 55 text

Refinement type with refined // Define rule as type type AccountIdRule = MinSize[3] And MaxSize[10] And StartsWith["@"] type AgeRule = NonNegative ルールを型として表現する 55

Slide 56

Slide 56 text

Refinement type with refined // Define rule as type type 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

Slide 57

Slide 57 text

Refinement type with refined // Define rule as type type 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

Slide 58

Slide 58 text

More practical example https://engineering.visional.inc/blog/168/scala- refined-newtype/ Derive runtime validation logic from type Work with Circe & Doobie より実践的な例を、弊社エンジニアリングブログで公開しています。 宣⾔的なランタイムバリデーション、JSON やDB ライブラリとの連携 58

Slide 59

Slide 59 text

Newcomer Take: Types 新メンバーの感想: 型 59

Slide 60

Slide 60 text

Newcomer Take: Types Types are domain knowledge 型 = ドメイン知識 60

Slide 61

Slide 61 text

Newcomer Take: Types Types are domain knowledge Controls expected behavior more closely 型で、期待する振る舞いを保証できる 61

Slide 62

Slide 62 text

Learning topic #2: Collections トピック2: コレクション 62

Slide 63

Slide 63 text

An application is a pack of collections Members Products Purchases Shippings ... アプリケーションはコレクションの塊 63

Slide 64

Slide 64 text

Scala has a powerful collection library Provides highly abstract operations which are easy-to- use, concise and universal. Scala のコレクションライブラリは強⼒。 簡潔で広く適⽤できる、⾼度に抽象化された操作。 64

Slide 65

Slide 65 text

Scala has a powerful collection library Provides highly abstract operations 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

Slide 66

Slide 66 text

Visual Scala Reference 66

Slide 67

Slide 67 text

67

Slide 68

Slide 68 text

Newcomer Take: Collections 新メンバーの感想: コレクション 68

Slide 69

Slide 69 text

Newcomer Take: Collections Strictly typed collections enable flexibility map/collect/reduce/etc make data processing easy 型付けされたコレクションが実現する柔軟性 69

Slide 70

Slide 70 text

Newcomer Take: Collections Strictly typed collections enable flexibility map/collect/reduce/etc make data processing easy Online resources cover this part of Scala well オンラインリソースもあります! 70

Slide 71

Slide 71 text

Learning topic #3: Composing functions 71

Slide 72

Slide 72 text

An application is also a pack of functions Composability of functions is important for evolving design and keeping it clean. アプリケーションは関数の塊。関数の合成のしやすさは、設計の進化とそれを クリーンに保つうえで重要 72

Slide 73

Slide 73 text

An application is also a pack of functions Composability of functions is important for evolving design and keeping it clean. How do we compose functions? How do we handle errors? 関数同⼠をどのように組み合わせるか? エラーハンドリングをどうするか? 73

Slide 74

Slide 74 text

https://fsharpforfunandprofit.com/rop/ 74

Slide 75

Slide 75 text

Composing "one-track" functions is easy def add2(n: Int): Int = n + 2 def multi3(n: Int): Int = n * 3 multi3(add2(10)) // 36 val composed = (add2 _).andThen(multi3 _) // or (multi3 _).compose(add2 _) composed(10) // 36 結果が分岐しない "1 トラック" な関数は合成が簡単。 75

Slide 76

Slide 76 text

"Two-track" function However, there are many "two-track" functions in the real world def validateOrder(order: UnvalidatedOrder): Either[ValidationError, ValidatedOrder] def checkStock(order: ValidatedOrder): Either[OutOfStockError, AvailableOrder] def priceOrder(order: AvailableOrder): Either[LowerThanMinPriceError, PlacedOrder] しかし、現実の世界には "2 トラック" な関数が多くある。 76

Slide 77

Slide 77 text

How shall we compose two-track functions? If there is an error, it should get shunted onto the failure track and bypass the rest of steps 失敗時にはその先の関数をバイパスするように合成したい。どうすればよいだ ろうか? 77

Slide 78

Slide 78 text

That's what flatMap is for! そのためにあるのが flatMap ! 78

Slide 79

Slide 79 text

Compose two-track functions with flatMap def f(order: UnvalidatedOrder): Either[OrderError, PlacedOrder] = validateOrder(unvalidatedOrder).flatMap { validatedOrder => checkStock(validatedOrder).flatMap { availableOrder => priceOrder(availableOrder) } } flatMap を使って "2 トラック" 関数を合成する 79

Slide 80

Slide 80 text

If all of the functions go ... def f(order: UnvalidatedOrder): Either[OrderError, PlacedOrder] = validateOrder(order).flatMap { validatedOrder => checkStock(validatedOrder).flatMap { availableOrder => priceOrder(availableOrder) // => } } すべての関数がうまくいけば... 80

Slide 81

Slide 81 text

If any function goes ... def f(order: UnvalidatedOrder): Either[OrderError, PlacedOrder] = validateOrder(order).flatMap { validatedOrder => // checkStock(validatedOrder).flatMap { availableOrder => priceOrder(availableOrder) } } validateOrder が Left なら ... 81

Slide 82

Slide 82 text

If any function goes ... def f(order: UnvalidatedOrder): Either[OrderError, PlacedOrder] = validateOrder(order).flatMap { validatedOrder => checkStock(validatedOrder).flatMap { availableOrder => // priceOrder(availableOrder) } } checkStock が Left なら ... 82

Slide 83

Slide 83 text

If any function goes ... def f(order: UnvalidatedOrder): Either[OrderError, PlacedOrder] = validateOrder(order).flatMap { validatedOrder => checkStock(validatedOrder).flatMap { availableOrder => priceOrder(availableOrder) // } } priceOrder が Left なら ... 83

Slide 84

Slide 84 text

for comprehension Is just syntactic sugar to avoid deeply nested code def f(order: UnvalidatedOrder): Either[OrderError, PlacedOrder] = for { validatedOrder <- validateOrder(order) availableOrder <- checkStock(validatedOrder) placedOrder <- priceOrder(availableOrder) } yield placedOrder for comprehension のシンタックスシュガーで深いネストを避ける 84

Slide 85

Slide 85 text

Newcomer Take: Composing Functions 新メンバーの感想: 関数の合成 85

Slide 86

Slide 86 text

Newcomer Take: Composing Functions Cleans error-handling エラーハンドリングをきれいに書ける 86

Slide 87

Slide 87 text

Newcomer Take: Composing Functions Cleans error-handling Improves readability two-track functions make business logic easy to read ビジネスロジックが読みやすくなる 87

Slide 88

Slide 88 text

When we talk about function composition The key is . not to say the M-word コツは こと。 モ○ ドって⾔わない 88

Slide 89

Slide 89 text

When we talk about function composition The key is not to say the M-word. コツは モ○ ドって⾔わないこと。 89

Slide 90

Slide 90 text

Patterns to support gaining Technology Knowledge テクノロジーの知識習得をサポートするパタン 90

Slide 91

Slide 91 text

"Scaffolding" in Mob/Pair programming Sketch out broad outlines until everyone can realize implementation Entity, Usecase, Query, Controller, routes, etc. ペア/ モブプログラミングでの "Scaffolding" みんなが実装をイメージできるまで、⼤枠をスケッチする 91

Slide 92

Slide 92 text

Scaffolding Sketch a method of usecase layer. // in usecase layer def placeOrder(order: UnvalidatedOrder): Either[OrderError, PlacedOrder] = { // 1. validate order // 2. check stocks // 3. price order ??? } ユースケース層のメソッドをスケッチする。 92

Slide 93

Slide 93 text

Scaffolding Prepare repository/query/entity method interface. trait StockRepository { /** Validate order * ... */ def validate(order: UnvalidatedOrder): Either[InvalidOrderError, ValidatedOrder] } class JdbcStockRepository extends StockRepository { def validate(order: UnvalidatedOrder): Either[InvalidOrderError, ValidatedOrder] = ??? } リポジトリ/ クエリ/ エンティティのメソッドのシグネチャを決める。 93

Slide 94

Slide 94 text

"Scaffolding" in Mob/Pair programming Sketch out broad outlines until everyone can realize implementation Entity, Usecase, Query, Controller, routes, etc. ペア/ モブプログラミングでの "Scaffolding" みんなが実装をイメージできるまで、⼤枠をスケッチする。 94

Slide 95

Slide 95 text

"Scaffolding" in Mob/Pair programming Sketch out broad outlines until everyone 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

Slide 96

Slide 96 text

"Scaffolding" in Mob/Pair programming Sketch out broad outlines until everyone 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

Slide 97

Slide 97 text

Newcomer's Take: Scaffolding 新メンバーの感想: Scaffolding 97

Slide 98

Slide 98 text

Newcomer's Take: Scaffolding Sped up time-to-productivity 成果を出すまでの時間を縮めることができる。 98

Slide 99

Slide 99 text

Newcomer's Take: Scaffolding Sped up time-to-productivity Spread organizational knowledge and best practices 組織の知識やベストプラクティスを共有できる。 99

Slide 100

Slide 100 text

Newcomer's Take: Scaffolding Sped up time-to-productivity Spread organizational knowledge and best practices Upfront teaching costs give long-term benefits 育成コストの前払いで、⻑期的なメリットを得る。 100

Slide 101

Slide 101 text

Introducing learning resources Share learning resources that dig deeper into the details individually 学習リソースの紹介。 個⼈が詳細を深掘ることができるよう学習リソースを共有する。 101

Slide 102

Slide 102 text

Introducing learning resources Share learning resources that dig deeper into the details individually Sometimes be sent to newcomers before they join the team as an preboarding process Preboarding の⼀環として、⼊社前のメンバーに送ることもある。 102

Slide 103

Slide 103 text

Some of the learning resources Books 実践Scala ⼊⾨ Scala Scalable Programming Functional Programming in Scala Hands-on Scala Programming Online Resources Scala 研修テキスト Essential Scala Scala Exercises Essential Slick Scala with Cats S-99: Ninety-Nine Scala Problems Scala Pet Store Step by Step Play2 hands-on 103

Slide 104

Slide 104 text

Essential Scala Tour of syntax Exercises to implement generic fold, 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

Slide 105

Slide 105 text

Scala Tutorial (Scala Exercises) Based on Coursera course Functional Programming 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

Slide 106

Slide 106 text

Hands-on Scala Programming Begins with an explanation of grammar, followed 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

Slide 107

Slide 107 text

Play2 + Slick/ScalikeJdbc hands-on A tutorial that implements CRUD app with Play2 and Slick/ScalikeJdbc Amount that can be completed in a few hours to a day Play2 + Slick/ScalikeJdbc でCRUD アプリを作るチュート リアル。数時間~1 ⽇で完了できる分量 107

Slide 108

Slide 108 text

Quick-win tasks A pattern that allows newcomers to contribute quickly クイックウィン タスク。新メンバーがすぐにコードにコントリビュートできる ようにするパタン。 108

Slide 109

Slide 109 text

Quick-win tasks A pattern that allows newcomers to contribute quickly 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

Slide 110

Slide 110 text

Quick-win tasks A pattern that allows newcomers to contribute quickly 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

Slide 111

Slide 111 text

Our practice in instructing Business Domain Knowledge 我々が実践していること: ビジネスドメインの知識編 111

Slide 112

Slide 112 text

Our practice: Business Domain Knowledge Classroom-lectures: Market, competitors and our product knowledge 座学: 市場や競合、⾃プロダクトについての知識を得る 112

Slide 113

Slide 113 text

Our practice: Business Domain Knowledge Classroom-lectures: Market, competitors and our product knowledge Pair/mob programming: Product specs ペアプロやモブプロ: プロダクトの仕様についてのレクチャー 113

Slide 114

Slide 114 text

Our practice: Business Domain Knowledge Classroom-lectures: Market, competitors and our product knowledge Pair/mob programming: Product specs A tool: How domain knowledge is represented in source code 「ドメイン知識がどのようにプロダクトで表現されているか」を可視化するツ ール 114

Slide 115

Slide 115 text

Zugen An architecture diagram generator for Scala project Provided as a sbt plugin Generates diagrams with SemanticDB/ScalaMeta Domain object table Domain relation diagram Method invocation diagram Zugen: Scala プロジェクトのアーキテクチャ図を⽣成するsbt プラグイン SemanticDB/ScalaMeta で図を⽣成する 115

Slide 116

Slide 116 text

Target source code example package domain.model.order sealed trait OrderStatus /** 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

Slide 117

Slide 117 text

Domain Object Table ドメインオブジェクトの⼀覧表 117

Slide 118

Slide 118 text

Domain Relation Diagram ドメインオブジェクトの関連図 118

Slide 119

Slide 119 text

Method Invocation Diagram メソッド呼び出し階層図 119

Slide 120

Slide 120 text

Onboarding with diagrams Diagrams support the understanding of how domain knowledge is represented in source code As a glossary, a map of bounded context, an overview of usecases 図はドメインがどのようにコードで表現されているかの理解をサポートする。 ⽤語集、概念の地図、ユースケースの概観図として。 120

Slide 121

Slide 121 text

Onboarding with diagrams Diagrams support the understanding of how domain 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

Slide 122

Slide 122 text

Onboarding also refines source code 122

Slide 123

Slide 123 text

Realizing design unfit in the onboarding process While explaining the code to newcomers, we sometimes feel uneasy about it 新メンバーに既存のコードについて説明していると、たまに違和感を覚えるこ とがある 123

Slide 124

Slide 124 text

Realizing design unfit in the onboarding process While explaining the 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

Slide 125

Slide 125 text

Realizing design unfit in the onboarding process While explaining the 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

Slide 126

Slide 126 text

SoftwareMill Tech Blog "Simple Scala Stack" As far as Scala 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

Slide 127

Slide 127 text

Onboarding process is a great chance to find engineering unfit Turn randomness into a chance for optimization, reconsider styles the team had previously chosen オンボーディングはオーバー/ アンダーエンジニアリングなどのunfit を発⾒す るチャンス。変化を逆⼿に取り、いままでのスタイルを⾒直す。 127

Slide 128

Slide 128 text

Not just instruction, but co-creation Onboarding process is not a one-way communication, but co-creation オンボーディングは⼀⽅的な伝達ではなく、共創のプロセス 128

Slide 129

Slide 129 text

Not just instruction, but co-creation Onboarding process is not a 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

Slide 130

Slide 130 text

Wrap up 130

Slide 131

Slide 131 text

Wrap up: Why onboarding matters A proper onboarding process reduces 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

Slide 132

Slide 132 text

Wrap up: Support for gaining knowledge There are a lot 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

Slide 133

Slide 133 text

Wrap up: Support for gaining knowledge There are a lot 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

Slide 134

Slide 134 text

Wrap up: Onboarding refines the code While using Scala, it’s 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

Slide 135

Slide 135 text

Wrap up: Onboarding refines the code While using Scala, it’s 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

Slide 136

Slide 136 text

Wrap up: Onboarding refines the code While using Scala, it’s 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

Slide 137

Slide 137 text

Interested in HR topic like this talk? We're looking for Scala developers who are passionate about solving people's work-related challenges! Feel free to join our Discord channel ! 私たちは⼈が働くことにまつわる課題を解決することに情熱を傾けられるScala 開発者を探しています。まずはDiscord チャンネルでお話しましょう! 137

Slide 138

Slide 138 text

Thank you! Build a nice Scala onboarding process Grow your Scala team Make Scala community more attractive ありがとうございました 素敵なオンボーディングプロセスを組み⽴てよう、Scala チームを育てよう、 そしてScala コミュニティをさらに魅⼒的にしよう 138