@k2works/claude-code-booster 3.6.1 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +42 -42
- package/bin/claude-code-booster +90 -90
- package/lib/assets/.claude/README.md +258 -239
- package/lib/assets/.claude/agent-memory/xp-programmer/MEMORY.md +6 -0
- package/lib/assets/.claude/agent-memory/xp-programmer/project_cargo_tracker.md +11 -0
- package/lib/assets/.claude/agent-memory/xp-programmer/project_ddd_patterns.md +27 -0
- package/lib/assets/.claude/agent-memory/xp-programmer/project_us07_route_assignment.md +19 -0
- package/lib/assets/.claude/scripts/generate-inception-deck.mjs +911 -911
- package/lib/assets/.claude/settings.json +11 -11
- package/lib/assets/.claude/skills/ai-agent-guidelines/SKILL.md +111 -111
- package/lib/assets/.claude/skills/analyzing-architecture/SKILL.md +83 -83
- package/lib/assets/.claude/skills/analyzing-business/SKILL.md +95 -95
- package/lib/assets/.claude/skills/analyzing-data-model/SKILL.md +77 -77
- package/lib/assets/.claude/skills/analyzing-domain-model/SKILL.md +117 -117
- package/lib/assets/.claude/skills/analyzing-inception-deck/SKILL.md +84 -84
- package/lib/assets/.claude/skills/analyzing-non-functional/SKILL.md +95 -95
- package/lib/assets/.claude/skills/analyzing-operation/SKILL.md +95 -95
- package/lib/assets/.claude/skills/analyzing-requirements/SKILL.md +91 -91
- package/lib/assets/.claude/skills/analyzing-tech-stack/SKILL.md +101 -101
- package/lib/assets/.claude/skills/analyzing-test-strategy/SKILL.md +89 -89
- package/lib/assets/.claude/skills/analyzing-ui-design/SKILL.md +80 -80
- package/lib/assets/.claude/skills/analyzing-usecases/SKILL.md +72 -72
- package/lib/assets/.claude/skills/creating-adr/SKILL.md +113 -113
- package/lib/assets/.claude/skills/developing-backend/SKILL.md +100 -100
- package/lib/assets/.claude/skills/developing-frontend/SKILL.md +93 -93
- package/lib/assets/.claude/skills/developing-release/SKILL.md +120 -120
- package/lib/assets/.claude/skills/generating-bmc/SKILL.md +97 -0
- package/lib/assets/.claude/skills/generating-slides/SKILL.md +94 -94
- package/lib/assets/.claude/skills/git-commit/SKILL.md +81 -81
- package/lib/assets/.claude/skills/killing-processes/SKILL.md +44 -44
- package/lib/assets/.claude/skills/operating-backup/SKILL.md +59 -59
- package/lib/assets/.claude/skills/operating-cicd/SKILL.md +54 -54
- package/lib/assets/.claude/skills/operating-deploy/SKILL.md +67 -67
- package/lib/assets/.claude/skills/operating-docs/SKILL.md +219 -219
- package/lib/assets/.claude/skills/operating-provision/SKILL.md +77 -77
- package/lib/assets/.claude/skills/operating-setup/SKILL.md +63 -63
- package/lib/assets/.claude/skills/orchestrating-analysis/SKILL.md +104 -104
- package/lib/assets/.claude/skills/orchestrating-development/SKILL.md +162 -162
- package/lib/assets/.claude/skills/orchestrating-operation/SKILL.md +158 -158
- package/lib/assets/.claude/skills/orchestrating-project/SKILL.md +144 -144
- package/lib/assets/.claude/skills/planning-releases/SKILL.md +119 -119
- package/lib/assets/.claude/skills/syncing-github-project/SKILL.md +151 -151
- package/lib/assets/.claude/skills/tracking-progress/SKILL.md +91 -91
- package/lib/assets/.claude/skills/validating-iteration-plan/SKILL.md +215 -215
- package/lib/assets/.devcontainer/devcontainer.json +34 -34
- package/lib/assets/.env.example +17 -17
- package/lib/assets/.gitattributes +4 -4
- package/lib/assets/.github/workflows/docker-publish.yml +77 -77
- package/lib/assets/.github/workflows/mkdocs.yml +39 -39
- package/lib/assets/AGENTS.md +94 -94
- package/lib/assets/CLAUDE.md +1 -0
- package/lib/assets/README.md +254 -254
- package/lib/assets/docker-compose.yml +33 -33
- package/lib/assets/docs/adr/index.md +10 -10
- package/lib/assets/docs/article/functional-desgin-ppp/all/01-immutability-and-data-transformation.md +475 -475
- package/lib/assets/docs/article/functional-desgin-ppp/all/02-function-composition.md +519 -519
- package/lib/assets/docs/article/functional-desgin-ppp/all/03-polymorphism.md +537 -537
- package/lib/assets/docs/article/functional-desgin-ppp/all/04-data-validation.md +300 -300
- package/lib/assets/docs/article/functional-desgin-ppp/all/05-property-based-testing.md +320 -320
- package/lib/assets/docs/article/functional-desgin-ppp/all/06-tdd-and-functional.md +498 -498
- package/lib/assets/docs/article/functional-desgin-ppp/all/07-composite-pattern.md +298 -298
- package/lib/assets/docs/article/functional-desgin-ppp/all/08-decorator-pattern.md +291 -291
- package/lib/assets/docs/article/functional-desgin-ppp/all/09-adapter-pattern.md +336 -336
- package/lib/assets/docs/article/functional-desgin-ppp/all/10-strategy-pattern.md +303 -303
- package/lib/assets/docs/article/functional-desgin-ppp/all/11-command-pattern.md +286 -286
- package/lib/assets/docs/article/functional-desgin-ppp/all/12-visitor-pattern.md +322 -322
- package/lib/assets/docs/article/functional-desgin-ppp/all/13-abstract-factory-pattern.md +319 -319
- package/lib/assets/docs/article/functional-desgin-ppp/all/14-abstract-server-pattern.md +365 -365
- package/lib/assets/docs/article/functional-desgin-ppp/all/15-gossiping-bus-drivers.md +156 -156
- package/lib/assets/docs/article/functional-desgin-ppp/all/16-payroll-system.md +178 -178
- package/lib/assets/docs/article/functional-desgin-ppp/all/17-video-rental-system.md +312 -312
- package/lib/assets/docs/article/functional-desgin-ppp/all/18-concurrency-system.md +287 -287
- package/lib/assets/docs/article/functional-desgin-ppp/all/19-wa-tor-simulation.md +286 -286
- package/lib/assets/docs/article/functional-desgin-ppp/all/20-pattern-interactions.md +274 -274
- package/lib/assets/docs/article/functional-desgin-ppp/all/21-best-practices.md +294 -294
- package/lib/assets/docs/article/functional-desgin-ppp/all/22-oo-to-fp-migration.md +337 -337
- package/lib/assets/docs/article/functional-desgin-ppp/all/index.md +388 -388
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/01-immutability-and-data-transformation.md +273 -273
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/02-function-composition.md +380 -380
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/03-polymorphism.md +384 -384
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/04-clojure-spec.md +350 -350
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/05-property-based-testing.md +352 -352
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/06-tdd-in-functional.md +383 -383
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/07-composite-pattern.md +529 -529
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/08-decorator-pattern.md +395 -395
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/09-adapter-pattern.md +399 -399
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/10-strategy-pattern.md +485 -485
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/11-command-pattern.md +566 -566
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/12-visitor-pattern.md +567 -567
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/13-abstract-factory-pattern.md +475 -475
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/14-abstract-server-pattern.md +462 -462
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/15-gossiping-bus-drivers.md +325 -325
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/16-payroll-system.md +401 -401
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/17-video-rental-system.md +450 -450
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/18-concurrency-system.md +475 -475
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/19-wator-simulation.md +739 -739
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/20-pattern-interactions.md +567 -567
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/21-best-practices.md +518 -518
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/22-oo-to-fp-migration.md +532 -532
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/index.md +241 -241
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/01-immutability-and-data-transformation.md +383 -383
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/02-function-composition.md +374 -374
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/03-polymorphism.md +375 -375
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/04-data-validation.md +195 -195
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/05-property-based-testing.md +268 -268
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/06-tdd-and-fp.md +294 -294
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/07-effects-and-pure-functions.md +164 -164
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/08-error-handling-strategies.md +168 -168
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/09-io-and-external-systems.md +254 -254
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/10-concurrency-patterns.md +269 -269
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/11-command-pattern.md +148 -148
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/12-visitor-pattern.md +176 -176
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/13-abstract-factory-pattern.md +604 -604
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/14-abstract-server-pattern.md +729 -729
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/15-gossiping-bus-drivers.md +291 -291
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/16-payroll-system.md +420 -420
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/17-video-rental-system.md +319 -319
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/18-concurrency-system.md +466 -466
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/19-wator-simulation.md +523 -523
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/20-pattern-interactions.md +287 -287
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/21-best-practices.md +340 -340
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/22-oo-to-fp-migration.md +395 -395
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/index.md +248 -248
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/01-immutability-and-data-transformation.md +384 -384
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/02-function-composition.md +452 -452
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/03-polymorphism.md +495 -495
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/04-data-validation.md +416 -416
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/05-property-based-testing.md +382 -382
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/06-tdd-functional.md +687 -687
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/07-composite-pattern.md +442 -442
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/08-decorator-pattern.md +479 -479
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/09-adapter-pattern.md +479 -479
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/10-strategy-pattern.md +427 -427
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/11-command-pattern.md +428 -428
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/12-visitor-pattern.md +339 -339
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/13-abstract-factory-pattern.md +309 -309
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/14-abstract-server-pattern.md +596 -596
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/15-gossiping-bus-drivers.md +355 -355
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/16-payroll-system.md +350 -350
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/17-video-rental-system.md +414 -414
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/18-concurrency-system.md +367 -367
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/19-wator-simulation.md +403 -403
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/20-pattern-interactions.md +291 -291
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/21-best-practices.md +324 -324
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/22-oo-to-fp-migration.md +332 -332
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/index.md +274 -274
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/01-immutability-and-data-transformation.md +298 -298
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/02-function-composition.md +304 -304
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/03-polymorphism.md +362 -362
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/04-data-validation.md +257 -257
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/05-property-based-testing.md +254 -254
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/06-tdd-functional.md +283 -283
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/07-composite-pattern.md +395 -395
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/08-decorator-pattern.md +319 -319
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/09-adapter-pattern.md +382 -382
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/10-strategy-pattern.md +287 -287
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/11-command-pattern.md +303 -303
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/12-visitor-pattern.md +326 -326
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/13-abstract-factory-pattern.md +332 -332
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/14-abstract-server-pattern.md +379 -379
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/15-gossiping-bus-drivers.md +177 -177
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/16-payroll-system.md +219 -219
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/17-video-rental-system.md +244 -244
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/18-concurrency-system.md +363 -363
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/19-wator-simulation.md +438 -438
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/20-pattern-interactions.md +325 -325
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/21-best-practices.md +403 -403
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/22-oo-to-fp-migration.md +469 -469
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/index.md +174 -174
- package/lib/assets/docs/article/functional-desgin-ppp/index.md +90 -90
- package/lib/assets/docs/article/functional-desgin-ppp/rust/01-immutability-and-data-transformation.md +450 -450
- package/lib/assets/docs/article/functional-desgin-ppp/rust/02-function-composition.md +463 -463
- package/lib/assets/docs/article/functional-desgin-ppp/rust/03-polymorphism.md +425 -425
- package/lib/assets/docs/article/functional-desgin-ppp/rust/04-data-validation.md +273 -273
- package/lib/assets/docs/article/functional-desgin-ppp/rust/05-property-based-testing.md +247 -247
- package/lib/assets/docs/article/functional-desgin-ppp/rust/06-tdd-and-functional.md +841 -841
- package/lib/assets/docs/article/functional-desgin-ppp/rust/07-composite-pattern.md +384 -384
- package/lib/assets/docs/article/functional-desgin-ppp/rust/08-decorator-pattern.md +383 -383
- package/lib/assets/docs/article/functional-desgin-ppp/rust/09-adapter-pattern.md +339 -339
- package/lib/assets/docs/article/functional-desgin-ppp/rust/10-strategy-pattern.md +331 -331
- package/lib/assets/docs/article/functional-desgin-ppp/rust/11-command-pattern.md +356 -356
- package/lib/assets/docs/article/functional-desgin-ppp/rust/12-visitor-pattern.md +379 -379
- package/lib/assets/docs/article/functional-desgin-ppp/rust/13-abstract-factory-pattern.md +361 -361
- package/lib/assets/docs/article/functional-desgin-ppp/rust/14-abstract-server-pattern.md +392 -392
- package/lib/assets/docs/article/functional-desgin-ppp/rust/15-gossiping-bus-drivers.md +300 -300
- package/lib/assets/docs/article/functional-desgin-ppp/rust/16-payroll-system.md +297 -297
- package/lib/assets/docs/article/functional-desgin-ppp/rust/17-video-rental-system.md +304 -304
- package/lib/assets/docs/article/functional-desgin-ppp/rust/18-concurrency-system.md +315 -315
- package/lib/assets/docs/article/functional-desgin-ppp/rust/19-wator-simulation.md +311 -311
- package/lib/assets/docs/article/functional-desgin-ppp/rust/20-pattern-interactions.md +304 -304
- package/lib/assets/docs/article/functional-desgin-ppp/rust/21-best-practices.md +336 -336
- package/lib/assets/docs/article/functional-desgin-ppp/rust/22-oo-to-fp-migration.md +349 -349
- package/lib/assets/docs/article/functional-desgin-ppp/rust/index.md +243 -243
- package/lib/assets/docs/article/functional-desgin-ppp/scala/01-immutability-and-data-transformation.md +328 -328
- package/lib/assets/docs/article/functional-desgin-ppp/scala/02-function-composition.md +348 -348
- package/lib/assets/docs/article/functional-desgin-ppp/scala/03-polymorphism.md +357 -357
- package/lib/assets/docs/article/functional-desgin-ppp/scala/04-data-validation.md +364 -364
- package/lib/assets/docs/article/functional-desgin-ppp/scala/05-property-based-testing.md +515 -515
- package/lib/assets/docs/article/functional-desgin-ppp/scala/06-tdd-functional.md +557 -557
- package/lib/assets/docs/article/functional-desgin-ppp/scala/07-composite-pattern.md +363 -363
- package/lib/assets/docs/article/functional-desgin-ppp/scala/08-decorator-pattern.md +327 -327
- package/lib/assets/docs/article/functional-desgin-ppp/scala/09-adapter-pattern.md +517 -517
- package/lib/assets/docs/article/functional-desgin-ppp/scala/10-strategy-pattern.md +441 -441
- package/lib/assets/docs/article/functional-desgin-ppp/scala/11-command-pattern.md +407 -407
- package/lib/assets/docs/article/functional-desgin-ppp/scala/12-visitor-pattern.md +379 -379
- package/lib/assets/docs/article/functional-desgin-ppp/scala/13-abstract-factory-pattern.md +398 -398
- package/lib/assets/docs/article/functional-desgin-ppp/scala/14-abstract-server-pattern.md +476 -476
- package/lib/assets/docs/article/functional-desgin-ppp/scala/15-gossiping-bus-drivers.md +391 -391
- package/lib/assets/docs/article/functional-desgin-ppp/scala/16-payroll-system.md +342 -342
- package/lib/assets/docs/article/functional-desgin-ppp/scala/17-video-rental-system.md +324 -324
- package/lib/assets/docs/article/functional-desgin-ppp/scala/18-concurrency-system.md +730 -730
- package/lib/assets/docs/article/functional-desgin-ppp/scala/19-wator-simulation.md +624 -624
- package/lib/assets/docs/article/functional-desgin-ppp/scala/20-pattern-interactions.md +512 -512
- package/lib/assets/docs/article/functional-desgin-ppp/scala/21-best-practices.md +433 -433
- package/lib/assets/docs/article/functional-desgin-ppp/scala/22-oo-to-fp-migration.md +688 -688
- package/lib/assets/docs/article/functional-desgin-ppp/scala/index.md +243 -243
- package/lib/assets/docs/article/getting-start-tdd/clojure/01-todo-list-and-first-test.md +166 -166
- package/lib/assets/docs/article/getting-start-tdd/clojure/02-fake-it-and-triangulation.md +162 -162
- package/lib/assets/docs/article/getting-start-tdd/clojure/03-obvious-implementation-and-refactoring.md +135 -135
- package/lib/assets/docs/article/getting-start-tdd/clojure/04-version-control-and-conventional-commits.md +88 -88
- package/lib/assets/docs/article/getting-start-tdd/clojure/05-package-management-and-static-analysis.md +299 -299
- package/lib/assets/docs/article/getting-start-tdd/clojure/06-task-runner-and-ci-cd.md +241 -241
- package/lib/assets/docs/article/getting-start-tdd/clojure/07-protocols-and-records.md +131 -131
- package/lib/assets/docs/article/getting-start-tdd/clojure/08-multimethods-and-design-patterns.md +130 -130
- package/lib/assets/docs/article/getting-start-tdd/clojure/09-namespaces-and-module-design.md +127 -127
- package/lib/assets/docs/article/getting-start-tdd/clojure/10-higher-order-functions-and-composition.md +114 -114
- package/lib/assets/docs/article/getting-start-tdd/clojure/11-persistent-data-and-pipeline.md +138 -138
- package/lib/assets/docs/article/getting-start-tdd/clojure/12-error-handling-and-spec.md +161 -161
- package/lib/assets/docs/article/getting-start-tdd/clojure/index.md +65 -65
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter01.md +232 -232
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter02.md +244 -244
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter03.md +202 -202
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter04.md +92 -92
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter05.md +256 -256
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter06.md +195 -195
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter07.md +214 -214
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter08.md +249 -249
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter09.md +174 -174
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter10.md +166 -166
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter11.md +192 -192
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter12.md +211 -211
- package/lib/assets/docs/article/getting-start-tdd/csharp/index.md +83 -83
- package/lib/assets/docs/article/getting-start-tdd/elixir/01-todo-list-and-first-test.md +87 -87
- package/lib/assets/docs/article/getting-start-tdd/elixir/02-fake-it-and-triangulation.md +95 -95
- package/lib/assets/docs/article/getting-start-tdd/elixir/03-obvious-implementation-and-refactoring.md +109 -109
- package/lib/assets/docs/article/getting-start-tdd/elixir/04-version-control-and-conventional-commits.md +96 -96
- package/lib/assets/docs/article/getting-start-tdd/elixir/05-package-management-and-static-analysis.md +88 -88
- package/lib/assets/docs/article/getting-start-tdd/elixir/06-task-runner-and-ci-cd.md +71 -71
- package/lib/assets/docs/article/getting-start-tdd/elixir/07-structs-and-protocols.md +110 -110
- package/lib/assets/docs/article/getting-start-tdd/elixir/08-pattern-matching-and-guards.md +108 -108
- package/lib/assets/docs/article/getting-start-tdd/elixir/09-module-design-and-behaviours.md +104 -104
- package/lib/assets/docs/article/getting-start-tdd/elixir/10-higher-order-functions-and-pipeline.md +178 -178
- package/lib/assets/docs/article/getting-start-tdd/elixir/11-stream-and-lazy-evaluation.md +142 -142
- package/lib/assets/docs/article/getting-start-tdd/elixir/12-error-handling-and-with.md +145 -145
- package/lib/assets/docs/article/getting-start-tdd/elixir/index.md +35 -35
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter01.md +202 -202
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter02.md +246 -246
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter03.md +218 -218
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter04.md +179 -179
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter05.md +267 -267
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter06.md +190 -190
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter07.md +161 -161
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter08.md +175 -175
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter09.md +222 -222
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter10.md +189 -189
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter11.md +212 -212
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter12.md +215 -215
- package/lib/assets/docs/article/getting-start-tdd/fsharp/index.md +71 -71
- package/lib/assets/docs/article/getting-start-tdd/go/01-todo-list-and-first-test.md +213 -213
- package/lib/assets/docs/article/getting-start-tdd/go/02-fake-it-and-triangulation.md +302 -302
- package/lib/assets/docs/article/getting-start-tdd/go/03-obvious-implementation-and-refactoring.md +339 -339
- package/lib/assets/docs/article/getting-start-tdd/go/04-version-control-and-conventional-commits.md +112 -112
- package/lib/assets/docs/article/getting-start-tdd/go/05-package-management-and-static-analysis.md +272 -272
- package/lib/assets/docs/article/getting-start-tdd/go/06-task-runner-and-ci-cd.md +233 -233
- package/lib/assets/docs/article/getting-start-tdd/go/07-encapsulation-and-polymorphism.md +394 -394
- package/lib/assets/docs/article/getting-start-tdd/go/08-design-patterns.md +422 -422
- package/lib/assets/docs/article/getting-start-tdd/go/09-solid-principles-and-module-design.md +400 -400
- package/lib/assets/docs/article/getting-start-tdd/go/10-higher-order-functions-and-composition.md +226 -226
- package/lib/assets/docs/article/getting-start-tdd/go/11-immutable-data-and-pipeline.md +296 -296
- package/lib/assets/docs/article/getting-start-tdd/go/12-error-handling-and-type-safety.md +411 -411
- package/lib/assets/docs/article/getting-start-tdd/go/index.md +83 -83
- package/lib/assets/docs/article/getting-start-tdd/haskell/01-todo-list-and-first-test.md +279 -279
- package/lib/assets/docs/article/getting-start-tdd/haskell/02-fake-it-and-triangulation.md +337 -337
- package/lib/assets/docs/article/getting-start-tdd/haskell/03-obvious-implementation-and-refactoring.md +257 -257
- package/lib/assets/docs/article/getting-start-tdd/haskell/04-version-control-and-conventional-commits.md +182 -182
- package/lib/assets/docs/article/getting-start-tdd/haskell/05-package-management-and-static-analysis.md +313 -313
- package/lib/assets/docs/article/getting-start-tdd/haskell/06-task-runner-and-ci-cd.md +309 -309
- package/lib/assets/docs/article/getting-start-tdd/haskell/07-algebraic-data-types-and-type-classes.md +412 -412
- package/lib/assets/docs/article/getting-start-tdd/haskell/08-pattern-matching-and-guards.md +390 -390
- package/lib/assets/docs/article/getting-start-tdd/haskell/09-module-design-and-smart-constructors.md +461 -461
- package/lib/assets/docs/article/getting-start-tdd/haskell/10-higher-order-functions-and-currying.md +434 -434
- package/lib/assets/docs/article/getting-start-tdd/haskell/11-function-composition-and-point-free.md +392 -392
- package/lib/assets/docs/article/getting-start-tdd/haskell/12-monad-and-error-handling.md +631 -631
- package/lib/assets/docs/article/getting-start-tdd/haskell/index.md +49 -49
- package/lib/assets/docs/article/getting-start-tdd/index.md +93 -93
- package/lib/assets/docs/article/getting-start-tdd/integration/01-language-overview.md +375 -375
- package/lib/assets/docs/article/getting-start-tdd/integration/02-test-framework-comparison.md +349 -349
- package/lib/assets/docs/article/getting-start-tdd/integration/03-tdd-pattern-comparison.md +445 -445
- package/lib/assets/docs/article/getting-start-tdd/integration/04-type-system-comparison.md +409 -409
- package/lib/assets/docs/article/getting-start-tdd/integration/05-dev-environment-comparison.md +330 -330
- package/lib/assets/docs/article/getting-start-tdd/integration/06-learning-roadmap.md +290 -290
- package/lib/assets/docs/article/getting-start-tdd/integration/index.md +69 -69
- package/lib/assets/docs/article/getting-start-tdd/java/01-todo-list-and-first-test.md +234 -234
- package/lib/assets/docs/article/getting-start-tdd/java/02-fake-it-and-triangulation.md +261 -261
- package/lib/assets/docs/article/getting-start-tdd/java/03-obvious-implementation-and-refactoring.md +185 -185
- package/lib/assets/docs/article/getting-start-tdd/java/04-version-control-and-conventional-commits.md +115 -115
- package/lib/assets/docs/article/getting-start-tdd/java/05-package-management-and-static-analysis.md +382 -382
- package/lib/assets/docs/article/getting-start-tdd/java/06-task-runner-and-ci-cd.md +272 -272
- package/lib/assets/docs/article/getting-start-tdd/java/07-encapsulation-and-polymorphism.md +626 -626
- package/lib/assets/docs/article/getting-start-tdd/java/08-design-patterns.md +393 -393
- package/lib/assets/docs/article/getting-start-tdd/java/09-solid-principles-and-module-design.md +310 -310
- package/lib/assets/docs/article/getting-start-tdd/java/10-higher-order-functions-and-composition.md +188 -188
- package/lib/assets/docs/article/getting-start-tdd/java/11-immutable-data-and-pipeline.md +167 -167
- package/lib/assets/docs/article/getting-start-tdd/java/12-error-handling-and-type-safety.md +205 -205
- package/lib/assets/docs/article/getting-start-tdd/java/index.md +61 -61
- package/lib/assets/docs/article/getting-start-tdd/node/01-todo-list-and-first-test.md +244 -244
- package/lib/assets/docs/article/getting-start-tdd/node/02-fake-it-and-triangulation.md +262 -262
- package/lib/assets/docs/article/getting-start-tdd/node/03-obvious-implementation-and-refactoring.md +169 -169
- package/lib/assets/docs/article/getting-start-tdd/node/04-version-control-and-conventional-commits.md +112 -112
- package/lib/assets/docs/article/getting-start-tdd/node/05-package-management-and-static-analysis.md +314 -314
- package/lib/assets/docs/article/getting-start-tdd/node/06-task-runner-and-ci-cd.md +235 -235
- package/lib/assets/docs/article/getting-start-tdd/node/07-encapsulation-and-polymorphism.md +327 -327
- package/lib/assets/docs/article/getting-start-tdd/node/08-design-patterns.md +322 -322
- package/lib/assets/docs/article/getting-start-tdd/node/09-solid-principles-and-module-design.md +285 -285
- package/lib/assets/docs/article/getting-start-tdd/node/10-higher-order-functions-and-composition.md +199 -199
- package/lib/assets/docs/article/getting-start-tdd/node/11-immutable-data-and-pipeline.md +207 -207
- package/lib/assets/docs/article/getting-start-tdd/node/12-error-handling-and-type-safety.md +295 -295
- package/lib/assets/docs/article/getting-start-tdd/node/index.md +56 -56
- package/lib/assets/docs/article/getting-start-tdd/php/01-todo-list-and-first-test.md +259 -259
- package/lib/assets/docs/article/getting-start-tdd/php/02-fake-it-and-triangulation.md +200 -200
- package/lib/assets/docs/article/getting-start-tdd/php/03-obvious-implementation-and-refactoring.md +248 -248
- package/lib/assets/docs/article/getting-start-tdd/php/04-version-control-and-conventional-commits.md +141 -141
- package/lib/assets/docs/article/getting-start-tdd/php/05-package-management-and-static-analysis.md +410 -410
- package/lib/assets/docs/article/getting-start-tdd/php/06-task-runner-and-ci-cd.md +321 -321
- package/lib/assets/docs/article/getting-start-tdd/php/07-encapsulation-and-polymorphism.md +372 -372
- package/lib/assets/docs/article/getting-start-tdd/php/08-design-patterns.md +453 -453
- package/lib/assets/docs/article/getting-start-tdd/php/09-solid-principles-and-module-design.md +460 -460
- package/lib/assets/docs/article/getting-start-tdd/php/10-higher-order-functions-and-composition.md +182 -182
- package/lib/assets/docs/article/getting-start-tdd/php/11-immutable-data-and-pipeline.md +266 -266
- package/lib/assets/docs/article/getting-start-tdd/php/12-error-handling-and-type-safety.md +308 -308
- package/lib/assets/docs/article/getting-start-tdd/php/index.md +84 -84
- package/lib/assets/docs/article/getting-start-tdd/python/01-todo-list-and-first-test.md +201 -201
- package/lib/assets/docs/article/getting-start-tdd/python/02-fake-it-and-triangulation.md +247 -247
- package/lib/assets/docs/article/getting-start-tdd/python/03-obvious-implementation-and-refactoring.md +199 -199
- package/lib/assets/docs/article/getting-start-tdd/python/04-version-control-and-conventional-commits.md +87 -87
- package/lib/assets/docs/article/getting-start-tdd/python/05-package-management-and-static-analysis.md +274 -274
- package/lib/assets/docs/article/getting-start-tdd/python/06-task-runner-and-ci-cd.md +190 -190
- package/lib/assets/docs/article/getting-start-tdd/python/07-encapsulation-and-polymorphism.md +208 -208
- package/lib/assets/docs/article/getting-start-tdd/python/08-design-patterns.md +172 -172
- package/lib/assets/docs/article/getting-start-tdd/python/09-solid-principles-and-module-design.md +130 -130
- package/lib/assets/docs/article/getting-start-tdd/python/10-higher-order-functions-and-composition.md +122 -122
- package/lib/assets/docs/article/getting-start-tdd/python/11-immutable-data-and-pipeline.md +116 -116
- package/lib/assets/docs/article/getting-start-tdd/python/12-error-handling-and-type-safety.md +126 -126
- package/lib/assets/docs/article/getting-start-tdd/python/index.md +55 -55
- package/lib/assets/docs/article/getting-start-tdd/ruby/01-todo-list-and-first-test.md +231 -231
- package/lib/assets/docs/article/getting-start-tdd/ruby/02-fake-it-and-triangulation.md +238 -238
- package/lib/assets/docs/article/getting-start-tdd/ruby/03-obvious-implementation-and-refactoring.md +228 -228
- package/lib/assets/docs/article/getting-start-tdd/ruby/04-version-control-and-conventional-commits.md +112 -112
- package/lib/assets/docs/article/getting-start-tdd/ruby/05-package-management-and-static-analysis.md +287 -287
- package/lib/assets/docs/article/getting-start-tdd/ruby/06-task-runner-and-ci-cd.md +248 -248
- package/lib/assets/docs/article/getting-start-tdd/ruby/07-encapsulation-and-polymorphism.md +279 -279
- package/lib/assets/docs/article/getting-start-tdd/ruby/08-design-patterns.md +329 -329
- package/lib/assets/docs/article/getting-start-tdd/ruby/09-solid-principles-and-module-design.md +196 -196
- package/lib/assets/docs/article/getting-start-tdd/ruby/10-higher-order-functions-and-composition.md +175 -175
- package/lib/assets/docs/article/getting-start-tdd/ruby/11-immutable-data-and-pipeline.md +237 -237
- package/lib/assets/docs/article/getting-start-tdd/ruby/12-error-handling-and-type-safety.md +398 -398
- package/lib/assets/docs/article/getting-start-tdd/ruby/index.md +83 -83
- package/lib/assets/docs/article/getting-start-tdd/rust/01-todo-list-and-first-test.md +211 -211
- package/lib/assets/docs/article/getting-start-tdd/rust/02-fake-it-and-triangulation.md +264 -264
- package/lib/assets/docs/article/getting-start-tdd/rust/03-obvious-implementation-and-refactoring.md +233 -233
- package/lib/assets/docs/article/getting-start-tdd/rust/04-version-control-and-conventional-commits.md +92 -92
- package/lib/assets/docs/article/getting-start-tdd/rust/05-package-management-and-static-analysis.md +212 -212
- package/lib/assets/docs/article/getting-start-tdd/rust/06-task-runner-and-ci-cd.md +164 -164
- package/lib/assets/docs/article/getting-start-tdd/rust/07-encapsulation-and-polymorphism.md +142 -142
- package/lib/assets/docs/article/getting-start-tdd/rust/08-design-patterns.md +145 -145
- package/lib/assets/docs/article/getting-start-tdd/rust/09-solid-principles-and-module-design.md +110 -110
- package/lib/assets/docs/article/getting-start-tdd/rust/10-higher-order-functions-and-composition.md +94 -94
- package/lib/assets/docs/article/getting-start-tdd/rust/11-immutable-data-and-pipeline.md +105 -105
- package/lib/assets/docs/article/getting-start-tdd/rust/12-error-handling-and-type-safety.md +112 -112
- package/lib/assets/docs/article/getting-start-tdd/rust/index.md +83 -83
- package/lib/assets/docs/article/getting-start-tdd/scala/01-todo-list-and-first-test.md +111 -111
- package/lib/assets/docs/article/getting-start-tdd/scala/02-fake-it-and-triangulation.md +107 -107
- package/lib/assets/docs/article/getting-start-tdd/scala/03-obvious-implementation-and-refactoring.md +99 -99
- package/lib/assets/docs/article/getting-start-tdd/scala/04-version-control-and-conventional-commits.md +123 -123
- package/lib/assets/docs/article/getting-start-tdd/scala/05-package-management-and-static-analysis.md +196 -196
- package/lib/assets/docs/article/getting-start-tdd/scala/06-task-runner-and-ci-cd.md +186 -186
- package/lib/assets/docs/article/getting-start-tdd/scala/07-case-classes-and-traits.md +139 -139
- package/lib/assets/docs/article/getting-start-tdd/scala/08-pattern-matching-and-sealed-traits.md +106 -106
- package/lib/assets/docs/article/getting-start-tdd/scala/09-packages-and-module-design.md +75 -75
- package/lib/assets/docs/article/getting-start-tdd/scala/10-higher-order-functions-and-composition.md +104 -104
- package/lib/assets/docs/article/getting-start-tdd/scala/11-collections-and-lazy-evaluation.md +94 -94
- package/lib/assets/docs/article/getting-start-tdd/scala/12-error-handling-and-type-safety.md +92 -92
- package/lib/assets/docs/article/getting-start-tdd/scala/index.md +65 -65
- package/lib/assets/docs/article/grokking-concurrency/all/index.md +404 -404
- package/lib/assets/docs/article/grokking-concurrency/all/part-1-ch02-sequential.md +554 -554
- package/lib/assets/docs/article/grokking-concurrency/all/part-2-ch04-05-threads.md +469 -469
- package/lib/assets/docs/article/grokking-concurrency/all/part-3-ch06-multitasking.md +520 -520
- package/lib/assets/docs/article/grokking-concurrency/all/part-4-ch07-parallel-patterns.md +420 -420
- package/lib/assets/docs/article/grokking-concurrency/all/part-5-ch08-09-synchronization.md +510 -510
- package/lib/assets/docs/article/grokking-concurrency/all/part-6-ch10-11-nonblocking-io.md +435 -435
- package/lib/assets/docs/article/grokking-concurrency/all/part-7-ch12-async.md +465 -465
- package/lib/assets/docs/article/grokking-concurrency/all/part-8-ch13-mapreduce.md +377 -377
- package/lib/assets/docs/article/grokking-concurrency/clojure/index.md +116 -116
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-1.md +108 -108
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-2.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-3.md +122 -122
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-4.md +123 -123
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-5.md +118 -118
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-6.md +89 -89
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-7.md +100 -100
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-8.md +120 -120
- package/lib/assets/docs/article/grokking-concurrency/csharp/index.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-1.md +97 -97
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-2.md +123 -123
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-3.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-4.md +112 -112
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-5.md +99 -99
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-6.md +61 -61
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-7.md +84 -84
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-8.md +92 -92
- package/lib/assets/docs/article/grokking-concurrency/fsharp/index.md +65 -65
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-1.md +80 -80
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-2.md +103 -103
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-3.md +94 -94
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-4.md +110 -110
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-5.md +104 -104
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-6.md +93 -93
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-7.md +121 -121
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-8.md +107 -107
- package/lib/assets/docs/article/grokking-concurrency/haskell/index.md +248 -248
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-1.md +96 -96
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-2.md +96 -96
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-3.md +91 -91
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-4.md +106 -106
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-5.md +99 -99
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-6.md +95 -95
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-7.md +111 -111
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-8.md +118 -118
- package/lib/assets/docs/article/grokking-concurrency/index.md +66 -66
- package/lib/assets/docs/article/grokking-concurrency/java/index.md +102 -102
- package/lib/assets/docs/article/grokking-concurrency/java/part-1.md +308 -308
- package/lib/assets/docs/article/grokking-concurrency/java/part-2.md +334 -334
- package/lib/assets/docs/article/grokking-concurrency/java/part-3.md +221 -221
- package/lib/assets/docs/article/grokking-concurrency/java/part-4.md +213 -213
- package/lib/assets/docs/article/grokking-concurrency/java/part-5.md +112 -112
- package/lib/assets/docs/article/grokking-concurrency/java/part-6.md +69 -69
- package/lib/assets/docs/article/grokking-concurrency/java/part-7.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/java/part-8.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/python/index.md +313 -313
- package/lib/assets/docs/article/grokking-concurrency/python/part-1.md +239 -239
- package/lib/assets/docs/article/grokking-concurrency/python/part-2.md +418 -418
- package/lib/assets/docs/article/grokking-concurrency/python/part-3.md +227 -227
- package/lib/assets/docs/article/grokking-concurrency/python/part-4.md +299 -299
- package/lib/assets/docs/article/grokking-concurrency/python/part-5.md +315 -315
- package/lib/assets/docs/article/grokking-concurrency/python/part-6.md +297 -297
- package/lib/assets/docs/article/grokking-concurrency/python/part-7.md +314 -314
- package/lib/assets/docs/article/grokking-concurrency/python/part-8.md +360 -360
- package/lib/assets/docs/article/grokking-concurrency/rust/index.md +270 -270
- package/lib/assets/docs/article/grokking-concurrency/rust/part-1.md +108 -108
- package/lib/assets/docs/article/grokking-concurrency/rust/part-2.md +120 -120
- package/lib/assets/docs/article/grokking-concurrency/rust/part-3.md +126 -126
- package/lib/assets/docs/article/grokking-concurrency/rust/part-4.md +175 -175
- package/lib/assets/docs/article/grokking-concurrency/rust/part-5.md +158 -158
- package/lib/assets/docs/article/grokking-concurrency/rust/part-6.md +94 -94
- package/lib/assets/docs/article/grokking-concurrency/rust/part-7.md +133 -133
- package/lib/assets/docs/article/grokking-concurrency/rust/part-8.md +155 -155
- package/lib/assets/docs/article/grokking-concurrency/scala/index.md +69 -69
- package/lib/assets/docs/article/grokking-concurrency/scala/part-1.md +78 -78
- package/lib/assets/docs/article/grokking-concurrency/scala/part-2.md +112 -112
- package/lib/assets/docs/article/grokking-concurrency/scala/part-3.md +93 -93
- package/lib/assets/docs/article/grokking-concurrency/scala/part-4.md +110 -110
- package/lib/assets/docs/article/grokking-concurrency/scala/part-5.md +119 -119
- package/lib/assets/docs/article/grokking-concurrency/scala/part-6.md +83 -83
- package/lib/assets/docs/article/grokking-concurrency/scala/part-7.md +131 -131
- package/lib/assets/docs/article/grokking-concurrency/scala/part-8.md +129 -129
- package/lib/assets/docs/article/grokkingfp/all/index.md +368 -368
- package/lib/assets/docs/article/grokkingfp/all/part-1-ch01-fp-introduction.md +530 -530
- package/lib/assets/docs/article/grokkingfp/all/part-1-ch02-pure-functions.md +923 -923
- package/lib/assets/docs/article/grokkingfp/all/part-2-ch03-immutable-data.md +1128 -1128
- package/lib/assets/docs/article/grokkingfp/all/part-2-ch04-higher-order-functions.md +1104 -1104
- package/lib/assets/docs/article/grokkingfp/all/part-2-ch05-flatmap.md +1026 -1026
- package/lib/assets/docs/article/grokkingfp/all/part-3-ch06-option.md +785 -785
- package/lib/assets/docs/article/grokkingfp/all/part-3-ch07-either-adt.md +871 -871
- package/lib/assets/docs/article/grokkingfp/all/part-4-ch08-io-monad.md +972 -972
- package/lib/assets/docs/article/grokkingfp/all/part-4-ch09-streams.md +926 -926
- package/lib/assets/docs/article/grokkingfp/all/part-5-ch10-concurrency.md +870 -870
- package/lib/assets/docs/article/grokkingfp/all/part-6-ch11-application.md +715 -715
- package/lib/assets/docs/article/grokkingfp/all/part-6-ch12-testing.md +626 -626
- package/lib/assets/docs/article/grokkingfp/all/writing-plan.md +712 -712
- package/lib/assets/docs/article/grokkingfp/clojure/index.md +276 -276
- package/lib/assets/docs/article/grokkingfp/clojure/part-1.md +667 -667
- package/lib/assets/docs/article/grokkingfp/clojure/part-2.md +643 -643
- package/lib/assets/docs/article/grokkingfp/clojure/part-3.md +620 -620
- package/lib/assets/docs/article/grokkingfp/clojure/part-4.md +697 -697
- package/lib/assets/docs/article/grokkingfp/clojure/part-5.md +751 -751
- package/lib/assets/docs/article/grokkingfp/clojure/part-6.md +721 -721
- package/lib/assets/docs/article/grokkingfp/csharp/index.md +246 -246
- package/lib/assets/docs/article/grokkingfp/csharp/part-1.md +811 -811
- package/lib/assets/docs/article/grokkingfp/csharp/part-2.md +971 -971
- package/lib/assets/docs/article/grokkingfp/csharp/part-3.md +981 -981
- package/lib/assets/docs/article/grokkingfp/csharp/part-4.md +949 -949
- package/lib/assets/docs/article/grokkingfp/csharp/part-5.md +947 -947
- package/lib/assets/docs/article/grokkingfp/csharp/part-6.md +739 -739
- package/lib/assets/docs/article/grokkingfp/elixir/index.md +203 -203
- package/lib/assets/docs/article/grokkingfp/elixir/part-1.md +712 -712
- package/lib/assets/docs/article/grokkingfp/elixir/part-2.md +838 -838
- package/lib/assets/docs/article/grokkingfp/elixir/part-3.md +985 -985
- package/lib/assets/docs/article/grokkingfp/elixir/part-4.md +974 -974
- package/lib/assets/docs/article/grokkingfp/elixir/part-5.md +1286 -1286
- package/lib/assets/docs/article/grokkingfp/elixir/part-6.md +1049 -1049
- package/lib/assets/docs/article/grokkingfp/fsharp/index.md +210 -210
- package/lib/assets/docs/article/grokkingfp/fsharp/part-1.md +714 -714
- package/lib/assets/docs/article/grokkingfp/fsharp/part-2.md +961 -961
- package/lib/assets/docs/article/grokkingfp/fsharp/part-3.md +972 -972
- package/lib/assets/docs/article/grokkingfp/fsharp/part-4.md +832 -832
- package/lib/assets/docs/article/grokkingfp/fsharp/part-5.md +911 -911
- package/lib/assets/docs/article/grokkingfp/fsharp/part-6.md +922 -922
- package/lib/assets/docs/article/grokkingfp/haskell/index.md +234 -234
- package/lib/assets/docs/article/grokkingfp/haskell/part-1.md +591 -591
- package/lib/assets/docs/article/grokkingfp/haskell/part-2.md +866 -866
- package/lib/assets/docs/article/grokkingfp/haskell/part-3.md +915 -915
- package/lib/assets/docs/article/grokkingfp/haskell/part-4.md +878 -878
- package/lib/assets/docs/article/grokkingfp/haskell/part-5.md +845 -845
- package/lib/assets/docs/article/grokkingfp/haskell/part-6.md +844 -844
- package/lib/assets/docs/article/grokkingfp/index.md +143 -143
- package/lib/assets/docs/article/grokkingfp/java/index.md +211 -211
- package/lib/assets/docs/article/grokkingfp/java/part-1.md +648 -648
- package/lib/assets/docs/article/grokkingfp/java/part-2.md +675 -675
- package/lib/assets/docs/article/grokkingfp/java/part-3.md +672 -672
- package/lib/assets/docs/article/grokkingfp/java/part-4.md +771 -771
- package/lib/assets/docs/article/grokkingfp/java/part-5.md +959 -959
- package/lib/assets/docs/article/grokkingfp/java/part-6.md +1328 -1328
- package/lib/assets/docs/article/grokkingfp/python/index.md +258 -258
- package/lib/assets/docs/article/grokkingfp/python/part-1.md +443 -443
- package/lib/assets/docs/article/grokkingfp/python/part-2.md +958 -958
- package/lib/assets/docs/article/grokkingfp/python/part-3.md +1004 -1004
- package/lib/assets/docs/article/grokkingfp/python/part-4.md +765 -765
- package/lib/assets/docs/article/grokkingfp/python/part-5.md +747 -747
- package/lib/assets/docs/article/grokkingfp/python/part-6.md +861 -861
- package/lib/assets/docs/article/grokkingfp/ruby/index.md +330 -330
- package/lib/assets/docs/article/grokkingfp/ruby/part-1.md +755 -755
- package/lib/assets/docs/article/grokkingfp/ruby/part-2.md +938 -938
- package/lib/assets/docs/article/grokkingfp/ruby/part-3.md +946 -946
- package/lib/assets/docs/article/grokkingfp/ruby/part-4.md +921 -921
- package/lib/assets/docs/article/grokkingfp/ruby/part-5.md +908 -908
- package/lib/assets/docs/article/grokkingfp/ruby/part-6.md +1412 -1412
- package/lib/assets/docs/article/grokkingfp/rust/index.md +242 -242
- package/lib/assets/docs/article/grokkingfp/rust/part-1.md +634 -634
- package/lib/assets/docs/article/grokkingfp/rust/part-2.md +1060 -1060
- package/lib/assets/docs/article/grokkingfp/rust/part-3.md +994 -994
- package/lib/assets/docs/article/grokkingfp/rust/part-4.md +573 -573
- package/lib/assets/docs/article/grokkingfp/rust/part-5.md +705 -705
- package/lib/assets/docs/article/grokkingfp/rust/part-6.md +508 -508
- package/lib/assets/docs/article/grokkingfp/scala/index.md +171 -171
- package/lib/assets/docs/article/grokkingfp/scala/part-1.md +543 -543
- package/lib/assets/docs/article/grokkingfp/scala/part-2.md +946 -946
- package/lib/assets/docs/article/grokkingfp/scala/part-3.md +919 -919
- package/lib/assets/docs/article/grokkingfp/scala/part-4.md +742 -742
- package/lib/assets/docs/article/grokkingfp/scala/part-5.md +722 -722
- package/lib/assets/docs/article/grokkingfp/scala/part-6.md +867 -867
- package/lib/assets/docs/article/grokkingfp/typescript/index.md +273 -273
- package/lib/assets/docs/article/grokkingfp/typescript/part-1.md +561 -561
- package/lib/assets/docs/article/grokkingfp/typescript/part-2.md +1129 -1129
- package/lib/assets/docs/article/grokkingfp/typescript/part-3.md +842 -842
- package/lib/assets/docs/article/grokkingfp/typescript/part-4.md +1087 -1087
- package/lib/assets/docs/article/grokkingfp/typescript/part-5.md +717 -717
- package/lib/assets/docs/article/grokkingfp/typescript/part-6.md +982 -982
- package/lib/assets/docs/article/practical-database-design/index.md +121 -121
- package/lib/assets/docs/article/practical-database-design/part1/chapter01.md +288 -288
- package/lib/assets/docs/article/practical-database-design/part1/chapter02.md +518 -518
- package/lib/assets/docs/article/practical-database-design/part1/chapter03.md +557 -557
- package/lib/assets/docs/article/practical-database-design/part2/chapter04.md +924 -924
- package/lib/assets/docs/article/practical-database-design/part2/chapter05.md +1627 -1627
- package/lib/assets/docs/article/practical-database-design/part2/chapter06.md +2716 -2716
- package/lib/assets/docs/article/practical-database-design/part2/chapter07.md +2082 -2082
- package/lib/assets/docs/article/practical-database-design/part2/chapter08.md +2105 -2105
- package/lib/assets/docs/article/practical-database-design/part2/chapter09.md +2031 -2031
- package/lib/assets/docs/article/practical-database-design/part2/chapter10.md +1387 -1387
- package/lib/assets/docs/article/practical-database-design/part2/chapter11.md +1677 -1677
- package/lib/assets/docs/article/practical-database-design/part2/chapter12.md +1417 -1417
- package/lib/assets/docs/article/practical-database-design/part2/chapter13.md +1434 -1434
- package/lib/assets/docs/article/practical-database-design/part3/chapter14.md +667 -667
- package/lib/assets/docs/article/practical-database-design/part3/chapter15.md +1625 -1625
- package/lib/assets/docs/article/practical-database-design/part3/chapter16.md +1915 -1915
- package/lib/assets/docs/article/practical-database-design/part3/chapter17.md +1708 -1708
- package/lib/assets/docs/article/practical-database-design/part3/chapter18.md +2095 -2095
- package/lib/assets/docs/article/practical-database-design/part3/chapter19.md +1123 -1123
- package/lib/assets/docs/article/practical-database-design/part3/chapter20.md +1031 -1031
- package/lib/assets/docs/article/practical-database-design/part3/chapter21.md +1382 -1382
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter14-orm.md +991 -991
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter15-orm.md +1300 -1300
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter16-orm.md +1166 -1166
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter17-orm.md +1584 -1584
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter18-orm.md +1183 -1183
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter19-orm.md +1016 -1016
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter20-orm.md +1753 -1753
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter21-orm.md +1447 -1447
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter22-orm.md +1878 -1878
- package/lib/assets/docs/article/practical-database-design/part4/chapter22.md +965 -965
- package/lib/assets/docs/article/practical-database-design/part4/chapter23.md +2069 -2069
- package/lib/assets/docs/article/practical-database-design/part4/chapter24.md +2439 -2439
- package/lib/assets/docs/article/practical-database-design/part4/chapter25.md +3661 -3661
- package/lib/assets/docs/article/practical-database-design/part4/chapter26.md +2916 -2916
- package/lib/assets/docs/article/practical-database-design/part4/chapter27.md +3105 -3105
- package/lib/assets/docs/article/practical-database-design/part4/chapter28.md +2697 -2697
- package/lib/assets/docs/article/practical-database-design/part4/chapter29.md +2544 -2544
- package/lib/assets/docs/article/practical-database-design/part4/chapter30.md +2180 -2180
- package/lib/assets/docs/article/practical-database-design/part4/chapter31.md +1192 -1192
- package/lib/assets/docs/article/practical-database-design/part4/chapter32.md +2101 -2101
- package/lib/assets/docs/article/practical-database-design/part5/chapter33.md +1032 -1032
- package/lib/assets/docs/article/practical-database-design/part5/chapter34.md +1609 -1609
- package/lib/assets/docs/article/practical-database-design/part5/chapter35.md +1453 -1453
- package/lib/assets/docs/article/practical-database-design/part5/chapter36.md +1292 -1292
- package/lib/assets/docs/article/practical-database-design/part5/chapter37.md +1470 -1470
- package/lib/assets/docs/article/practical-database-design/part5/chapter38.md +1698 -1698
- package/lib/assets/docs/article/practical-database-design/part5/chapter39.md +2334 -2334
- package/lib/assets/docs/article/practical-database-design/study/study2-1.md +1693 -1693
- package/lib/assets/docs/article/practical-database-design/study/study2-2.md +1347 -1347
- package/lib/assets/docs/article/practical-database-design/study/study2-3.md +2044 -2044
- package/lib/assets/docs/article/practical-database-design/study/study2-4.md +2229 -2229
- package/lib/assets/docs/article/practical-database-design/study/study2-5.md +2418 -2418
- package/lib/assets/docs/article/practical-database-design/study/study3-1.md +2205 -2205
- package/lib/assets/docs/article/practical-database-design/study/study3-2.md +2221 -2221
- package/lib/assets/docs/article/practical-database-design/study/study3-3.md +2253 -2253
- package/lib/assets/docs/article/practical-database-design/study/study3-4.md +2106 -2106
- package/lib/assets/docs/article/practical-database-design/study/study3-5.md +2507 -2507
- package/lib/assets/docs/article/practical-database-design/study/study4-1.md +2587 -2587
- package/lib/assets/docs/article/practical-database-design/study/study4-2.md +2075 -2075
- package/lib/assets/docs/article/practical-database-design/study/study4-3.md +1805 -1805
- package/lib/assets/docs/article/practical-database-design/study/study4-4.md +1895 -1895
- package/lib/assets/docs/article/practical-database-design/study/study4-5.md +2878 -2878
- package/lib/assets/docs/assets/css/extra.css +29 -29
- package/lib/assets/docs/assets/js/extra.js +44 -44
- package/lib/assets/docs/development/index.md +39 -39
- package/lib/assets/docs/operation/index.md +11 -11
- package/lib/assets/docs/reference/CodexCLIMCP/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/351/226/213/347/231/272/343/203/225/343/203/255/343/203/274.md +532 -532
- package/lib/assets/docs/reference/CodexCLIMCP/343/202/265/343/203/274/343/203/220/343/203/274/350/250/255/345/256/232/346/211/213/351/240/206.md +341 -341
- package/lib/assets/docs/reference/Java/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/346/247/213/347/257/211/343/202/254/343/202/244/343/203/211.md +581 -581
- package/lib/assets/docs/reference/SonarQube/343/203/255/343/203/274/343/202/253/343/203/253/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +642 -642
- package/lib/assets/docs/reference/TypeScript/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/346/247/213/347/257/211/343/202/254/343/202/244/343/203/211.md +465 -465
- package/lib/assets/docs/reference/UI/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +450 -450
- package/lib/assets/docs/reference/images/Ansoff.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BrandBasicStrategy.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BrandCategorization.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BrandRecurutementStrategy.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BrandValue.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BusinessActivitiy.svg +3 -3
- package/lib/assets/docs/reference/images/HRM.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/MarketingStructure.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/OrganizationElemnts.svg +3 -3
- package/lib/assets/docs/reference/images/PPM.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/PositioningMap.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/ProductLayer.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/ProductMix.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/SWOT.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/TargetMarket.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/ThreeGenericStrategies.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/VRIO.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/ValueChain.drawio.svg +3 -3
- package/lib/assets/docs/reference/index.md +52 -52
- package/lib/assets/docs/reference//343/202/210/343/201/204/343/202/275/343/203/225/343/203/210/343/202/246/343/202/247/343/202/242/343/201/250/343/201/257.md +250 -250
- package/lib/assets/docs/reference//343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +2216 -2216
- package/lib/assets/docs/reference//343/202/244/343/203/263/343/203/225/343/203/251/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +1878 -1878
- package/lib/assets/docs/reference//343/202/250/343/202/257/343/202/271/343/203/210/343/203/252/343/203/274/343/203/240/343/203/227/343/203/255/343/202/260/343/203/251/343/203/237/343/203/263/343/202/260.md +550 -550
- package/lib/assets/docs/reference//343/202/263/343/203/274/343/203/207/343/202/243/343/203/263/343/202/260/343/201/250/343/203/206/343/202/271/343/203/210/343/202/254/343/202/244/343/203/211.md +705 -705
- package/lib/assets/docs/reference//343/203/206/343/202/271/343/203/210/346/210/246/347/225/245/343/202/254/343/202/244/343/203/211.md +1313 -1313
- package/lib/assets/docs/reference//343/203/207/343/203/274/343/202/277/343/203/242/343/203/207/343/203/253/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +311 -311
- package/lib/assets/docs/reference//343/203/211/343/203/241/343/202/244/343/203/263/343/203/242/343/203/207/343/203/253/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +599 -599
- package/lib/assets/docs/reference//343/203/223/343/202/270/343/203/215/343/202/271/343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243/345/210/206/346/236/220/343/202/254/343/202/244/343/203/211.md +528 -528
- package/lib/assets/docs/reference//343/203/246/343/203/274/343/202/271/343/202/261/343/203/274/343/202/271/344/275/234/346/210/220/343/202/254/343/202/244/343/203/211.md +689 -689
- package/lib/assets/docs/reference//343/203/252/343/203/252/343/203/274/343/202/271/343/202/254/343/202/244/343/203/211.md +461 -461
- package/lib/assets/docs/reference//343/203/252/343/203/252/343/203/274/343/202/271/343/203/273/343/202/244/343/203/206/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263/350/250/210/347/224/273/343/202/254/343/202/244/343/203/211.md +580 -580
- package/lib/assets/docs/reference//343/203/255/343/202/270/343/202/253/343/203/253/343/202/267/343/203/263/343/202/255/343/203/263/343/202/260.md +1367 -1367
- package/lib/assets/docs/reference//344/274/201/346/245/255/347/265/214/345/226/266/350/253/226.md +2637 -2637
- package/lib/assets/docs/reference//347/222/260/345/242/203/345/244/211/346/225/260/347/256/241/347/220/206/343/202/254/343/202/244/343/203/211.md +665 -665
- package/lib/assets/docs/reference//350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +1248 -1248
- package/lib/assets/docs/reference//350/250/200/350/252/236/345/210/245/351/226/213/347/231/272/343/202/254/343/202/244/343/203/211.md +518 -518
- package/lib/assets/docs/reference//351/201/213/345/226/266/347/256/241/347/220/206.md +1482 -1482
- package/lib/assets/docs/reference//351/201/213/347/224/250/343/202/271/343/202/257/343/203/252/343/203/227/343/203/210/344/275/234/346/210/220/343/202/254/343/202/244/343/203/211.md +421 -421
- package/lib/assets/docs/reference//351/201/213/347/224/250/350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +392 -392
- package/lib/assets/docs/reference//351/226/213/347/231/272/343/202/254/343/202/244/343/203/211.md +299 -299
- package/lib/assets/docs/reference//351/235/236/346/251/237/350/203/275/350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +1236 -1236
- package/lib/assets/docs/review/index.md +5 -5
- package/lib/assets/docs/strategy/index.md +1 -1
- package/lib/assets/docs/template/ADR.md +30 -30
- package/lib/assets/docs/template/AWS/343/202/271/343/203/206/343/203/274/343/202/270/343/203/263/343/202/260/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +1366 -1366
- package/lib/assets/docs/template/AWS/343/203/227/343/203/255/343/203/200/343/202/257/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +634 -634
- package/lib/assets/docs/template/README.md +50 -50
- package/lib/assets/docs/template/index.md +23 -23
- package/lib/assets/docs/template//343/201/276/343/201/232/343/201/223/343/202/214/343/202/222/350/252/255/343/202/202/343/201/206/343/203/252/343/202/271/343/203/210.md +12 -12
- package/lib/assets/docs/template//343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/351/226/213/347/231/272/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +547 -547
- package/lib/assets/docs/template//343/202/244/343/203/206/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263/345/256/214/344/272/206/345/240/261/345/221/212/346/233/270.md +58 -58
- package/lib/assets/docs/template//343/202/244/343/203/263/343/202/273/343/203/227/343/202/267/343/203/247/343/203/263/343/203/207/343/203/203/343/202/255.md +13 -13
- package/lib/assets/docs/template//343/203/223/343/202/270/343/203/215/343/202/271/343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243.md +379 -379
- package/lib/assets/docs/template//344/274/201/346/245/255/345/210/206/346/236/220.md +573 -573
- package/lib/assets/docs/template//345/256/214/345/205/250/345/275/242/345/274/217/343/201/256/343/203/246/343/203/274/343/202/271/343/202/261/343/203/274/343/202/271.md +69 -69
- package/lib/assets/docs/template//350/246/201/344/273/266/345/256/232/347/276/251.md +669 -669
- package/lib/assets/docs/template//350/250/255/350/250/210.md +173 -173
- package/lib/assets/docs/template//351/226/213/347/231/272/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +688 -688
- package/lib/assets/gulpfile.js +25 -25
- package/lib/assets/mkdocs.yml +136 -136
- package/lib/assets/ops/docker/mkdoc/Dockerfile +19 -19
- package/lib/assets/ops/scripts/journal.js +180 -180
- package/lib/assets/ops/scripts/mkdocs.js +82 -82
- package/lib/assets/ops/scripts/release.js +431 -431
- package/lib/assets/ops/scripts/sonar_local.js +726 -726
- package/lib/assets/ops/scripts/ssh.js +190 -190
- package/lib/assets/ops/scripts/vault.js +299 -299
- package/lib/assets/package-lock.json +1653 -1653
- package/lib/assets/package.json +40 -40
- package/lib/gulpfile.js +37 -37
- package/package.json +41 -41
|
@@ -1,1049 +1,1049 @@
|
|
|
1
|
-
# Part VI: 実践的なアプリケーション構築とテスト
|
|
2
|
-
|
|
3
|
-
本章では、これまで学んだ関数型プログラミングの概念を統合し、実践的なアプリケーションを構築します。また、関数型プログラミングにおけるテスト戦略についても学びます。
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 第12章: 実践的なアプリケーションとテスト戦略
|
|
8
|
-
|
|
9
|
-
### 12.1 TravelGuide アプリケーション
|
|
10
|
-
|
|
11
|
-
旅行ガイドアプリケーションを例に、実践的な FP アプリケーションの構築方法を学びます。
|
|
12
|
-
|
|
13
|
-
```plantuml
|
|
14
|
-
@startuml
|
|
15
|
-
!theme plain
|
|
16
|
-
|
|
17
|
-
package "TravelGuide Application" {
|
|
18
|
-
rectangle "Model" {
|
|
19
|
-
class Location {
|
|
20
|
-
id: LocationId
|
|
21
|
-
name: String
|
|
22
|
-
population: integer
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
class Attraction {
|
|
26
|
-
name: String
|
|
27
|
-
description: String | nil
|
|
28
|
-
location: Location
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
class TravelGuide {
|
|
32
|
-
attraction: Attraction
|
|
33
|
-
subjects: [String]
|
|
34
|
-
search_report: SearchReport
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
rectangle "Data Access" {
|
|
39
|
-
interface DataAccess {
|
|
40
|
-
+find_attractions(): {:ok, [Attraction]} | {:error, String}
|
|
41
|
-
+find_artists_from_location(): {:ok, [MusicArtist]} | {:error, String}
|
|
42
|
-
+find_movies_about_location(): {:ok, [Movie]} | {:error, String}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
class TestDataAccess
|
|
46
|
-
class CachedDataAccess
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
DataAccess <|.. TestDataAccess
|
|
50
|
-
DataAccess <|.. CachedDataAccess
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@enduml
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### 12.2 ドメインモデルの定義
|
|
57
|
-
|
|
58
|
-
**ソースファイル**: `app/elixir/lib/ch12/travel_guide.ex`
|
|
59
|
-
|
|
60
|
-
Elixir では構造体(struct)を使ってドメインモデルを定義します。
|
|
61
|
-
|
|
62
|
-
```elixir
|
|
63
|
-
defmodule LocationId do
|
|
64
|
-
@moduledoc "位置情報 ID(Value Object)"
|
|
65
|
-
defstruct [:value]
|
|
66
|
-
|
|
67
|
-
@type t :: %__MODULE__{value: String.t()}
|
|
68
|
-
|
|
69
|
-
@spec new(String.t()) :: t()
|
|
70
|
-
def new(value), do: %__MODULE__{value: value}
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
defmodule Location do
|
|
74
|
-
@moduledoc "ロケーション"
|
|
75
|
-
defstruct [:id, :name, :population]
|
|
76
|
-
|
|
77
|
-
@type t :: %__MODULE__{
|
|
78
|
-
id: LocationId.t(),
|
|
79
|
-
name: String.t(),
|
|
80
|
-
population: non_neg_integer()
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
@spec new(LocationId.t(), String.t(), non_neg_integer()) :: t()
|
|
84
|
-
def new(id, name, population) do
|
|
85
|
-
%__MODULE__{id: id, name: name, population: population}
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
defmodule Attraction do
|
|
90
|
-
@moduledoc "アトラクション(観光地)"
|
|
91
|
-
defstruct [:name, :description, :location]
|
|
92
|
-
|
|
93
|
-
@type t :: %__MODULE__{
|
|
94
|
-
name: String.t(),
|
|
95
|
-
description: String.t() | nil,
|
|
96
|
-
location: Location.t()
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
@spec new(String.t(), String.t() | nil, Location.t()) :: t()
|
|
100
|
-
def new(name, description, location) do
|
|
101
|
-
%__MODULE__{name: name, description: description, location: location}
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### 12.3 データアクセス層の抽象化
|
|
107
|
-
|
|
108
|
-
Elixir では `@behaviour` を使用してインターフェースを定義します。
|
|
109
|
-
|
|
110
|
-
```elixir
|
|
111
|
-
defmodule DataAccess do
|
|
112
|
-
@moduledoc """
|
|
113
|
-
データアクセス層のインターフェース(振る舞い)
|
|
114
|
-
|
|
115
|
-
実装モジュールはこの振る舞いを実装する必要がある。
|
|
116
|
-
"""
|
|
117
|
-
|
|
118
|
-
@type ordering :: :by_name | :by_location_population
|
|
119
|
-
|
|
120
|
-
@callback find_attractions(String.t(), ordering(), pos_integer()) ::
|
|
121
|
-
{:ok, [Attraction.t()]} | {:error, String.t()}
|
|
122
|
-
|
|
123
|
-
@callback find_artists_from_location(LocationId.t(), pos_integer()) ::
|
|
124
|
-
{:ok, [MusicArtist.t()]} | {:error, String.t()}
|
|
125
|
-
|
|
126
|
-
@callback find_movies_about_location(LocationId.t(), pos_integer()) ::
|
|
127
|
-
{:ok, [Movie.t()]} | {:error, String.t()}
|
|
128
|
-
|
|
129
|
-
@callback find_hotels_near_location(LocationId.t(), pos_integer()) ::
|
|
130
|
-
{:ok, [Hotel.t()]} | {:error, String.t()}
|
|
131
|
-
end
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
```plantuml
|
|
135
|
-
@startuml
|
|
136
|
-
!theme plain
|
|
137
|
-
|
|
138
|
-
interface DataAccess {
|
|
139
|
-
+find_attractions(): {:ok, [Attraction]} | {:error, String}
|
|
140
|
-
+find_artists_from_location(): {:ok, [MusicArtist]} | {:error, String}
|
|
141
|
-
+find_movies_about_location(): {:ok, [Movie]} | {:error, String}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
note right of DataAccess
|
|
145
|
-
@behaviour による振る舞い定義
|
|
146
|
-
実装モジュールは @impl true で実装
|
|
147
|
-
end note
|
|
148
|
-
|
|
149
|
-
class TestDataAccess {
|
|
150
|
-
+find_attractions(): {:ok, [Attraction]}
|
|
151
|
-
+find_artists_from_location(): {:ok, [MusicArtist]}
|
|
152
|
-
+find_movies_about_location(): {:ok, [Movie]}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
class FailingDataAccess {
|
|
156
|
-
+find_attractions(): {:ok, [Attraction]}
|
|
157
|
-
+find_artists_from_location(): {:error, String}
|
|
158
|
-
+find_movies_about_location(): {:error, String}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
DataAccess <|.. TestDataAccess
|
|
162
|
-
DataAccess <|.. FailingDataAccess
|
|
163
|
-
|
|
164
|
-
@enduml
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### 12.4 スタブ実装
|
|
168
|
-
|
|
169
|
-
テスト用のスタブ実装を作成します。
|
|
170
|
-
|
|
171
|
-
```elixir
|
|
172
|
-
defmodule TestDataAccess do
|
|
173
|
-
@moduledoc "テスト用のスタブ実装"
|
|
174
|
-
@behaviour DataAccess
|
|
175
|
-
|
|
176
|
-
@impl true
|
|
177
|
-
def find_attractions(name, _ordering, limit) do
|
|
178
|
-
attractions =
|
|
179
|
-
case name do
|
|
180
|
-
"Empty" -> []
|
|
181
|
-
_ ->
|
|
182
|
-
[
|
|
183
|
-
Attraction.new("#{name} Tower", "A famous tower", @test_location),
|
|
184
|
-
Attraction.new("#{name} Park", "A beautiful park", @test_location),
|
|
185
|
-
Attraction.new("#{name} Museum", "A great museum", @test_location)
|
|
186
|
-
]
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
{:ok, Enum.take(attractions, limit)}
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
@impl true
|
|
193
|
-
def find_artists_from_location(_location_id, limit) do
|
|
194
|
-
artists = [
|
|
195
|
-
MusicArtist.new("Test Artist 1", "Pop"),
|
|
196
|
-
MusicArtist.new("Test Artist 2", "Rock")
|
|
197
|
-
]
|
|
198
|
-
|
|
199
|
-
{:ok, Enum.take(artists, limit)}
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
# 他のコールバックも同様に実装...
|
|
203
|
-
end
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### 12.5 Agent を使用したキャッシュ
|
|
207
|
-
|
|
208
|
-
Elixir の Agent を使用して、スレッドセーフなキャッシュを実装します。
|
|
209
|
-
|
|
210
|
-
```elixir
|
|
211
|
-
defmodule CachedDataAccess do
|
|
212
|
-
@moduledoc """
|
|
213
|
-
Agent を使ったキャッシュ付きデータアクセス
|
|
214
|
-
"""
|
|
215
|
-
|
|
216
|
-
@spec start_link(module()) :: {:ok, pid()}
|
|
217
|
-
def start_link(data_access_module) do
|
|
218
|
-
Agent.start_link(fn ->
|
|
219
|
-
%{
|
|
220
|
-
module: data_access_module,
|
|
221
|
-
attractions_cache: %{},
|
|
222
|
-
artists_cache: %{},
|
|
223
|
-
movies_cache: %{},
|
|
224
|
-
hotels_cache: %{}
|
|
225
|
-
}
|
|
226
|
-
end)
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
@spec find_attractions(pid(), String.t(), DataAccess.ordering(), pos_integer()) ::
|
|
230
|
-
{:ok, [Attraction.t()]} | {:error, String.t()}
|
|
231
|
-
def find_attractions(cache, name, ordering, limit) do
|
|
232
|
-
key = "#{name}-#{ordering}-#{limit}"
|
|
233
|
-
|
|
234
|
-
Agent.get_and_update(cache, fn state ->
|
|
235
|
-
case Map.get(state.attractions_cache, key) do
|
|
236
|
-
nil ->
|
|
237
|
-
result = state.module.find_attractions(name, ordering, limit)
|
|
238
|
-
|
|
239
|
-
case result do
|
|
240
|
-
{:ok, attractions} ->
|
|
241
|
-
new_cache = Map.put(state.attractions_cache, key, attractions)
|
|
242
|
-
{result, %{state | attractions_cache: new_cache}}
|
|
243
|
-
|
|
244
|
-
{:error, _} = error ->
|
|
245
|
-
{error, state}
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
cached ->
|
|
249
|
-
{{:ok, cached}, state}
|
|
250
|
-
end
|
|
251
|
-
end)
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
# 他のメソッドも同様に実装...
|
|
255
|
-
end
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
```plantuml
|
|
259
|
-
@startuml
|
|
260
|
-
!theme plain
|
|
261
|
-
skinparam activity {
|
|
262
|
-
BackgroundColor White
|
|
263
|
-
BorderColor Black
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
start
|
|
267
|
-
|
|
268
|
-
:キャッシュキー生成;
|
|
269
|
-
|
|
270
|
-
:Agent.get_and_update でキャッシュ確認;
|
|
271
|
-
|
|
272
|
-
if (キャッシュにデータあり?) then (yes)
|
|
273
|
-
:キャッシュからデータ返却;
|
|
274
|
-
else (no)
|
|
275
|
-
:外部モジュールを呼び出し;
|
|
276
|
-
:結果をキャッシュに保存;
|
|
277
|
-
:結果を返却;
|
|
278
|
-
endif
|
|
279
|
-
|
|
280
|
-
stop
|
|
281
|
-
|
|
282
|
-
note right
|
|
283
|
-
Agent を使用した
|
|
284
|
-
スレッドセーフなキャッシュ
|
|
285
|
-
end note
|
|
286
|
-
|
|
287
|
-
@enduml
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
### 12.6 アプリケーションの組み立て
|
|
291
|
-
|
|
292
|
-
すべてのコンポーネントを組み合わせてアプリケーションを構築します。
|
|
293
|
-
|
|
294
|
-
```elixir
|
|
295
|
-
@spec travel_guide(module(), String.t()) :: {:ok, TravelGuide.t()} | {:error, String.t()}
|
|
296
|
-
def travel_guide(data_access_module, attraction_name) do
|
|
297
|
-
case data_access_module.find_attractions(attraction_name, :by_location_population, 1) do
|
|
298
|
-
{:ok, []} ->
|
|
299
|
-
{:error, "No attractions found"}
|
|
300
|
-
|
|
301
|
-
{:ok, [attraction | _]} ->
|
|
302
|
-
build_guide(data_access_module, attraction, 1)
|
|
303
|
-
|
|
304
|
-
{:error, reason} ->
|
|
305
|
-
{:error, reason}
|
|
306
|
-
end
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
defp build_guide(data_access_module, attraction, attractions_searched) do
|
|
310
|
-
location_id = attraction.location.id
|
|
311
|
-
|
|
312
|
-
artists_result = data_access_module.find_artists_from_location(location_id, 2)
|
|
313
|
-
movies_result = data_access_module.find_movies_about_location(location_id, 2)
|
|
314
|
-
|
|
315
|
-
errors =
|
|
316
|
-
[artists_result, movies_result]
|
|
317
|
-
|> Enum.filter(&match?({:error, _}, &1))
|
|
318
|
-
|> Enum.map(fn {:error, reason} -> reason end)
|
|
319
|
-
|
|
320
|
-
artists =
|
|
321
|
-
case artists_result do
|
|
322
|
-
{:ok, list} -> list
|
|
323
|
-
{:error, _} -> []
|
|
324
|
-
end
|
|
325
|
-
|
|
326
|
-
movies =
|
|
327
|
-
case movies_result do
|
|
328
|
-
{:ok, list} -> list
|
|
329
|
-
{:error, _} -> []
|
|
330
|
-
end
|
|
331
|
-
|
|
332
|
-
subjects = Enum.map(artists, & &1.name) ++ Enum.map(movies, & &1.name)
|
|
333
|
-
report = SearchReport.new(attractions_searched, errors)
|
|
334
|
-
|
|
335
|
-
{:ok, TravelGuide.new(attraction, subjects, report)}
|
|
336
|
-
end
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
```plantuml
|
|
340
|
-
@startuml
|
|
341
|
-
!theme plain
|
|
342
|
-
|
|
343
|
-
rectangle "travel_guide 関数" {
|
|
344
|
-
card "1. アトラクション検索" as step1
|
|
345
|
-
card "2. アーティスト検索" as step2
|
|
346
|
-
card "3. 映画検索" as step3
|
|
347
|
-
card "4. TravelGuide 組み立て" as step4
|
|
348
|
-
|
|
349
|
-
step1 --> step2 : attraction
|
|
350
|
-
step1 --> step3 : location.id
|
|
351
|
-
step2 --> step4 : artists
|
|
352
|
-
step3 --> step4 : movies
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
note bottom
|
|
356
|
-
パターンマッチングで
|
|
357
|
-
複数の結果を合成
|
|
358
|
-
end note
|
|
359
|
-
|
|
360
|
-
@enduml
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
### 12.7 SearchReport の導入
|
|
364
|
-
|
|
365
|
-
テスト可能性を高めるため、`SearchReport` を導入します。
|
|
366
|
-
|
|
367
|
-
**ソースファイル**: `app/elixir/lib/ch12/travel_guide.ex`
|
|
368
|
-
|
|
369
|
-
```elixir
|
|
370
|
-
defmodule SearchReport do
|
|
371
|
-
@moduledoc "検索レポート"
|
|
372
|
-
defstruct [:attractions_searched, :errors]
|
|
373
|
-
|
|
374
|
-
@type t :: %__MODULE__{
|
|
375
|
-
attractions_searched: non_neg_integer(),
|
|
376
|
-
errors: [String.t()]
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
@spec new(non_neg_integer(), [String.t()]) :: t()
|
|
380
|
-
def new(attractions_searched, errors \\ []) do
|
|
381
|
-
%__MODULE__{attractions_searched: attractions_searched, errors: errors}
|
|
382
|
-
end
|
|
383
|
-
|
|
384
|
-
@spec empty() :: t()
|
|
385
|
-
def empty, do: new(0, [])
|
|
386
|
-
|
|
387
|
-
@spec add_error(t(), String.t()) :: t()
|
|
388
|
-
def add_error(%__MODULE__{} = report, error) do
|
|
389
|
-
%{report | errors: report.errors ++ [error]}
|
|
390
|
-
end
|
|
391
|
-
end
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
```plantuml
|
|
395
|
-
@startuml
|
|
396
|
-
!theme plain
|
|
397
|
-
|
|
398
|
-
class TravelGuide {
|
|
399
|
-
attraction: Attraction
|
|
400
|
-
subjects: [String]
|
|
401
|
-
search_report: SearchReport
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
class SearchReport {
|
|
405
|
-
attractions_searched: integer
|
|
406
|
-
errors: [String]
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
TravelGuide --> SearchReport
|
|
410
|
-
|
|
411
|
-
note right of SearchReport
|
|
412
|
-
検索の統計情報と
|
|
413
|
-
エラー情報を保持
|
|
414
|
-
end note
|
|
415
|
-
|
|
416
|
-
@enduml
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
---
|
|
420
|
-
|
|
421
|
-
## テスト戦略
|
|
422
|
-
|
|
423
|
-
### 12.8 関数型プログラミングのテスト
|
|
424
|
-
|
|
425
|
-
関数型プログラミングでは、純粋関数のおかげでテストが非常に簡単になります。
|
|
426
|
-
|
|
427
|
-
```plantuml
|
|
428
|
-
@startuml
|
|
429
|
-
!theme plain
|
|
430
|
-
|
|
431
|
-
rectangle "テストの種類" {
|
|
432
|
-
rectangle "単体テスト" as unit {
|
|
433
|
-
card "純粋関数のテスト"
|
|
434
|
-
card "高速・独立"
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
rectangle "プロパティベーステスト" as property {
|
|
438
|
-
card "ランダム入力"
|
|
439
|
-
card "不変条件の検証"
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
rectangle "統合テスト" as integration {
|
|
443
|
-
card "コンポーネント連携"
|
|
444
|
-
card "スタブ/モック使用"
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
unit --> property : 補完
|
|
449
|
-
property --> integration : 補完
|
|
450
|
-
|
|
451
|
-
@enduml
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
### 12.9 純粋関数のテスト
|
|
455
|
-
|
|
456
|
-
**ソースファイル**: `app/elixir/lib/ch12/testing.ex`
|
|
457
|
-
|
|
458
|
-
純粋関数は入力と出力だけを考えればよいため、テストが簡単です。
|
|
459
|
-
|
|
460
|
-
```elixir
|
|
461
|
-
# テスト対象の純粋関数
|
|
462
|
-
@spec filter_popular_locations([Location.t()], non_neg_integer()) :: [Location.t()]
|
|
463
|
-
def filter_popular_locations(locations, min_population) do
|
|
464
|
-
Enum.filter(locations, fn loc -> loc.population >= min_population end)
|
|
465
|
-
end
|
|
466
|
-
|
|
467
|
-
@spec sort_by_population([Attraction.t()]) :: [Attraction.t()]
|
|
468
|
-
def sort_by_population(attractions) do
|
|
469
|
-
Enum.sort_by(attractions, fn a -> a.location.population end, :desc)
|
|
470
|
-
end
|
|
471
|
-
|
|
472
|
-
@spec aggregate_results([{:ok, any()} | {:error, String.t()}]) ::
|
|
473
|
-
{[any()], [String.t()]}
|
|
474
|
-
def aggregate_results(results) do
|
|
475
|
-
Enum.reduce(results, {[], []}, fn result, {successes, errors} ->
|
|
476
|
-
case result do
|
|
477
|
-
{:ok, value} -> {successes ++ [value], errors}
|
|
478
|
-
{:error, reason} -> {successes, errors ++ [reason]}
|
|
479
|
-
end
|
|
480
|
-
end)
|
|
481
|
-
end
|
|
482
|
-
```
|
|
483
|
-
|
|
484
|
-
### 12.10 プロパティベーステスト
|
|
485
|
-
|
|
486
|
-
**ソースファイル**: `app/elixir/lib/ch12/testing.ex`
|
|
487
|
-
|
|
488
|
-
ランダムな入力を生成して不変条件をテストします。
|
|
489
|
-
|
|
490
|
-
```elixir
|
|
491
|
-
@doc """
|
|
492
|
-
プロパティをテスト(指定回数実行)
|
|
493
|
-
"""
|
|
494
|
-
@spec check_property(pos_integer(), (-> boolean())) :: :ok | {:error, String.t()}
|
|
495
|
-
def check_property(iterations, property_fn) do
|
|
496
|
-
results =
|
|
497
|
-
Enum.map(1..iterations, fn _ ->
|
|
498
|
-
try do
|
|
499
|
-
property_fn.()
|
|
500
|
-
rescue
|
|
501
|
-
_ -> false
|
|
502
|
-
end
|
|
503
|
-
end)
|
|
504
|
-
|
|
505
|
-
if Enum.all?(results) do
|
|
506
|
-
:ok
|
|
507
|
-
else
|
|
508
|
-
failed_count = Enum.count(results, &(!&1))
|
|
509
|
-
{:error, "Property failed #{failed_count}/#{iterations} times"}
|
|
510
|
-
end
|
|
511
|
-
end
|
|
512
|
-
|
|
513
|
-
@doc """
|
|
514
|
-
filter_popular_locations の不変条件をテスト
|
|
515
|
-
"""
|
|
516
|
-
@spec verify_filter_properties(pos_integer()) :: :ok | {:error, String.t()}
|
|
517
|
-
def verify_filter_properties(iterations) do
|
|
518
|
-
check_property(iterations, fn ->
|
|
519
|
-
locations = random_locations(:rand.uniform(20))
|
|
520
|
-
min_population = random_positive_int(5_000_000)
|
|
521
|
-
|
|
522
|
-
result = TravelGuide.filter_popular_locations(locations, min_population)
|
|
523
|
-
|
|
524
|
-
# プロパティ1: 結果のサイズは入力以下
|
|
525
|
-
size_property = length(result) <= length(locations)
|
|
526
|
-
|
|
527
|
-
# プロパティ2: 結果のすべての要素は条件を満たす
|
|
528
|
-
all_meet_condition = Enum.all?(result, fn loc -> loc.population >= min_population end)
|
|
529
|
-
|
|
530
|
-
# プロパティ3: 条件を満たす要素はすべて結果に含まれる
|
|
531
|
-
qualifying = Enum.filter(locations, fn loc -> loc.population >= min_population end)
|
|
532
|
-
all_included = Enum.all?(qualifying, fn loc -> loc in result end)
|
|
533
|
-
|
|
534
|
-
size_property and all_meet_condition and all_included
|
|
535
|
-
end)
|
|
536
|
-
end
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
```plantuml
|
|
540
|
-
@startuml
|
|
541
|
-
!theme plain
|
|
542
|
-
|
|
543
|
-
rectangle "プロパティベーステスト" {
|
|
544
|
-
card "random_location/0" as gen
|
|
545
|
-
card "ランダムデータ生成" as random
|
|
546
|
-
card "プロパティ検証" as verify
|
|
547
|
-
card "N回繰り返しテスト" as repeat
|
|
548
|
-
|
|
549
|
-
gen --> random
|
|
550
|
-
random --> verify
|
|
551
|
-
verify --> repeat
|
|
552
|
-
repeat --> random : 繰り返し
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
note bottom
|
|
556
|
-
ランダムな入力で
|
|
557
|
-
不変条件を検証
|
|
558
|
-
end note
|
|
559
|
-
|
|
560
|
-
@enduml
|
|
561
|
-
```
|
|
562
|
-
|
|
563
|
-
### 12.11 ランダムデータ生成
|
|
564
|
-
|
|
565
|
-
```elixir
|
|
566
|
-
@doc """
|
|
567
|
-
ランダムな文字列を生成
|
|
568
|
-
"""
|
|
569
|
-
@spec random_string(pos_integer()) :: String.t()
|
|
570
|
-
def random_string(length) do
|
|
571
|
-
:crypto.strong_rand_bytes(length)
|
|
572
|
-
|> Base.encode64()
|
|
573
|
-
|> binary_part(0, length)
|
|
574
|
-
end
|
|
575
|
-
|
|
576
|
-
@doc """
|
|
577
|
-
ランダムな Location を生成
|
|
578
|
-
"""
|
|
579
|
-
@spec random_location() :: Location.t()
|
|
580
|
-
def random_location do
|
|
581
|
-
id = LocationId.new("Q#{random_positive_int(1_000_000)}")
|
|
582
|
-
name = random_string(8)
|
|
583
|
-
population = random_positive_int(10_000_000)
|
|
584
|
-
Location.new(id, name, population)
|
|
585
|
-
end
|
|
586
|
-
|
|
587
|
-
@doc """
|
|
588
|
-
ランダムな Attraction を生成
|
|
589
|
-
"""
|
|
590
|
-
@spec random_attraction() :: Attraction.t()
|
|
591
|
-
def random_attraction do
|
|
592
|
-
name = random_string(10)
|
|
593
|
-
description = if :rand.uniform(2) == 1, do: random_string(20), else: nil
|
|
594
|
-
location = random_location()
|
|
595
|
-
Attraction.new(name, description, location)
|
|
596
|
-
end
|
|
597
|
-
```
|
|
598
|
-
|
|
599
|
-
### 12.12 統合テスト
|
|
600
|
-
|
|
601
|
-
```elixir
|
|
602
|
-
@doc """
|
|
603
|
-
TravelGuide の統合テストを実行
|
|
604
|
-
"""
|
|
605
|
-
@spec run_integration_tests() :: {:ok, map()}
|
|
606
|
-
def run_integration_tests do
|
|
607
|
-
tests = [
|
|
608
|
-
{:normal_case, fn ->
|
|
609
|
-
case TravelGuide.travel_guide(TravelGuide.TestDataAccess, "Tokyo") do
|
|
610
|
-
{:ok, guide} ->
|
|
611
|
-
guide.attraction.name == "Tokyo Tower" and
|
|
612
|
-
length(guide.subjects) > 0 and
|
|
613
|
-
guide.search_report.errors == []
|
|
614
|
-
|
|
615
|
-
_ ->
|
|
616
|
-
false
|
|
617
|
-
end
|
|
618
|
-
end},
|
|
619
|
-
{:empty_result, fn ->
|
|
620
|
-
case TravelGuide.travel_guide(TravelGuide.TestDataAccess, "Empty") do
|
|
621
|
-
{:error, "No attractions found"} -> true
|
|
622
|
-
_ -> false
|
|
623
|
-
end
|
|
624
|
-
end},
|
|
625
|
-
{:error_handling, fn ->
|
|
626
|
-
case TravelGuide.travel_guide(TravelGuide.FailingDataAccess, "Test") do
|
|
627
|
-
{:ok, guide} ->
|
|
628
|
-
length(guide.search_report.errors) == 2
|
|
629
|
-
|
|
630
|
-
_ ->
|
|
631
|
-
false
|
|
632
|
-
end
|
|
633
|
-
end},
|
|
634
|
-
{:cached_access, fn ->
|
|
635
|
-
{:ok, cache} = TravelGuide.CachedDataAccess.start_link(TravelGuide.TestDataAccess)
|
|
636
|
-
|
|
637
|
-
result1 = TravelGuide.travel_guide_cached(cache, "Tokyo")
|
|
638
|
-
result2 = TravelGuide.travel_guide_cached(cache, "Tokyo")
|
|
639
|
-
|
|
640
|
-
stats = TravelGuide.CachedDataAccess.cache_stats(cache)
|
|
641
|
-
Agent.stop(cache)
|
|
642
|
-
|
|
643
|
-
case {result1, result2} do
|
|
644
|
-
{{:ok, g1}, {:ok, g2}} ->
|
|
645
|
-
g1.attraction.name == g2.attraction.name and
|
|
646
|
-
stats.attractions > 0
|
|
647
|
-
|
|
648
|
-
_ ->
|
|
649
|
-
false
|
|
650
|
-
end
|
|
651
|
-
end}
|
|
652
|
-
]
|
|
653
|
-
|
|
654
|
-
results =
|
|
655
|
-
Enum.map(tests, fn {name, test_fn} ->
|
|
656
|
-
result =
|
|
657
|
-
try do
|
|
658
|
-
test_fn.()
|
|
659
|
-
rescue
|
|
660
|
-
_ -> false
|
|
661
|
-
end
|
|
662
|
-
|
|
663
|
-
{name, result}
|
|
664
|
-
end)
|
|
665
|
-
|
|
666
|
-
passed = Enum.count(results, fn {_, r} -> r end)
|
|
667
|
-
failed = Enum.count(results, fn {_, r} -> !r end)
|
|
668
|
-
|
|
669
|
-
{:ok, %{passed: passed, failed: failed, results: results}}
|
|
670
|
-
end
|
|
671
|
-
```
|
|
672
|
-
|
|
673
|
-
```plantuml
|
|
674
|
-
@startuml
|
|
675
|
-
!theme plain
|
|
676
|
-
|
|
677
|
-
rectangle "テスト構成" {
|
|
678
|
-
rectangle "本番" as prod {
|
|
679
|
-
interface "DataAccess" as da1
|
|
680
|
-
class "WikidataDataAccess" as wda
|
|
681
|
-
da1 <|.. wda
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
rectangle "テスト" as test {
|
|
685
|
-
interface "DataAccess" as da2
|
|
686
|
-
class "TestDataAccess" as tda
|
|
687
|
-
class "FailingDataAccess" as fda
|
|
688
|
-
da2 <|.. tda
|
|
689
|
-
da2 <|.. fda
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
note bottom of prod
|
|
694
|
-
実際の外部 API に接続
|
|
695
|
-
end note
|
|
696
|
-
|
|
697
|
-
note bottom of test
|
|
698
|
-
テストデータを返す
|
|
699
|
-
即座に結果を返す
|
|
700
|
-
end note
|
|
701
|
-
|
|
702
|
-
@enduml
|
|
703
|
-
```
|
|
704
|
-
|
|
705
|
-
### 12.13 パフォーマンステスト
|
|
706
|
-
|
|
707
|
-
```elixir
|
|
708
|
-
@doc """
|
|
709
|
-
関数の実行時間を計測
|
|
710
|
-
"""
|
|
711
|
-
@spec measure_time((-> any())) :: {non_neg_integer(), any()}
|
|
712
|
-
def measure_time(fun) do
|
|
713
|
-
{time, result} = :timer.tc(fun)
|
|
714
|
-
{time, result}
|
|
715
|
-
end
|
|
716
|
-
|
|
717
|
-
@doc """
|
|
718
|
-
キャッシュの効果を測定
|
|
719
|
-
"""
|
|
720
|
-
@spec measure_cache_effect(pos_integer()) :: {:ok, map()}
|
|
721
|
-
def measure_cache_effect(iterations) do
|
|
722
|
-
# キャッシュなしの時間
|
|
723
|
-
{uncached_time, _} =
|
|
724
|
-
measure_time(fn ->
|
|
725
|
-
Enum.each(1..iterations, fn _ ->
|
|
726
|
-
TravelGuide.travel_guide(TravelGuide.TestDataAccess, "Tokyo")
|
|
727
|
-
end)
|
|
728
|
-
end)
|
|
729
|
-
|
|
730
|
-
# キャッシュありの時間
|
|
731
|
-
{:ok, cache} = TravelGuide.CachedDataAccess.start_link(TravelGuide.TestDataAccess)
|
|
732
|
-
|
|
733
|
-
{cached_time, _} =
|
|
734
|
-
measure_time(fn ->
|
|
735
|
-
Enum.each(1..iterations, fn _ ->
|
|
736
|
-
TravelGuide.travel_guide_cached(cache, "Tokyo")
|
|
737
|
-
end)
|
|
738
|
-
end)
|
|
739
|
-
|
|
740
|
-
Agent.stop(cache)
|
|
741
|
-
|
|
742
|
-
{:ok,
|
|
743
|
-
%{
|
|
744
|
-
uncached_time: uncached_time,
|
|
745
|
-
cached_time: cached_time,
|
|
746
|
-
speedup: uncached_time / max(cached_time, 1)
|
|
747
|
-
}}
|
|
748
|
-
end
|
|
749
|
-
```
|
|
750
|
-
|
|
751
|
-
### 12.14 テストピラミッド
|
|
752
|
-
|
|
753
|
-
```plantuml
|
|
754
|
-
@startuml
|
|
755
|
-
!theme plain
|
|
756
|
-
|
|
757
|
-
rectangle "テストピラミッド" {
|
|
758
|
-
rectangle "E2E テスト\n(少数)" as e2e
|
|
759
|
-
rectangle "統合テスト\n(中程度)" as integration
|
|
760
|
-
rectangle "単体テスト + プロパティテスト\n(多数)" as unit
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
e2e -[hidden]down- integration
|
|
764
|
-
integration -[hidden]down- unit
|
|
765
|
-
|
|
766
|
-
note right of unit
|
|
767
|
-
FP では純粋関数が多いため
|
|
768
|
-
単体テストが非常に効果的
|
|
769
|
-
end note
|
|
770
|
-
|
|
771
|
-
@enduml
|
|
772
|
-
```
|
|
773
|
-
|
|
774
|
-
---
|
|
775
|
-
|
|
776
|
-
## まとめ
|
|
777
|
-
|
|
778
|
-
### Part VI で学んだこと
|
|
779
|
-
|
|
780
|
-
```plantuml
|
|
781
|
-
@startuml
|
|
782
|
-
!theme plain
|
|
783
|
-
|
|
784
|
-
rectangle "Part VI: 実践的なアプリケーション" {
|
|
785
|
-
rectangle "ドメインモデル" as model {
|
|
786
|
-
card "構造体による型定義"
|
|
787
|
-
card "Value Object パターン"
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
rectangle "データアクセス" as data {
|
|
791
|
-
card "@behaviour による抽象化"
|
|
792
|
-
card "スタブ実装"
|
|
793
|
-
card "Agent によるキャッシュ"
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
rectangle "テスト戦略" as test {
|
|
797
|
-
card "純粋関数のテスト"
|
|
798
|
-
card "プロパティベーステスト"
|
|
799
|
-
card "統合テスト"
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
model --> data
|
|
804
|
-
data --> test
|
|
805
|
-
|
|
806
|
-
@enduml
|
|
807
|
-
```
|
|
808
|
-
|
|
809
|
-
### キーポイント
|
|
810
|
-
|
|
811
|
-
1. **@behaviour による抽象化**: DataAccess 振る舞いで外部依存を抽象化
|
|
812
|
-
2. **Agent でキャッシュ**: スレッドセーフな状態管理
|
|
813
|
-
3. **タプルでエラー処理**: `{:ok, value}` / `{:error, reason}` で明示的なエラーハンドリング
|
|
814
|
-
4. **SearchReport**: テスト可能性と可観測性の向上
|
|
815
|
-
5. **スタブ**: 外部依存を差し替えてテスト
|
|
816
|
-
6. **プロパティベーステスト**: ランダム入力で不変条件を検証
|
|
817
|
-
|
|
818
|
-
### Scala との対比
|
|
819
|
-
|
|
820
|
-
| 概念 | Scala | Elixir |
|
|
821
|
-
|------|-------|--------|
|
|
822
|
-
| インターフェース | `trait` | `@behaviour` |
|
|
823
|
-
| 状態管理 | `Ref[IO, A]` | `Agent` |
|
|
824
|
-
| リソース管理 | `Resource[IO, A]` | プロセス / `with` |
|
|
825
|
-
| エラー処理 | `Either[E, A]` | `{:ok, a} \| {:error, e}` |
|
|
826
|
-
| 非同期処理 | `IO[A]` | `Task` / `GenServer` |
|
|
827
|
-
| キャッシュ | `Ref` + `Map` | `Agent` + `Map` |
|
|
828
|
-
|
|
829
|
-
### 学習の総括
|
|
830
|
-
|
|
831
|
-
```plantuml
|
|
832
|
-
@startuml
|
|
833
|
-
!theme plain
|
|
834
|
-
left to right direction
|
|
835
|
-
|
|
836
|
-
rectangle "Elixir FP の学習パス" {
|
|
837
|
-
card "Part I\n基礎" as p1
|
|
838
|
-
card "Part II\nイミュータブル操作" as p2
|
|
839
|
-
card "Part III\n型とパターン" as p3
|
|
840
|
-
card "Part IV\nStream と再帰" as p4
|
|
841
|
-
card "Part V\n並行処理・OTP" as p5
|
|
842
|
-
card "Part VI\n実践" as p6
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
p1 --> p2
|
|
846
|
-
p2 --> p3
|
|
847
|
-
p3 --> p4
|
|
848
|
-
p4 --> p5
|
|
849
|
-
p5 --> p6
|
|
850
|
-
|
|
851
|
-
@enduml
|
|
852
|
-
```
|
|
853
|
-
|
|
854
|
-
---
|
|
855
|
-
|
|
856
|
-
## 演習問題
|
|
857
|
-
|
|
858
|
-
### 問題 1: DataAccess の拡張
|
|
859
|
-
|
|
860
|
-
以下の要件で `DataAccess` を拡張してください:
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
- 新しいコールバック `find_restaurants_near_location` を追加
|
|
864
|
-
- 戻り値は `{:ok, [Restaurant.t()]} | {:error, String.t()}`
|
|
865
|
-
|
|
866
|
-
<details>
|
|
867
|
-
<summary>解答</summary>
|
|
868
|
-
|
|
869
|
-
```elixir
|
|
870
|
-
defmodule Restaurant do
|
|
871
|
-
defstruct [:name, :cuisine, :rating, :location]
|
|
872
|
-
|
|
873
|
-
@type t :: %__MODULE__{
|
|
874
|
-
name: String.t(),
|
|
875
|
-
cuisine: String.t(),
|
|
876
|
-
rating: float(),
|
|
877
|
-
location: Location.t()
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
@spec new(String.t(), String.t(), float(), Location.t()) :: t()
|
|
881
|
-
def new(name, cuisine, rating, location) do
|
|
882
|
-
%__MODULE__{name: name, cuisine: cuisine, rating: rating, location: location}
|
|
883
|
-
end
|
|
884
|
-
end
|
|
885
|
-
|
|
886
|
-
# DataAccess に追加
|
|
887
|
-
@callback find_restaurants_near_location(LocationId.t(), pos_integer()) ::
|
|
888
|
-
{:ok, [Restaurant.t()]} | {:error, String.t()}
|
|
889
|
-
|
|
890
|
-
# TestDataAccess の実装
|
|
891
|
-
@impl true
|
|
892
|
-
def find_restaurants_near_location(_location_id, limit) do
|
|
893
|
-
restaurants = [
|
|
894
|
-
Restaurant.new("Test Restaurant 1", "Japanese", 4.5, @test_location),
|
|
895
|
-
Restaurant.new("Test Restaurant 2", "Italian", 4.0, @test_location)
|
|
896
|
-
]
|
|
897
|
-
|
|
898
|
-
{:ok, Enum.take(restaurants, limit)}
|
|
899
|
-
end
|
|
900
|
-
```
|
|
901
|
-
|
|
902
|
-
</details>
|
|
903
|
-
|
|
904
|
-
### 問題 2: プロパティベーステスト
|
|
905
|
-
|
|
906
|
-
以下の関数に対するプロパティベーステストを書いてください:
|
|
907
|
-
|
|
908
|
-
```elixir
|
|
909
|
-
def merge_subjects(artists, movies) do
|
|
910
|
-
Enum.map(artists, & &1.name) ++ Enum.map(movies, & &1.name)
|
|
911
|
-
end
|
|
912
|
-
```
|
|
913
|
-
|
|
914
|
-
<details>
|
|
915
|
-
<summary>解答</summary>
|
|
916
|
-
|
|
917
|
-
```elixir
|
|
918
|
-
@spec verify_merge_properties(pos_integer()) :: :ok | {:error, String.t()}
|
|
919
|
-
def verify_merge_properties(iterations) do
|
|
920
|
-
check_property(iterations, fn ->
|
|
921
|
-
artist_count = :rand.uniform(10)
|
|
922
|
-
movie_count = :rand.uniform(10)
|
|
923
|
-
|
|
924
|
-
artists = Enum.map(1..artist_count, fn i ->
|
|
925
|
-
MusicArtist.new("Artist #{i}", nil)
|
|
926
|
-
end)
|
|
927
|
-
|
|
928
|
-
movies = Enum.map(1..movie_count, fn i ->
|
|
929
|
-
Movie.new("Movie #{i}", nil)
|
|
930
|
-
end)
|
|
931
|
-
|
|
932
|
-
result = TravelGuide.merge_subjects(artists, movies)
|
|
933
|
-
|
|
934
|
-
# プロパティ1: 結果の長さは入力の合計
|
|
935
|
-
length_property = length(result) == artist_count + movie_count
|
|
936
|
-
|
|
937
|
-
# プロパティ2: すべてのアーティスト名が含まれる
|
|
938
|
-
artist_names = Enum.map(artists, & &1.name)
|
|
939
|
-
artists_included = Enum.all?(artist_names, fn n -> n in result end)
|
|
940
|
-
|
|
941
|
-
# プロパティ3: すべての映画名が含まれる
|
|
942
|
-
movie_names = Enum.map(movies, & &1.name)
|
|
943
|
-
movies_included = Enum.all?(movie_names, fn n -> n in result end)
|
|
944
|
-
|
|
945
|
-
length_property and artists_included and movies_included
|
|
946
|
-
end)
|
|
947
|
-
end
|
|
948
|
-
```
|
|
949
|
-
|
|
950
|
-
</details>
|
|
951
|
-
|
|
952
|
-
### 問題 3: キャッシュの有効期限
|
|
953
|
-
|
|
954
|
-
`CachedDataAccess` にキャッシュの有効期限機能を追加してください。
|
|
955
|
-
|
|
956
|
-
<details>
|
|
957
|
-
<summary>解答</summary>
|
|
958
|
-
|
|
959
|
-
```elixir
|
|
960
|
-
defmodule CachedDataAccessWithTTL do
|
|
961
|
-
@moduledoc """
|
|
962
|
-
TTL(有効期限)付きキャッシュ
|
|
963
|
-
"""
|
|
964
|
-
|
|
965
|
-
@default_ttl_ms 60_000 # 60秒
|
|
966
|
-
|
|
967
|
-
@spec start_link(module(), pos_integer()) :: {:ok, pid()}
|
|
968
|
-
def start_link(data_access_module, ttl_ms \\ @default_ttl_ms) do
|
|
969
|
-
Agent.start_link(fn ->
|
|
970
|
-
%{
|
|
971
|
-
module: data_access_module,
|
|
972
|
-
ttl_ms: ttl_ms,
|
|
973
|
-
attractions_cache: %{} # key => {value, timestamp}
|
|
974
|
-
}
|
|
975
|
-
end)
|
|
976
|
-
end
|
|
977
|
-
|
|
978
|
-
@spec find_attractions(pid(), String.t(), DataAccess.ordering(), pos_integer()) ::
|
|
979
|
-
{:ok, [Attraction.t()]} | {:error, String.t()}
|
|
980
|
-
def find_attractions(cache, name, ordering, limit) do
|
|
981
|
-
key = "#{name}-#{ordering}-#{limit}"
|
|
982
|
-
now = System.monotonic_time(:millisecond)
|
|
983
|
-
|
|
984
|
-
Agent.get_and_update(cache, fn state ->
|
|
985
|
-
case Map.get(state.attractions_cache, key) do
|
|
986
|
-
{cached, timestamp} when now - timestamp < state.ttl_ms ->
|
|
987
|
-
# キャッシュが有効
|
|
988
|
-
{{:ok, cached}, state}
|
|
989
|
-
|
|
990
|
-
_ ->
|
|
991
|
-
# キャッシュが無効または存在しない
|
|
992
|
-
result = state.module.find_attractions(name, ordering, limit)
|
|
993
|
-
|
|
994
|
-
case result do
|
|
995
|
-
{:ok, attractions} ->
|
|
996
|
-
new_cache = Map.put(state.attractions_cache, key, {attractions, now})
|
|
997
|
-
{result, %{state | attractions_cache: new_cache}}
|
|
998
|
-
|
|
999
|
-
{:error, _} = error ->
|
|
1000
|
-
{error, state}
|
|
1001
|
-
end
|
|
1002
|
-
end
|
|
1003
|
-
end)
|
|
1004
|
-
end
|
|
1005
|
-
end
|
|
1006
|
-
```
|
|
1007
|
-
|
|
1008
|
-
</details>
|
|
1009
|
-
|
|
1010
|
-
---
|
|
1011
|
-
|
|
1012
|
-
## シリーズ全体の総括
|
|
1013
|
-
|
|
1014
|
-
本シリーズでは、「Grokking Functional Programming」の内容に沿って、Elixir による関数型プログラミングの基礎から実践的なアプリケーション構築までを学びました。
|
|
1015
|
-
|
|
1016
|
-
### 学んだ主な概念
|
|
1017
|
-
|
|
1018
|
-
| Part | 章 | 主な概念 |
|
|
1019
|
-
|------|-----|----------|
|
|
1020
|
-
| I | 1-2 | 純粋関数、イミュータビリティ |
|
|
1021
|
-
| II | 3-5 | パイプ演算子、高階関数、Enum |
|
|
1022
|
-
| III | 6-7 | パターンマッチング、with 式 |
|
|
1023
|
-
| IV | 8-9 | Stream、再帰 |
|
|
1024
|
-
| V | 10-11 | 並行処理、OTP パターン |
|
|
1025
|
-
| VI | 12 | 実践アプリケーション、テスト |
|
|
1026
|
-
|
|
1027
|
-
### 関数型プログラミングの利点
|
|
1028
|
-
|
|
1029
|
-
1. **予測可能性**: 純粋関数は同じ入力に対して常に同じ出力
|
|
1030
|
-
2. **テスト容易性**: 副作用がないためテストが簡単
|
|
1031
|
-
3. **合成可能性**: パイプ演算子で小さな関数を組み合わせ
|
|
1032
|
-
4. **並行安全性**: イミュータブルデータは競合状態を防ぐ
|
|
1033
|
-
5. **パターンマッチング**: 明確で安全なデータ処理
|
|
1034
|
-
|
|
1035
|
-
### Elixir 特有の利点
|
|
1036
|
-
|
|
1037
|
-
1. **OTP**: 堅牢な並行処理フレームワーク
|
|
1038
|
-
2. **BEAM VM**: 軽量プロセスと高いスケーラビリティ
|
|
1039
|
-
3. **パイプ演算子**: 読みやすいデータ変換
|
|
1040
|
-
4. **パターンマッチング**: 強力な分岐とデストラクチャリング
|
|
1041
|
-
5. **ホットコードスワップ**: 無停止でのコード更新
|
|
1042
|
-
|
|
1043
|
-
### 次のステップ
|
|
1044
|
-
|
|
1045
|
-
- Phoenix フレームワークでの Web 開発
|
|
1046
|
-
- Ecto でのデータベース操作
|
|
1047
|
-
- LiveView でのリアルタイム UI
|
|
1048
|
-
- Nerves での組み込み開発
|
|
1049
|
-
- 実際のプロジェクトで FP を適用する
|
|
1
|
+
# Part VI: 実践的なアプリケーション構築とテスト
|
|
2
|
+
|
|
3
|
+
本章では、これまで学んだ関数型プログラミングの概念を統合し、実践的なアプリケーションを構築します。また、関数型プログラミングにおけるテスト戦略についても学びます。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 第12章: 実践的なアプリケーションとテスト戦略
|
|
8
|
+
|
|
9
|
+
### 12.1 TravelGuide アプリケーション
|
|
10
|
+
|
|
11
|
+
旅行ガイドアプリケーションを例に、実践的な FP アプリケーションの構築方法を学びます。
|
|
12
|
+
|
|
13
|
+
```plantuml
|
|
14
|
+
@startuml
|
|
15
|
+
!theme plain
|
|
16
|
+
|
|
17
|
+
package "TravelGuide Application" {
|
|
18
|
+
rectangle "Model" {
|
|
19
|
+
class Location {
|
|
20
|
+
id: LocationId
|
|
21
|
+
name: String
|
|
22
|
+
population: integer
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
class Attraction {
|
|
26
|
+
name: String
|
|
27
|
+
description: String | nil
|
|
28
|
+
location: Location
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class TravelGuide {
|
|
32
|
+
attraction: Attraction
|
|
33
|
+
subjects: [String]
|
|
34
|
+
search_report: SearchReport
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
rectangle "Data Access" {
|
|
39
|
+
interface DataAccess {
|
|
40
|
+
+find_attractions(): {:ok, [Attraction]} | {:error, String}
|
|
41
|
+
+find_artists_from_location(): {:ok, [MusicArtist]} | {:error, String}
|
|
42
|
+
+find_movies_about_location(): {:ok, [Movie]} | {:error, String}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
class TestDataAccess
|
|
46
|
+
class CachedDataAccess
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
DataAccess <|.. TestDataAccess
|
|
50
|
+
DataAccess <|.. CachedDataAccess
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@enduml
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 12.2 ドメインモデルの定義
|
|
57
|
+
|
|
58
|
+
**ソースファイル**: `app/elixir/lib/ch12/travel_guide.ex`
|
|
59
|
+
|
|
60
|
+
Elixir では構造体(struct)を使ってドメインモデルを定義します。
|
|
61
|
+
|
|
62
|
+
```elixir
|
|
63
|
+
defmodule LocationId do
|
|
64
|
+
@moduledoc "位置情報 ID(Value Object)"
|
|
65
|
+
defstruct [:value]
|
|
66
|
+
|
|
67
|
+
@type t :: %__MODULE__{value: String.t()}
|
|
68
|
+
|
|
69
|
+
@spec new(String.t()) :: t()
|
|
70
|
+
def new(value), do: %__MODULE__{value: value}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
defmodule Location do
|
|
74
|
+
@moduledoc "ロケーション"
|
|
75
|
+
defstruct [:id, :name, :population]
|
|
76
|
+
|
|
77
|
+
@type t :: %__MODULE__{
|
|
78
|
+
id: LocationId.t(),
|
|
79
|
+
name: String.t(),
|
|
80
|
+
population: non_neg_integer()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@spec new(LocationId.t(), String.t(), non_neg_integer()) :: t()
|
|
84
|
+
def new(id, name, population) do
|
|
85
|
+
%__MODULE__{id: id, name: name, population: population}
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
defmodule Attraction do
|
|
90
|
+
@moduledoc "アトラクション(観光地)"
|
|
91
|
+
defstruct [:name, :description, :location]
|
|
92
|
+
|
|
93
|
+
@type t :: %__MODULE__{
|
|
94
|
+
name: String.t(),
|
|
95
|
+
description: String.t() | nil,
|
|
96
|
+
location: Location.t()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@spec new(String.t(), String.t() | nil, Location.t()) :: t()
|
|
100
|
+
def new(name, description, location) do
|
|
101
|
+
%__MODULE__{name: name, description: description, location: location}
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 12.3 データアクセス層の抽象化
|
|
107
|
+
|
|
108
|
+
Elixir では `@behaviour` を使用してインターフェースを定義します。
|
|
109
|
+
|
|
110
|
+
```elixir
|
|
111
|
+
defmodule DataAccess do
|
|
112
|
+
@moduledoc """
|
|
113
|
+
データアクセス層のインターフェース(振る舞い)
|
|
114
|
+
|
|
115
|
+
実装モジュールはこの振る舞いを実装する必要がある。
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
@type ordering :: :by_name | :by_location_population
|
|
119
|
+
|
|
120
|
+
@callback find_attractions(String.t(), ordering(), pos_integer()) ::
|
|
121
|
+
{:ok, [Attraction.t()]} | {:error, String.t()}
|
|
122
|
+
|
|
123
|
+
@callback find_artists_from_location(LocationId.t(), pos_integer()) ::
|
|
124
|
+
{:ok, [MusicArtist.t()]} | {:error, String.t()}
|
|
125
|
+
|
|
126
|
+
@callback find_movies_about_location(LocationId.t(), pos_integer()) ::
|
|
127
|
+
{:ok, [Movie.t()]} | {:error, String.t()}
|
|
128
|
+
|
|
129
|
+
@callback find_hotels_near_location(LocationId.t(), pos_integer()) ::
|
|
130
|
+
{:ok, [Hotel.t()]} | {:error, String.t()}
|
|
131
|
+
end
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
```plantuml
|
|
135
|
+
@startuml
|
|
136
|
+
!theme plain
|
|
137
|
+
|
|
138
|
+
interface DataAccess {
|
|
139
|
+
+find_attractions(): {:ok, [Attraction]} | {:error, String}
|
|
140
|
+
+find_artists_from_location(): {:ok, [MusicArtist]} | {:error, String}
|
|
141
|
+
+find_movies_about_location(): {:ok, [Movie]} | {:error, String}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
note right of DataAccess
|
|
145
|
+
@behaviour による振る舞い定義
|
|
146
|
+
実装モジュールは @impl true で実装
|
|
147
|
+
end note
|
|
148
|
+
|
|
149
|
+
class TestDataAccess {
|
|
150
|
+
+find_attractions(): {:ok, [Attraction]}
|
|
151
|
+
+find_artists_from_location(): {:ok, [MusicArtist]}
|
|
152
|
+
+find_movies_about_location(): {:ok, [Movie]}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
class FailingDataAccess {
|
|
156
|
+
+find_attractions(): {:ok, [Attraction]}
|
|
157
|
+
+find_artists_from_location(): {:error, String}
|
|
158
|
+
+find_movies_about_location(): {:error, String}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
DataAccess <|.. TestDataAccess
|
|
162
|
+
DataAccess <|.. FailingDataAccess
|
|
163
|
+
|
|
164
|
+
@enduml
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 12.4 スタブ実装
|
|
168
|
+
|
|
169
|
+
テスト用のスタブ実装を作成します。
|
|
170
|
+
|
|
171
|
+
```elixir
|
|
172
|
+
defmodule TestDataAccess do
|
|
173
|
+
@moduledoc "テスト用のスタブ実装"
|
|
174
|
+
@behaviour DataAccess
|
|
175
|
+
|
|
176
|
+
@impl true
|
|
177
|
+
def find_attractions(name, _ordering, limit) do
|
|
178
|
+
attractions =
|
|
179
|
+
case name do
|
|
180
|
+
"Empty" -> []
|
|
181
|
+
_ ->
|
|
182
|
+
[
|
|
183
|
+
Attraction.new("#{name} Tower", "A famous tower", @test_location),
|
|
184
|
+
Attraction.new("#{name} Park", "A beautiful park", @test_location),
|
|
185
|
+
Attraction.new("#{name} Museum", "A great museum", @test_location)
|
|
186
|
+
]
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
{:ok, Enum.take(attractions, limit)}
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
@impl true
|
|
193
|
+
def find_artists_from_location(_location_id, limit) do
|
|
194
|
+
artists = [
|
|
195
|
+
MusicArtist.new("Test Artist 1", "Pop"),
|
|
196
|
+
MusicArtist.new("Test Artist 2", "Rock")
|
|
197
|
+
]
|
|
198
|
+
|
|
199
|
+
{:ok, Enum.take(artists, limit)}
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# 他のコールバックも同様に実装...
|
|
203
|
+
end
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### 12.5 Agent を使用したキャッシュ
|
|
207
|
+
|
|
208
|
+
Elixir の Agent を使用して、スレッドセーフなキャッシュを実装します。
|
|
209
|
+
|
|
210
|
+
```elixir
|
|
211
|
+
defmodule CachedDataAccess do
|
|
212
|
+
@moduledoc """
|
|
213
|
+
Agent を使ったキャッシュ付きデータアクセス
|
|
214
|
+
"""
|
|
215
|
+
|
|
216
|
+
@spec start_link(module()) :: {:ok, pid()}
|
|
217
|
+
def start_link(data_access_module) do
|
|
218
|
+
Agent.start_link(fn ->
|
|
219
|
+
%{
|
|
220
|
+
module: data_access_module,
|
|
221
|
+
attractions_cache: %{},
|
|
222
|
+
artists_cache: %{},
|
|
223
|
+
movies_cache: %{},
|
|
224
|
+
hotels_cache: %{}
|
|
225
|
+
}
|
|
226
|
+
end)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
@spec find_attractions(pid(), String.t(), DataAccess.ordering(), pos_integer()) ::
|
|
230
|
+
{:ok, [Attraction.t()]} | {:error, String.t()}
|
|
231
|
+
def find_attractions(cache, name, ordering, limit) do
|
|
232
|
+
key = "#{name}-#{ordering}-#{limit}"
|
|
233
|
+
|
|
234
|
+
Agent.get_and_update(cache, fn state ->
|
|
235
|
+
case Map.get(state.attractions_cache, key) do
|
|
236
|
+
nil ->
|
|
237
|
+
result = state.module.find_attractions(name, ordering, limit)
|
|
238
|
+
|
|
239
|
+
case result do
|
|
240
|
+
{:ok, attractions} ->
|
|
241
|
+
new_cache = Map.put(state.attractions_cache, key, attractions)
|
|
242
|
+
{result, %{state | attractions_cache: new_cache}}
|
|
243
|
+
|
|
244
|
+
{:error, _} = error ->
|
|
245
|
+
{error, state}
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
cached ->
|
|
249
|
+
{{:ok, cached}, state}
|
|
250
|
+
end
|
|
251
|
+
end)
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# 他のメソッドも同様に実装...
|
|
255
|
+
end
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
```plantuml
|
|
259
|
+
@startuml
|
|
260
|
+
!theme plain
|
|
261
|
+
skinparam activity {
|
|
262
|
+
BackgroundColor White
|
|
263
|
+
BorderColor Black
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
start
|
|
267
|
+
|
|
268
|
+
:キャッシュキー生成;
|
|
269
|
+
|
|
270
|
+
:Agent.get_and_update でキャッシュ確認;
|
|
271
|
+
|
|
272
|
+
if (キャッシュにデータあり?) then (yes)
|
|
273
|
+
:キャッシュからデータ返却;
|
|
274
|
+
else (no)
|
|
275
|
+
:外部モジュールを呼び出し;
|
|
276
|
+
:結果をキャッシュに保存;
|
|
277
|
+
:結果を返却;
|
|
278
|
+
endif
|
|
279
|
+
|
|
280
|
+
stop
|
|
281
|
+
|
|
282
|
+
note right
|
|
283
|
+
Agent を使用した
|
|
284
|
+
スレッドセーフなキャッシュ
|
|
285
|
+
end note
|
|
286
|
+
|
|
287
|
+
@enduml
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### 12.6 アプリケーションの組み立て
|
|
291
|
+
|
|
292
|
+
すべてのコンポーネントを組み合わせてアプリケーションを構築します。
|
|
293
|
+
|
|
294
|
+
```elixir
|
|
295
|
+
@spec travel_guide(module(), String.t()) :: {:ok, TravelGuide.t()} | {:error, String.t()}
|
|
296
|
+
def travel_guide(data_access_module, attraction_name) do
|
|
297
|
+
case data_access_module.find_attractions(attraction_name, :by_location_population, 1) do
|
|
298
|
+
{:ok, []} ->
|
|
299
|
+
{:error, "No attractions found"}
|
|
300
|
+
|
|
301
|
+
{:ok, [attraction | _]} ->
|
|
302
|
+
build_guide(data_access_module, attraction, 1)
|
|
303
|
+
|
|
304
|
+
{:error, reason} ->
|
|
305
|
+
{:error, reason}
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
defp build_guide(data_access_module, attraction, attractions_searched) do
|
|
310
|
+
location_id = attraction.location.id
|
|
311
|
+
|
|
312
|
+
artists_result = data_access_module.find_artists_from_location(location_id, 2)
|
|
313
|
+
movies_result = data_access_module.find_movies_about_location(location_id, 2)
|
|
314
|
+
|
|
315
|
+
errors =
|
|
316
|
+
[artists_result, movies_result]
|
|
317
|
+
|> Enum.filter(&match?({:error, _}, &1))
|
|
318
|
+
|> Enum.map(fn {:error, reason} -> reason end)
|
|
319
|
+
|
|
320
|
+
artists =
|
|
321
|
+
case artists_result do
|
|
322
|
+
{:ok, list} -> list
|
|
323
|
+
{:error, _} -> []
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
movies =
|
|
327
|
+
case movies_result do
|
|
328
|
+
{:ok, list} -> list
|
|
329
|
+
{:error, _} -> []
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
subjects = Enum.map(artists, & &1.name) ++ Enum.map(movies, & &1.name)
|
|
333
|
+
report = SearchReport.new(attractions_searched, errors)
|
|
334
|
+
|
|
335
|
+
{:ok, TravelGuide.new(attraction, subjects, report)}
|
|
336
|
+
end
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
```plantuml
|
|
340
|
+
@startuml
|
|
341
|
+
!theme plain
|
|
342
|
+
|
|
343
|
+
rectangle "travel_guide 関数" {
|
|
344
|
+
card "1. アトラクション検索" as step1
|
|
345
|
+
card "2. アーティスト検索" as step2
|
|
346
|
+
card "3. 映画検索" as step3
|
|
347
|
+
card "4. TravelGuide 組み立て" as step4
|
|
348
|
+
|
|
349
|
+
step1 --> step2 : attraction
|
|
350
|
+
step1 --> step3 : location.id
|
|
351
|
+
step2 --> step4 : artists
|
|
352
|
+
step3 --> step4 : movies
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
note bottom
|
|
356
|
+
パターンマッチングで
|
|
357
|
+
複数の結果を合成
|
|
358
|
+
end note
|
|
359
|
+
|
|
360
|
+
@enduml
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### 12.7 SearchReport の導入
|
|
364
|
+
|
|
365
|
+
テスト可能性を高めるため、`SearchReport` を導入します。
|
|
366
|
+
|
|
367
|
+
**ソースファイル**: `app/elixir/lib/ch12/travel_guide.ex`
|
|
368
|
+
|
|
369
|
+
```elixir
|
|
370
|
+
defmodule SearchReport do
|
|
371
|
+
@moduledoc "検索レポート"
|
|
372
|
+
defstruct [:attractions_searched, :errors]
|
|
373
|
+
|
|
374
|
+
@type t :: %__MODULE__{
|
|
375
|
+
attractions_searched: non_neg_integer(),
|
|
376
|
+
errors: [String.t()]
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
@spec new(non_neg_integer(), [String.t()]) :: t()
|
|
380
|
+
def new(attractions_searched, errors \\ []) do
|
|
381
|
+
%__MODULE__{attractions_searched: attractions_searched, errors: errors}
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
@spec empty() :: t()
|
|
385
|
+
def empty, do: new(0, [])
|
|
386
|
+
|
|
387
|
+
@spec add_error(t(), String.t()) :: t()
|
|
388
|
+
def add_error(%__MODULE__{} = report, error) do
|
|
389
|
+
%{report | errors: report.errors ++ [error]}
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
```plantuml
|
|
395
|
+
@startuml
|
|
396
|
+
!theme plain
|
|
397
|
+
|
|
398
|
+
class TravelGuide {
|
|
399
|
+
attraction: Attraction
|
|
400
|
+
subjects: [String]
|
|
401
|
+
search_report: SearchReport
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
class SearchReport {
|
|
405
|
+
attractions_searched: integer
|
|
406
|
+
errors: [String]
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
TravelGuide --> SearchReport
|
|
410
|
+
|
|
411
|
+
note right of SearchReport
|
|
412
|
+
検索の統計情報と
|
|
413
|
+
エラー情報を保持
|
|
414
|
+
end note
|
|
415
|
+
|
|
416
|
+
@enduml
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## テスト戦略
|
|
422
|
+
|
|
423
|
+
### 12.8 関数型プログラミングのテスト
|
|
424
|
+
|
|
425
|
+
関数型プログラミングでは、純粋関数のおかげでテストが非常に簡単になります。
|
|
426
|
+
|
|
427
|
+
```plantuml
|
|
428
|
+
@startuml
|
|
429
|
+
!theme plain
|
|
430
|
+
|
|
431
|
+
rectangle "テストの種類" {
|
|
432
|
+
rectangle "単体テスト" as unit {
|
|
433
|
+
card "純粋関数のテスト"
|
|
434
|
+
card "高速・独立"
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
rectangle "プロパティベーステスト" as property {
|
|
438
|
+
card "ランダム入力"
|
|
439
|
+
card "不変条件の検証"
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
rectangle "統合テスト" as integration {
|
|
443
|
+
card "コンポーネント連携"
|
|
444
|
+
card "スタブ/モック使用"
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
unit --> property : 補完
|
|
449
|
+
property --> integration : 補完
|
|
450
|
+
|
|
451
|
+
@enduml
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### 12.9 純粋関数のテスト
|
|
455
|
+
|
|
456
|
+
**ソースファイル**: `app/elixir/lib/ch12/testing.ex`
|
|
457
|
+
|
|
458
|
+
純粋関数は入力と出力だけを考えればよいため、テストが簡単です。
|
|
459
|
+
|
|
460
|
+
```elixir
|
|
461
|
+
# テスト対象の純粋関数
|
|
462
|
+
@spec filter_popular_locations([Location.t()], non_neg_integer()) :: [Location.t()]
|
|
463
|
+
def filter_popular_locations(locations, min_population) do
|
|
464
|
+
Enum.filter(locations, fn loc -> loc.population >= min_population end)
|
|
465
|
+
end
|
|
466
|
+
|
|
467
|
+
@spec sort_by_population([Attraction.t()]) :: [Attraction.t()]
|
|
468
|
+
def sort_by_population(attractions) do
|
|
469
|
+
Enum.sort_by(attractions, fn a -> a.location.population end, :desc)
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
@spec aggregate_results([{:ok, any()} | {:error, String.t()}]) ::
|
|
473
|
+
{[any()], [String.t()]}
|
|
474
|
+
def aggregate_results(results) do
|
|
475
|
+
Enum.reduce(results, {[], []}, fn result, {successes, errors} ->
|
|
476
|
+
case result do
|
|
477
|
+
{:ok, value} -> {successes ++ [value], errors}
|
|
478
|
+
{:error, reason} -> {successes, errors ++ [reason]}
|
|
479
|
+
end
|
|
480
|
+
end)
|
|
481
|
+
end
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### 12.10 プロパティベーステスト
|
|
485
|
+
|
|
486
|
+
**ソースファイル**: `app/elixir/lib/ch12/testing.ex`
|
|
487
|
+
|
|
488
|
+
ランダムな入力を生成して不変条件をテストします。
|
|
489
|
+
|
|
490
|
+
```elixir
|
|
491
|
+
@doc """
|
|
492
|
+
プロパティをテスト(指定回数実行)
|
|
493
|
+
"""
|
|
494
|
+
@spec check_property(pos_integer(), (-> boolean())) :: :ok | {:error, String.t()}
|
|
495
|
+
def check_property(iterations, property_fn) do
|
|
496
|
+
results =
|
|
497
|
+
Enum.map(1..iterations, fn _ ->
|
|
498
|
+
try do
|
|
499
|
+
property_fn.()
|
|
500
|
+
rescue
|
|
501
|
+
_ -> false
|
|
502
|
+
end
|
|
503
|
+
end)
|
|
504
|
+
|
|
505
|
+
if Enum.all?(results) do
|
|
506
|
+
:ok
|
|
507
|
+
else
|
|
508
|
+
failed_count = Enum.count(results, &(!&1))
|
|
509
|
+
{:error, "Property failed #{failed_count}/#{iterations} times"}
|
|
510
|
+
end
|
|
511
|
+
end
|
|
512
|
+
|
|
513
|
+
@doc """
|
|
514
|
+
filter_popular_locations の不変条件をテスト
|
|
515
|
+
"""
|
|
516
|
+
@spec verify_filter_properties(pos_integer()) :: :ok | {:error, String.t()}
|
|
517
|
+
def verify_filter_properties(iterations) do
|
|
518
|
+
check_property(iterations, fn ->
|
|
519
|
+
locations = random_locations(:rand.uniform(20))
|
|
520
|
+
min_population = random_positive_int(5_000_000)
|
|
521
|
+
|
|
522
|
+
result = TravelGuide.filter_popular_locations(locations, min_population)
|
|
523
|
+
|
|
524
|
+
# プロパティ1: 結果のサイズは入力以下
|
|
525
|
+
size_property = length(result) <= length(locations)
|
|
526
|
+
|
|
527
|
+
# プロパティ2: 結果のすべての要素は条件を満たす
|
|
528
|
+
all_meet_condition = Enum.all?(result, fn loc -> loc.population >= min_population end)
|
|
529
|
+
|
|
530
|
+
# プロパティ3: 条件を満たす要素はすべて結果に含まれる
|
|
531
|
+
qualifying = Enum.filter(locations, fn loc -> loc.population >= min_population end)
|
|
532
|
+
all_included = Enum.all?(qualifying, fn loc -> loc in result end)
|
|
533
|
+
|
|
534
|
+
size_property and all_meet_condition and all_included
|
|
535
|
+
end)
|
|
536
|
+
end
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
```plantuml
|
|
540
|
+
@startuml
|
|
541
|
+
!theme plain
|
|
542
|
+
|
|
543
|
+
rectangle "プロパティベーステスト" {
|
|
544
|
+
card "random_location/0" as gen
|
|
545
|
+
card "ランダムデータ生成" as random
|
|
546
|
+
card "プロパティ検証" as verify
|
|
547
|
+
card "N回繰り返しテスト" as repeat
|
|
548
|
+
|
|
549
|
+
gen --> random
|
|
550
|
+
random --> verify
|
|
551
|
+
verify --> repeat
|
|
552
|
+
repeat --> random : 繰り返し
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
note bottom
|
|
556
|
+
ランダムな入力で
|
|
557
|
+
不変条件を検証
|
|
558
|
+
end note
|
|
559
|
+
|
|
560
|
+
@enduml
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
### 12.11 ランダムデータ生成
|
|
564
|
+
|
|
565
|
+
```elixir
|
|
566
|
+
@doc """
|
|
567
|
+
ランダムな文字列を生成
|
|
568
|
+
"""
|
|
569
|
+
@spec random_string(pos_integer()) :: String.t()
|
|
570
|
+
def random_string(length) do
|
|
571
|
+
:crypto.strong_rand_bytes(length)
|
|
572
|
+
|> Base.encode64()
|
|
573
|
+
|> binary_part(0, length)
|
|
574
|
+
end
|
|
575
|
+
|
|
576
|
+
@doc """
|
|
577
|
+
ランダムな Location を生成
|
|
578
|
+
"""
|
|
579
|
+
@spec random_location() :: Location.t()
|
|
580
|
+
def random_location do
|
|
581
|
+
id = LocationId.new("Q#{random_positive_int(1_000_000)}")
|
|
582
|
+
name = random_string(8)
|
|
583
|
+
population = random_positive_int(10_000_000)
|
|
584
|
+
Location.new(id, name, population)
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
@doc """
|
|
588
|
+
ランダムな Attraction を生成
|
|
589
|
+
"""
|
|
590
|
+
@spec random_attraction() :: Attraction.t()
|
|
591
|
+
def random_attraction do
|
|
592
|
+
name = random_string(10)
|
|
593
|
+
description = if :rand.uniform(2) == 1, do: random_string(20), else: nil
|
|
594
|
+
location = random_location()
|
|
595
|
+
Attraction.new(name, description, location)
|
|
596
|
+
end
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
### 12.12 統合テスト
|
|
600
|
+
|
|
601
|
+
```elixir
|
|
602
|
+
@doc """
|
|
603
|
+
TravelGuide の統合テストを実行
|
|
604
|
+
"""
|
|
605
|
+
@spec run_integration_tests() :: {:ok, map()}
|
|
606
|
+
def run_integration_tests do
|
|
607
|
+
tests = [
|
|
608
|
+
{:normal_case, fn ->
|
|
609
|
+
case TravelGuide.travel_guide(TravelGuide.TestDataAccess, "Tokyo") do
|
|
610
|
+
{:ok, guide} ->
|
|
611
|
+
guide.attraction.name == "Tokyo Tower" and
|
|
612
|
+
length(guide.subjects) > 0 and
|
|
613
|
+
guide.search_report.errors == []
|
|
614
|
+
|
|
615
|
+
_ ->
|
|
616
|
+
false
|
|
617
|
+
end
|
|
618
|
+
end},
|
|
619
|
+
{:empty_result, fn ->
|
|
620
|
+
case TravelGuide.travel_guide(TravelGuide.TestDataAccess, "Empty") do
|
|
621
|
+
{:error, "No attractions found"} -> true
|
|
622
|
+
_ -> false
|
|
623
|
+
end
|
|
624
|
+
end},
|
|
625
|
+
{:error_handling, fn ->
|
|
626
|
+
case TravelGuide.travel_guide(TravelGuide.FailingDataAccess, "Test") do
|
|
627
|
+
{:ok, guide} ->
|
|
628
|
+
length(guide.search_report.errors) == 2
|
|
629
|
+
|
|
630
|
+
_ ->
|
|
631
|
+
false
|
|
632
|
+
end
|
|
633
|
+
end},
|
|
634
|
+
{:cached_access, fn ->
|
|
635
|
+
{:ok, cache} = TravelGuide.CachedDataAccess.start_link(TravelGuide.TestDataAccess)
|
|
636
|
+
|
|
637
|
+
result1 = TravelGuide.travel_guide_cached(cache, "Tokyo")
|
|
638
|
+
result2 = TravelGuide.travel_guide_cached(cache, "Tokyo")
|
|
639
|
+
|
|
640
|
+
stats = TravelGuide.CachedDataAccess.cache_stats(cache)
|
|
641
|
+
Agent.stop(cache)
|
|
642
|
+
|
|
643
|
+
case {result1, result2} do
|
|
644
|
+
{{:ok, g1}, {:ok, g2}} ->
|
|
645
|
+
g1.attraction.name == g2.attraction.name and
|
|
646
|
+
stats.attractions > 0
|
|
647
|
+
|
|
648
|
+
_ ->
|
|
649
|
+
false
|
|
650
|
+
end
|
|
651
|
+
end}
|
|
652
|
+
]
|
|
653
|
+
|
|
654
|
+
results =
|
|
655
|
+
Enum.map(tests, fn {name, test_fn} ->
|
|
656
|
+
result =
|
|
657
|
+
try do
|
|
658
|
+
test_fn.()
|
|
659
|
+
rescue
|
|
660
|
+
_ -> false
|
|
661
|
+
end
|
|
662
|
+
|
|
663
|
+
{name, result}
|
|
664
|
+
end)
|
|
665
|
+
|
|
666
|
+
passed = Enum.count(results, fn {_, r} -> r end)
|
|
667
|
+
failed = Enum.count(results, fn {_, r} -> !r end)
|
|
668
|
+
|
|
669
|
+
{:ok, %{passed: passed, failed: failed, results: results}}
|
|
670
|
+
end
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
```plantuml
|
|
674
|
+
@startuml
|
|
675
|
+
!theme plain
|
|
676
|
+
|
|
677
|
+
rectangle "テスト構成" {
|
|
678
|
+
rectangle "本番" as prod {
|
|
679
|
+
interface "DataAccess" as da1
|
|
680
|
+
class "WikidataDataAccess" as wda
|
|
681
|
+
da1 <|.. wda
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
rectangle "テスト" as test {
|
|
685
|
+
interface "DataAccess" as da2
|
|
686
|
+
class "TestDataAccess" as tda
|
|
687
|
+
class "FailingDataAccess" as fda
|
|
688
|
+
da2 <|.. tda
|
|
689
|
+
da2 <|.. fda
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
note bottom of prod
|
|
694
|
+
実際の外部 API に接続
|
|
695
|
+
end note
|
|
696
|
+
|
|
697
|
+
note bottom of test
|
|
698
|
+
テストデータを返す
|
|
699
|
+
即座に結果を返す
|
|
700
|
+
end note
|
|
701
|
+
|
|
702
|
+
@enduml
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
### 12.13 パフォーマンステスト
|
|
706
|
+
|
|
707
|
+
```elixir
|
|
708
|
+
@doc """
|
|
709
|
+
関数の実行時間を計測
|
|
710
|
+
"""
|
|
711
|
+
@spec measure_time((-> any())) :: {non_neg_integer(), any()}
|
|
712
|
+
def measure_time(fun) do
|
|
713
|
+
{time, result} = :timer.tc(fun)
|
|
714
|
+
{time, result}
|
|
715
|
+
end
|
|
716
|
+
|
|
717
|
+
@doc """
|
|
718
|
+
キャッシュの効果を測定
|
|
719
|
+
"""
|
|
720
|
+
@spec measure_cache_effect(pos_integer()) :: {:ok, map()}
|
|
721
|
+
def measure_cache_effect(iterations) do
|
|
722
|
+
# キャッシュなしの時間
|
|
723
|
+
{uncached_time, _} =
|
|
724
|
+
measure_time(fn ->
|
|
725
|
+
Enum.each(1..iterations, fn _ ->
|
|
726
|
+
TravelGuide.travel_guide(TravelGuide.TestDataAccess, "Tokyo")
|
|
727
|
+
end)
|
|
728
|
+
end)
|
|
729
|
+
|
|
730
|
+
# キャッシュありの時間
|
|
731
|
+
{:ok, cache} = TravelGuide.CachedDataAccess.start_link(TravelGuide.TestDataAccess)
|
|
732
|
+
|
|
733
|
+
{cached_time, _} =
|
|
734
|
+
measure_time(fn ->
|
|
735
|
+
Enum.each(1..iterations, fn _ ->
|
|
736
|
+
TravelGuide.travel_guide_cached(cache, "Tokyo")
|
|
737
|
+
end)
|
|
738
|
+
end)
|
|
739
|
+
|
|
740
|
+
Agent.stop(cache)
|
|
741
|
+
|
|
742
|
+
{:ok,
|
|
743
|
+
%{
|
|
744
|
+
uncached_time: uncached_time,
|
|
745
|
+
cached_time: cached_time,
|
|
746
|
+
speedup: uncached_time / max(cached_time, 1)
|
|
747
|
+
}}
|
|
748
|
+
end
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
### 12.14 テストピラミッド
|
|
752
|
+
|
|
753
|
+
```plantuml
|
|
754
|
+
@startuml
|
|
755
|
+
!theme plain
|
|
756
|
+
|
|
757
|
+
rectangle "テストピラミッド" {
|
|
758
|
+
rectangle "E2E テスト\n(少数)" as e2e
|
|
759
|
+
rectangle "統合テスト\n(中程度)" as integration
|
|
760
|
+
rectangle "単体テスト + プロパティテスト\n(多数)" as unit
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
e2e -[hidden]down- integration
|
|
764
|
+
integration -[hidden]down- unit
|
|
765
|
+
|
|
766
|
+
note right of unit
|
|
767
|
+
FP では純粋関数が多いため
|
|
768
|
+
単体テストが非常に効果的
|
|
769
|
+
end note
|
|
770
|
+
|
|
771
|
+
@enduml
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
---
|
|
775
|
+
|
|
776
|
+
## まとめ
|
|
777
|
+
|
|
778
|
+
### Part VI で学んだこと
|
|
779
|
+
|
|
780
|
+
```plantuml
|
|
781
|
+
@startuml
|
|
782
|
+
!theme plain
|
|
783
|
+
|
|
784
|
+
rectangle "Part VI: 実践的なアプリケーション" {
|
|
785
|
+
rectangle "ドメインモデル" as model {
|
|
786
|
+
card "構造体による型定義"
|
|
787
|
+
card "Value Object パターン"
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
rectangle "データアクセス" as data {
|
|
791
|
+
card "@behaviour による抽象化"
|
|
792
|
+
card "スタブ実装"
|
|
793
|
+
card "Agent によるキャッシュ"
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
rectangle "テスト戦略" as test {
|
|
797
|
+
card "純粋関数のテスト"
|
|
798
|
+
card "プロパティベーステスト"
|
|
799
|
+
card "統合テスト"
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
model --> data
|
|
804
|
+
data --> test
|
|
805
|
+
|
|
806
|
+
@enduml
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
### キーポイント
|
|
810
|
+
|
|
811
|
+
1. **@behaviour による抽象化**: DataAccess 振る舞いで外部依存を抽象化
|
|
812
|
+
2. **Agent でキャッシュ**: スレッドセーフな状態管理
|
|
813
|
+
3. **タプルでエラー処理**: `{:ok, value}` / `{:error, reason}` で明示的なエラーハンドリング
|
|
814
|
+
4. **SearchReport**: テスト可能性と可観測性の向上
|
|
815
|
+
5. **スタブ**: 外部依存を差し替えてテスト
|
|
816
|
+
6. **プロパティベーステスト**: ランダム入力で不変条件を検証
|
|
817
|
+
|
|
818
|
+
### Scala との対比
|
|
819
|
+
|
|
820
|
+
| 概念 | Scala | Elixir |
|
|
821
|
+
|------|-------|--------|
|
|
822
|
+
| インターフェース | `trait` | `@behaviour` |
|
|
823
|
+
| 状態管理 | `Ref[IO, A]` | `Agent` |
|
|
824
|
+
| リソース管理 | `Resource[IO, A]` | プロセス / `with` |
|
|
825
|
+
| エラー処理 | `Either[E, A]` | `{:ok, a} \| {:error, e}` |
|
|
826
|
+
| 非同期処理 | `IO[A]` | `Task` / `GenServer` |
|
|
827
|
+
| キャッシュ | `Ref` + `Map` | `Agent` + `Map` |
|
|
828
|
+
|
|
829
|
+
### 学習の総括
|
|
830
|
+
|
|
831
|
+
```plantuml
|
|
832
|
+
@startuml
|
|
833
|
+
!theme plain
|
|
834
|
+
left to right direction
|
|
835
|
+
|
|
836
|
+
rectangle "Elixir FP の学習パス" {
|
|
837
|
+
card "Part I\n基礎" as p1
|
|
838
|
+
card "Part II\nイミュータブル操作" as p2
|
|
839
|
+
card "Part III\n型とパターン" as p3
|
|
840
|
+
card "Part IV\nStream と再帰" as p4
|
|
841
|
+
card "Part V\n並行処理・OTP" as p5
|
|
842
|
+
card "Part VI\n実践" as p6
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
p1 --> p2
|
|
846
|
+
p2 --> p3
|
|
847
|
+
p3 --> p4
|
|
848
|
+
p4 --> p5
|
|
849
|
+
p5 --> p6
|
|
850
|
+
|
|
851
|
+
@enduml
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
---
|
|
855
|
+
|
|
856
|
+
## 演習問題
|
|
857
|
+
|
|
858
|
+
### 問題 1: DataAccess の拡張
|
|
859
|
+
|
|
860
|
+
以下の要件で `DataAccess` を拡張してください:
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
- 新しいコールバック `find_restaurants_near_location` を追加
|
|
864
|
+
- 戻り値は `{:ok, [Restaurant.t()]} | {:error, String.t()}`
|
|
865
|
+
|
|
866
|
+
<details>
|
|
867
|
+
<summary>解答</summary>
|
|
868
|
+
|
|
869
|
+
```elixir
|
|
870
|
+
defmodule Restaurant do
|
|
871
|
+
defstruct [:name, :cuisine, :rating, :location]
|
|
872
|
+
|
|
873
|
+
@type t :: %__MODULE__{
|
|
874
|
+
name: String.t(),
|
|
875
|
+
cuisine: String.t(),
|
|
876
|
+
rating: float(),
|
|
877
|
+
location: Location.t()
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
@spec new(String.t(), String.t(), float(), Location.t()) :: t()
|
|
881
|
+
def new(name, cuisine, rating, location) do
|
|
882
|
+
%__MODULE__{name: name, cuisine: cuisine, rating: rating, location: location}
|
|
883
|
+
end
|
|
884
|
+
end
|
|
885
|
+
|
|
886
|
+
# DataAccess に追加
|
|
887
|
+
@callback find_restaurants_near_location(LocationId.t(), pos_integer()) ::
|
|
888
|
+
{:ok, [Restaurant.t()]} | {:error, String.t()}
|
|
889
|
+
|
|
890
|
+
# TestDataAccess の実装
|
|
891
|
+
@impl true
|
|
892
|
+
def find_restaurants_near_location(_location_id, limit) do
|
|
893
|
+
restaurants = [
|
|
894
|
+
Restaurant.new("Test Restaurant 1", "Japanese", 4.5, @test_location),
|
|
895
|
+
Restaurant.new("Test Restaurant 2", "Italian", 4.0, @test_location)
|
|
896
|
+
]
|
|
897
|
+
|
|
898
|
+
{:ok, Enum.take(restaurants, limit)}
|
|
899
|
+
end
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
</details>
|
|
903
|
+
|
|
904
|
+
### 問題 2: プロパティベーステスト
|
|
905
|
+
|
|
906
|
+
以下の関数に対するプロパティベーステストを書いてください:
|
|
907
|
+
|
|
908
|
+
```elixir
|
|
909
|
+
def merge_subjects(artists, movies) do
|
|
910
|
+
Enum.map(artists, & &1.name) ++ Enum.map(movies, & &1.name)
|
|
911
|
+
end
|
|
912
|
+
```
|
|
913
|
+
|
|
914
|
+
<details>
|
|
915
|
+
<summary>解答</summary>
|
|
916
|
+
|
|
917
|
+
```elixir
|
|
918
|
+
@spec verify_merge_properties(pos_integer()) :: :ok | {:error, String.t()}
|
|
919
|
+
def verify_merge_properties(iterations) do
|
|
920
|
+
check_property(iterations, fn ->
|
|
921
|
+
artist_count = :rand.uniform(10)
|
|
922
|
+
movie_count = :rand.uniform(10)
|
|
923
|
+
|
|
924
|
+
artists = Enum.map(1..artist_count, fn i ->
|
|
925
|
+
MusicArtist.new("Artist #{i}", nil)
|
|
926
|
+
end)
|
|
927
|
+
|
|
928
|
+
movies = Enum.map(1..movie_count, fn i ->
|
|
929
|
+
Movie.new("Movie #{i}", nil)
|
|
930
|
+
end)
|
|
931
|
+
|
|
932
|
+
result = TravelGuide.merge_subjects(artists, movies)
|
|
933
|
+
|
|
934
|
+
# プロパティ1: 結果の長さは入力の合計
|
|
935
|
+
length_property = length(result) == artist_count + movie_count
|
|
936
|
+
|
|
937
|
+
# プロパティ2: すべてのアーティスト名が含まれる
|
|
938
|
+
artist_names = Enum.map(artists, & &1.name)
|
|
939
|
+
artists_included = Enum.all?(artist_names, fn n -> n in result end)
|
|
940
|
+
|
|
941
|
+
# プロパティ3: すべての映画名が含まれる
|
|
942
|
+
movie_names = Enum.map(movies, & &1.name)
|
|
943
|
+
movies_included = Enum.all?(movie_names, fn n -> n in result end)
|
|
944
|
+
|
|
945
|
+
length_property and artists_included and movies_included
|
|
946
|
+
end)
|
|
947
|
+
end
|
|
948
|
+
```
|
|
949
|
+
|
|
950
|
+
</details>
|
|
951
|
+
|
|
952
|
+
### 問題 3: キャッシュの有効期限
|
|
953
|
+
|
|
954
|
+
`CachedDataAccess` にキャッシュの有効期限機能を追加してください。
|
|
955
|
+
|
|
956
|
+
<details>
|
|
957
|
+
<summary>解答</summary>
|
|
958
|
+
|
|
959
|
+
```elixir
|
|
960
|
+
defmodule CachedDataAccessWithTTL do
|
|
961
|
+
@moduledoc """
|
|
962
|
+
TTL(有効期限)付きキャッシュ
|
|
963
|
+
"""
|
|
964
|
+
|
|
965
|
+
@default_ttl_ms 60_000 # 60秒
|
|
966
|
+
|
|
967
|
+
@spec start_link(module(), pos_integer()) :: {:ok, pid()}
|
|
968
|
+
def start_link(data_access_module, ttl_ms \\ @default_ttl_ms) do
|
|
969
|
+
Agent.start_link(fn ->
|
|
970
|
+
%{
|
|
971
|
+
module: data_access_module,
|
|
972
|
+
ttl_ms: ttl_ms,
|
|
973
|
+
attractions_cache: %{} # key => {value, timestamp}
|
|
974
|
+
}
|
|
975
|
+
end)
|
|
976
|
+
end
|
|
977
|
+
|
|
978
|
+
@spec find_attractions(pid(), String.t(), DataAccess.ordering(), pos_integer()) ::
|
|
979
|
+
{:ok, [Attraction.t()]} | {:error, String.t()}
|
|
980
|
+
def find_attractions(cache, name, ordering, limit) do
|
|
981
|
+
key = "#{name}-#{ordering}-#{limit}"
|
|
982
|
+
now = System.monotonic_time(:millisecond)
|
|
983
|
+
|
|
984
|
+
Agent.get_and_update(cache, fn state ->
|
|
985
|
+
case Map.get(state.attractions_cache, key) do
|
|
986
|
+
{cached, timestamp} when now - timestamp < state.ttl_ms ->
|
|
987
|
+
# キャッシュが有効
|
|
988
|
+
{{:ok, cached}, state}
|
|
989
|
+
|
|
990
|
+
_ ->
|
|
991
|
+
# キャッシュが無効または存在しない
|
|
992
|
+
result = state.module.find_attractions(name, ordering, limit)
|
|
993
|
+
|
|
994
|
+
case result do
|
|
995
|
+
{:ok, attractions} ->
|
|
996
|
+
new_cache = Map.put(state.attractions_cache, key, {attractions, now})
|
|
997
|
+
{result, %{state | attractions_cache: new_cache}}
|
|
998
|
+
|
|
999
|
+
{:error, _} = error ->
|
|
1000
|
+
{error, state}
|
|
1001
|
+
end
|
|
1002
|
+
end
|
|
1003
|
+
end)
|
|
1004
|
+
end
|
|
1005
|
+
end
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
</details>
|
|
1009
|
+
|
|
1010
|
+
---
|
|
1011
|
+
|
|
1012
|
+
## シリーズ全体の総括
|
|
1013
|
+
|
|
1014
|
+
本シリーズでは、「Grokking Functional Programming」の内容に沿って、Elixir による関数型プログラミングの基礎から実践的なアプリケーション構築までを学びました。
|
|
1015
|
+
|
|
1016
|
+
### 学んだ主な概念
|
|
1017
|
+
|
|
1018
|
+
| Part | 章 | 主な概念 |
|
|
1019
|
+
|------|-----|----------|
|
|
1020
|
+
| I | 1-2 | 純粋関数、イミュータビリティ |
|
|
1021
|
+
| II | 3-5 | パイプ演算子、高階関数、Enum |
|
|
1022
|
+
| III | 6-7 | パターンマッチング、with 式 |
|
|
1023
|
+
| IV | 8-9 | Stream、再帰 |
|
|
1024
|
+
| V | 10-11 | 並行処理、OTP パターン |
|
|
1025
|
+
| VI | 12 | 実践アプリケーション、テスト |
|
|
1026
|
+
|
|
1027
|
+
### 関数型プログラミングの利点
|
|
1028
|
+
|
|
1029
|
+
1. **予測可能性**: 純粋関数は同じ入力に対して常に同じ出力
|
|
1030
|
+
2. **テスト容易性**: 副作用がないためテストが簡単
|
|
1031
|
+
3. **合成可能性**: パイプ演算子で小さな関数を組み合わせ
|
|
1032
|
+
4. **並行安全性**: イミュータブルデータは競合状態を防ぐ
|
|
1033
|
+
5. **パターンマッチング**: 明確で安全なデータ処理
|
|
1034
|
+
|
|
1035
|
+
### Elixir 特有の利点
|
|
1036
|
+
|
|
1037
|
+
1. **OTP**: 堅牢な並行処理フレームワーク
|
|
1038
|
+
2. **BEAM VM**: 軽量プロセスと高いスケーラビリティ
|
|
1039
|
+
3. **パイプ演算子**: 読みやすいデータ変換
|
|
1040
|
+
4. **パターンマッチング**: 強力な分岐とデストラクチャリング
|
|
1041
|
+
5. **ホットコードスワップ**: 無停止でのコード更新
|
|
1042
|
+
|
|
1043
|
+
### 次のステップ
|
|
1044
|
+
|
|
1045
|
+
- Phoenix フレームワークでの Web 開発
|
|
1046
|
+
- Ecto でのデータベース操作
|
|
1047
|
+
- LiveView でのリアルタイム UI
|
|
1048
|
+
- Nerves での組み込み開発
|
|
1049
|
+
- 実際のプロジェクトで FP を適用する
|