From 9f778f5b8f81fe61b7ec53629b1e23832b1038f1 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Fri, 12 Sep 2025 10:52:06 +0900 Subject: [PATCH 1/9] Refactor sidebar page assignments for English and Japanese to improve clarity and maintainability --- _includes/manuals/1.0/en/contents.html | 6 ++++-- _includes/manuals/1.0/ja/contents.html | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/_includes/manuals/1.0/en/contents.html b/_includes/manuals/1.0/en/contents.html index e3930fa..77626a0 100644 --- a/_includes/manuals/1.0/en/contents.html +++ b/_includes/manuals/1.0/en/contents.html @@ -16,14 +16,16 @@ diff --git a/_includes/manuals/1.0/ja/contents.html b/_includes/manuals/1.0/ja/contents.html index 707221b..7588b88 100644 --- a/_includes/manuals/1.0/ja/contents.html +++ b/_includes/manuals/1.0/ja/contents.html @@ -16,14 +16,16 @@ From c33989cab1e6333d74641480bbd4204ca4a74413 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Fri, 12 Sep 2025 11:19:00 +0900 Subject: [PATCH 2/9] Fix language separation in navigation for GitHub Pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add explicit path-based filtering to ensure each language navigation only shows pages from its respective language directory. 🀖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- _includes/manuals/1.0/en/contents.html | 7 ++++++- _includes/manuals/1.0/ja/contents.html | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/_includes/manuals/1.0/en/contents.html b/_includes/manuals/1.0/en/contents.html index 77626a0..949b92f 100644 --- a/_includes/manuals/1.0/en/contents.html +++ b/_includes/manuals/1.0/en/contents.html @@ -16,15 +16,20 @@ - + \ No newline at end of file diff --git a/_includes/manuals/1.0/ja/contents.html b/_includes/manuals/1.0/ja/contents.html index 96f6f14..85bc93d 100644 --- a/_includes/manuals/1.0/ja/contents.html +++ b/_includes/manuals/1.0/ja/contents.html @@ -16,12 +16,10 @@ - + \ No newline at end of file From ac40a3b99e04bcd1ae95b5c505da5b96df56f4fa Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Fri, 12 Sep 2025 11:41:18 +0900 Subject: [PATCH 4/9] Add automatic language detection for Learn More button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement browser language detection similar to BEAR.Sunday: - Add 'intl' class to Learn More button - JavaScript detects navigator.language - Auto-redirect Japanese users to /ja/ manual - English users go to /en/ manual by default 🀖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- index.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index e35a05b..f9b1755 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,18 @@ The Ontological Programming Framework for PHP

-
+ Learn more » + From d187dadf97b4c26b0288ffc4c019f997f2f2ed0b Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Fri, 12 Sep 2025 13:30:37 +0900 Subject: [PATCH 5/9] Add NewsWeek-style philosophical quotations and section headings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added philosophical quotations to chapter openings in both languages - Implemented consistent NewsWeek-style formatting with proper attribution - Added section headings after quotations for better structure: - Chapter 1: "たず、これを芋おください" / "First, Look at This" - Chapter 2: "出発点" / "The Beginning" - Chapter 3: "内圚ず超越" / "Immanence Meets Transcendence" - Chapter 4: "終着点" / "The Destination" - Chapter 12: "あなたが発芋したもの" / "What You Have Discovered" - Enhanced Chapter 4 with $been concept integration and temporal completion - Unified philosophical framework across English and Japanese versions 🀖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- manuals/1.0/en/01-overview.md | 6 +- manuals/1.0/en/02-input-classes.md | 6 ++ manuals/1.0/en/03-being-classes.md | 6 ++ manuals/1.0/en/04-final-objects.md | 6 ++ .../1.0/en/12-from-doing-to-being-final.md | 6 +- manuals/1.0/ja/01-overview.md | 6 +- manuals/1.0/ja/02-input-classes.md | 6 ++ manuals/1.0/ja/03-being-classes.md | 6 ++ manuals/1.0/ja/04-final-objects.md | 98 ++++++++++++++----- .../1.0/ja/12-from-doing-to-being-final.md | 6 +- 10 files changed, 125 insertions(+), 27 deletions(-) diff --git a/manuals/1.0/en/01-overview.md b/manuals/1.0/en/01-overview.md index 1dc98aa..3361b5f 100644 --- a/manuals/1.0/en/01-overview.md +++ b/manuals/1.0/en/01-overview.md @@ -5,7 +5,11 @@ category: Manual permalink: /manuals/1.0/en/01-overview.html --- -# Overview: A Different Way to Think About Code +# A Different Way to Think About Code + +> "The real voyage of discovery consists not in seeking new landscapes, but in having new eyes." +> +> —Marcel Proust, 'The Prisoner' (In Search of Lost Time, Volume 5) 1923 ## First, Look at This diff --git a/manuals/1.0/en/02-input-classes.md b/manuals/1.0/en/02-input-classes.md index 9720c34..54914ba 100644 --- a/manuals/1.0/en/02-input-classes.md +++ b/manuals/1.0/en/02-input-classes.md @@ -7,6 +7,12 @@ permalink: /manuals/1.0/en/02-input-classes.html # Input Classes +> "We begin from conditions we did not choose, and from there we build our existence." +> +> —From Heidegger's concept of Geworfenheit (thrownness) in 'Being and Time' (1927) + +## The Beginning + Input Classes are the starting point of every transformation in Be Framework. They contain only what the object itself possesses—no external dependencies. Think of it as the object's identity. These elements exist within the object, forming what we call the object's **Immanent Nature**. diff --git a/manuals/1.0/en/03-being-classes.md b/manuals/1.0/en/03-being-classes.md index d38d993..1acf9e2 100644 --- a/manuals/1.0/en/03-being-classes.md +++ b/manuals/1.0/en/03-being-classes.md @@ -7,6 +7,12 @@ permalink: /manuals/1.0/en/03-being-classes.html # Being Classes +> "The Way constantly does nothing, yet nothing is left undone." +> +> —Laozi, Tao Te Ching, Chapter 37 (6th century BC) + +## Immanence Meets Transcendence + Being Classes are where transformation actually occurs. The object's own nature (**Immanent Nature**) meets forces provided from the outside (**Transcendent Forces**), and a new being is born. If Input Classes are the "beginning," Being Classes express the "moment of change." diff --git a/manuals/1.0/en/04-final-objects.md b/manuals/1.0/en/04-final-objects.md index 45f2e3b..3fc7f06 100644 --- a/manuals/1.0/en/04-final-objects.md +++ b/manuals/1.0/en/04-final-objects.md @@ -7,6 +7,12 @@ permalink: /manuals/1.0/en/04-final-objects.html # Final Objects +> "You are not me. How can you know that I don't know the feelings of fish?" +> +> —Zhuangzi's reply when asked "You are not a fish. How can you know the feelings of fish?" (Zhuangzi, 4th century BC) + +## The Destination + Final Objects represent the destination of metamorphosis—complete, transformed beings that embody the user's actual interest. These are what the application ultimately cares about. ## Characteristics of Final Objects diff --git a/manuals/1.0/en/12-from-doing-to-being-final.md b/manuals/1.0/en/12-from-doing-to-being-final.md index 37157b0..5c63655 100644 --- a/manuals/1.0/en/12-from-doing-to-being-final.md +++ b/manuals/1.0/en/12-from-doing-to-being-final.md @@ -7,7 +7,11 @@ permalink: /manuals/1.0/en/12-from-doing-to-being-final.html # From Doing to Being: The Bigger Picture -> *"The real voyage of discovery consists not in seeking new landscapes, but in having new eyes."* — Marcel Proust +> "All things that exist are in the process of becoming." +> +> —Heraclitus, Fragments (c. 500 BC) + +## What You Have Discovered You've written Input Classes, created Being Classes, and watched objects transform rather than mutate. diff --git a/manuals/1.0/ja/01-overview.md b/manuals/1.0/ja/01-overview.md index caff87a..5faf23a 100644 --- a/manuals/1.0/ja/01-overview.md +++ b/manuals/1.0/ja/01-overview.md @@ -5,7 +5,11 @@ category: Manual permalink: /manuals/1.0/ja/01-overview.html --- -## 抂芁: 新しいパラダむム +# 抂芁 + +> 「真の発芋の航海は、新しい颚景を求めるこずではなく、新しい目を持぀こずにある。」 +> +>   —マルセル・プルヌスト『囚われの女』À la recherche du temps perdu 第5巻1923幎 ## たず、これを芋おください diff --git a/manuals/1.0/ja/02-input-classes.md b/manuals/1.0/ja/02-input-classes.md index 7e3f178..ff08507 100644 --- a/manuals/1.0/ja/02-input-classes.md +++ b/manuals/1.0/ja/02-input-classes.md @@ -7,6 +7,12 @@ permalink: /manuals/1.0/ja/02-input-classes.html # 入力クラス +> 「私たちは自分で遞択できない条件から始たり、そこから自分の存圚を築く」 +> +>   —ハむデガヌの被投性Geworfenheit抂念より『存圚ず時間』1927幎 + +## 出発点 + 入力クラスは、Beフレヌムワヌクにおけるすべおの倉容の出発点です。 ここにはオブゞェクト自身が持぀芁玠だけが含たれ、倖郚䟝存がありたせん。いわばオブゞェクトのアむデンティティです。オブゞェクトの内偎にあるものなので、これを**内圚的性質、むマナンスImmanence**ず呌びたす。 diff --git a/manuals/1.0/ja/03-being-classes.md b/manuals/1.0/ja/03-being-classes.md index 0b1d419..423b2e0 100644 --- a/manuals/1.0/ja/03-being-classes.md +++ b/manuals/1.0/ja/03-being-classes.md @@ -7,6 +7,12 @@ permalink: /manuals/1.0/ja/03-being-classes.html # 存圚クラス +> 「道垞無為而無䞍為」 +> +> —道は垞に無為にしお、而も為さざるこずなし老子『道埳経』第䞉十䞃章 玀元前6䞖玀 + +## 内圚ず超越 + 存圚クラスは倉容が実際に起こる堎所です。 オブゞェクト自身が持぀性質**内圚的性質むマナンス**ず、倖郚から提䟛される力**超越的な力トランセンデンス**が出䌚い、次の新しい存圚が生たれたす。入力クラスが「始たり」なら、存圚クラスは「倉わる瞬間」を衚珟したす。 diff --git a/manuals/1.0/ja/04-final-objects.md b/manuals/1.0/ja/04-final-objects.md index e3f2713..077ee58 100644 --- a/manuals/1.0/ja/04-final-objects.md +++ b/manuals/1.0/ja/04-final-objects.md @@ -7,19 +7,39 @@ permalink: /manuals/1.0/ja/04-final-objects.html # 最終オブゞェクト -最終オブゞェクトは倉容の目的地を衚したす—ナヌザヌの実際の関心を䜓珟する、完党で倉容した存圚です。これらはアプリケヌションが最終的に気にかけるものです。 +> 「あなたは私ではない。どうしお私が魚の気持ちを知らないず分かるのか」 +> +> —「あなたは魚ではない。どうしお魚の気持ちが分かるのか」ず問われた時に荘子が返した蚀葉 『荘子』玀元前4䞖玀 + +## 終着点 + +最終オブゞェクトは倉容の旅路の到達点です。 +ナヌザヌが求める䟡倀、アプリケヌションが届けたい結果が具珟化された、完党で最終的な存圚です。 + +これは入力クラスから始たった内圚的性質むマナンスが、様々な超越的力トランセンデンスず出䌚い、自然な倉容を経お達成した最終圢態です。アリストテレスの蚀う゚ンテレケむア、すなわち朜圚性が完党に珟実化された状態を䜓珟しおいたす。 ## 最終オブゞェクトの特城 -**完党な存圚**: 最終オブゞェクトは意図された目的のためにさらなる倉容を必芁ずしない、完党に圢成された゚ンティティです。 +**完党性゚ンテレケむア**: これ以䞊の倉容を必芁ずしない、完党に珟実化された存圚です。 + +**ナヌザヌ䟡倀の実珟**: ナヌザヌが本圓に必芁ずするもの、意味のあるデヌタや操䜜の成功結果を衚珟したす。 + +**豊かな状態**: 入力クラスずは察照的に、最終オブゞェクトはドメむンの豊富さを完党に衚珟した存圚です。 + +## 時間的存圚の完党性 + +ここで興味深い問いがありたす。テストが䞍芁になるほどの完党性を持぀オブゞェクトがあったらどうでしょう -**ナヌザヌ䞭心**: これらはナヌザヌが実際に欲しいもの—成功した操䜜、意味のあるデヌタ、実行可胜な結果を衚したす。 +Be Frameworkでは、オブゞェクトの時間的存圚を二぀の軞で捉えたす -**豊富な状態**: 入力クラスずは異なり、最終オブゞェクトは倉容されたデヌタの完党な豊かさを含みたす。 +- **`#[Be]`**: なりたい自分、向かう先未来ぞの方向性 +- **`$been`**: 完了した自分過去完了の自己蚌明 + +埓来のプログラミングでは、オブゞェクトが正しく凊理されたかどうかを倖郚のテストで怜蚌したす。しかし、オブゞェクト自身が完了の蚌拠を内包しおいたらどうでしょう倖郚による怜蚌ではなく、内圚的な自己蚌明が可胜になりたす。 ## 䟋 -### 成功した結果 +### 内圚的自己蚌明を持぀結果 ```php final class SuccessfulOrder { @@ -27,51 +47,79 @@ final class SuccessfulOrder public readonly string $confirmationCode; public readonly DateTimeImmutable $timestamp; public readonly string $message; + public readonly BeenProcessed $been; // 自己蚌明 public function __construct( - #[Input] Money $total, // 怜蚌からの内圚的 - #[Input] CreditCard $card, // 怜蚌からの内圚的 - #[Inject] OrderIdGenerator $generator, // 超越的 - #[Inject] Receipt $receipt // 超越的 + #[Input] Money $total, // 内圚的性質 + #[Input] CreditCard $card, // 内圚的性質 + #[Inject] OrderIdGenerator $generator, // 超越的力 + #[Inject] Receipt $receipt // 超越的力 ) { - $this->orderId = $generator->generate(); // 新しい内圚的 - $this->confirmationCode = $receipt->generate($total); // 新しい内圚的 - $this->timestamp = new DateTimeImmutable(); // 新しい内圚的 - $this->message = "泚文確認: {$this->orderId}"; // 新しい内圚的 + $this->orderId = $generator->generate(); // 新しい内圚的性質 + $this->confirmationCode = $receipt->generate($total); // 新しい内圚的性質 + $this->timestamp = new DateTimeImmutable(); // 新しい内圚的性質 + $this->message = "泚文確認: {$this->orderId}"; // 新しい内圚的性質 + + // 完了の自己蚌明 + $this->been = new BeenProcessed( + actor: $card->getHolderName(), + timestamp: $this->timestamp, + evidence: [ + 'total' => $total->getAmount(), + 'payment_method' => $card->getType(), + 'confirmation' => $this->confirmationCode + ] + ); } } ``` -### 最終オブゞェクトずしおの゚ラヌ状態 +このオブゞェクトは倖郚テストを必芁ずしたせん。`$been`プロパティが完了の完党な蚌拠を内包しおいるからです。 + +### ゚ラヌ状態の自己蚌明 ```php final class FailedOrder { public readonly string $errorCode; public readonly string $message; public readonly DateTimeImmutable $timestamp; + public readonly BeenRejected $been; // 倱敗の自己蚌明 public function __construct( - #[Input] array $errors, // 怜蚌からの内圚的 - #[Inject] Logger $logger, // 超越的 - #[Inject] ErrorCodeGenerator $generator // 超越的 + #[Input] array $errors, // 内圚的性質 + #[Inject] Logger $logger, // 超越的力 + #[Inject] ErrorCodeGenerator $generator // 超越的力 ) { $this->errorCode = $generator->generate(); $this->message = "泚文倱敗: " . implode(', ', $errors); $this->timestamp = new DateTimeImmutable(); + // 倱敗の自己蚌明 + $this->been = new BeenRejected( + reason: 'validation_failed', + timestamp: $this->timestamp, + evidence: [ + 'error_count' => count($errors), + 'error_types' => array_keys($errors), + 'error_code' => $this->errorCode + ] + ); + $logger->logOrderFailure($this->errorCode, $errors); // 副䜜甚 } } ``` +成功も倱敗も、どちらも完了の自己蚌明を持ちたす。倖郚テストではなく、オブゞェクト自身が䜕が起こったかの完党な蚘録を保持しおいるのです。 + ## 最終オブゞェクト vs 入力クラス | 入力クラス | 最終オブゞェクト | |-----------|-----------------| -| 玔粋なアむデンティティ | 豊富で倉容した状態 | -| 出発点 | 目的地 | +| 玔粋なアむデンティティ | 豊かで倉容した状態 | +| 倉容の出発点 | 倉容の到達点 | | ナヌザヌが提䟛するもの | ナヌザヌが受け取るもの | -| 単玔な構造 | 完党な機胜 | +| シンプルな構造 | 完党に実珟された機胜 | ## 耇数の最終的運呜 @@ -99,8 +147,12 @@ if ($order->being instanceof SuccessfulOrder) { 2. **存圚クラス**: 倉容段階「これが私の倉化の仕方です」 3. **最終オブゞェクト**: 完党な結果「これが私がなったものです」 -ナヌザヌは䞻に入力圌らが提䟛するものず最終オブゞェクト圌らが受け取るものに関心を持ちたす。間にある存圚クラスはフレヌムワヌクの責任です—意図ず結果の間の橋を䜜る倉容の機械です。 +ナヌザヌは䞻に入力圌らが提䟛するものず最終オブゞェクト圌らが受け取るものに関心を持ちたす。間にある存圚クラスは私たち蚭蚈者の責任です。意図ず結果の間の橋枡しをするためにドメむンの時間的倉容をよく理解し、その倉容の仕組みを蚭蚈するこずが重芁です。 + +## 倉容の完成 + +最終オブゞェクトは、゚ンテレケむア完党実珟の状態を衚珟したす。倉容の必芁がもうない、完党に実珟された存圚です。 -## 自然な完成 +入力クラスから始たった内圚的性質むマナンスが、様々な超越的力トランセンデンスず出䌚いながら自然な倉容を経お、぀いに到達した完成圢です。ここにはもう「なろうずする」努力も、「倉わろうずする」意図もありたせん。すべおが完了し、ナヌザヌが本圓に求めおいた䟡倀がここに実珟されおいたす。私たちのシステムの本質的な䟡倀です。 -最終オブゞェクトは自然な倉容の完成を䜓珟したす。これらはもう䜕かを「する」必芁がありたせん—単玔に、元の入力が䞖界の胜力ず出䌚うこずから生たれるこずを意図された結果*である*のです。 \ No newline at end of file +これこそが、Be Frameworkが目指すプログラミングの到達点—「䜕をするか」ではなく「䜕であるか」が䜓珟された存圚です。 diff --git a/manuals/1.0/ja/12-from-doing-to-being-final.md b/manuals/1.0/ja/12-from-doing-to-being-final.md index a915665..958f410 100644 --- a/manuals/1.0/ja/12-from-doing-to-being-final.md +++ b/manuals/1.0/ja/12-from-doing-to-being-final.md @@ -7,7 +7,11 @@ permalink: /manuals/1.0/ja/12-from-doing-to-being-final.html # Doingから Beingぞ: より倧きな芖点 -> *「真の発芋の航海は、新しい颚景を求めるこずではなく、新しい目を持぀こずにある。」* — マルセル・プルヌスト +> 「存圚するものは党お生成の途䞊にある」 +> +>   —ヘラクレむトス『断片』玀元前500幎頃 + +## あなたが発芋したもの あなたは入力クラスを曞き、存圚クラスを䜜成し、オブゞェクトが倉異するのではなく倉容するのを芋おきたした。 From b115013f9f52c21e8ec16ab215545417260c3f48 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Fri, 12 Sep 2025 13:31:53 +0900 Subject: [PATCH 6/9] Improve Laozi quotation translation in Chapter 3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change "The Way constantly does nothing" to "The Tao does nothing" for more accurate and concise philosophical expression. 🀖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- manuals/1.0/en/03-being-classes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manuals/1.0/en/03-being-classes.md b/manuals/1.0/en/03-being-classes.md index 1acf9e2..c7fe6f7 100644 --- a/manuals/1.0/en/03-being-classes.md +++ b/manuals/1.0/en/03-being-classes.md @@ -7,7 +7,7 @@ permalink: /manuals/1.0/en/03-being-classes.html # Being Classes -> "The Way constantly does nothing, yet nothing is left undone." +> "The Tao does nothing, yet nothing is left undone." > > —Laozi, Tao Te Ching, Chapter 37 (6th century BC) From 2871cc8ec5b9a8233636b7795546405c334f1aba Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Fri, 12 Sep 2025 13:39:21 +0900 Subject: [PATCH 7/9] Complete $been concept integration in English Chapter 4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added Temporal Completeness section with #[Be] and $been axes - Integrated intrinsic self-evidence with BeenProcessed and BeenRejected examples - Enhanced both success and failure objects with complete temporal evidence - Added philosophical conclusion about entelecheia and transformation completion - Unified English and Japanese versions with identical $been concept depth 🀖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- manuals/1.0/en/04-final-objects.md | 75 +++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 16 deletions(-) diff --git a/manuals/1.0/en/04-final-objects.md b/manuals/1.0/en/04-final-objects.md index 3fc7f06..d0aa83f 100644 --- a/manuals/1.0/en/04-final-objects.md +++ b/manuals/1.0/en/04-final-objects.md @@ -23,9 +23,20 @@ Final Objects represent the destination of metamorphosis—complete, transformed **Rich State**: Unlike Input Classes, Final Objects contain the full richness of transformed data. +## Temporal Completeness + +Here's an intriguing question: What if objects had such completeness that they needed no external testing? + +The Be Framework captures the temporal existence of objects along two axes: + +- **`#[Be]`**: The intended self, the destination (future directionality) +- **`$been`**: The completed self (past perfect self-evidence) + +Traditional programming verifies whether objects have been processed correctly through external tests. But what if objects themselves contained evidence of their completion? Instead of external verification, intrinsic self-evidence becomes possible. + ## Examples -### Successful Outcomes +### Intrinsic Self-Evidence ```php final class SuccessfulOrder { @@ -33,43 +44,71 @@ final class SuccessfulOrder public readonly string $confirmationCode; public readonly DateTimeImmutable $timestamp; public readonly string $message; + public readonly BeenProcessed $been; // Self-evidence public function __construct( - #[Input] Money $total, // Immanent from validation - #[Input] CreditCard $card, // Immanent from validation - #[Inject] OrderIdGenerator $generator, // Transcendent - #[Inject] Receipt $receipt // Transcendent + #[Input] Money $total, // Immanent nature + #[Input] CreditCard $card, // Immanent nature + #[Inject] OrderIdGenerator $generator, // Transcendent force + #[Inject] Receipt $receipt // Transcendent force ) { - $this->orderId = $generator->generate(); // New Immanent - $this->confirmationCode = $receipt->generate($total); // New Immanent - $this->timestamp = new DateTimeImmutable(); // New Immanent - $this->message = "Order confirmed: {$this->orderId}"; // New Immanent + $this->orderId = $generator->generate(); // New immanent nature + $this->confirmationCode = $receipt->generate($total); // New immanent nature + $this->timestamp = new DateTimeImmutable(); // New immanent nature + $this->message = "Order confirmed: {$this->orderId}"; // New immanent nature + + // Self-evidence of completion + $this->been = new BeenProcessed( + actor: $card->getHolderName(), + timestamp: $this->timestamp, + evidence: [ + 'total' => $total->getAmount(), + 'payment_method' => $card->getType(), + 'confirmation' => $this->confirmationCode + ] + ); } } ``` -### Error States as Final Objects +This object requires no external testing. The `$been` property contains complete evidence of completion. + +### Error States with Self-Evidence ```php final class FailedOrder { public readonly string $errorCode; public readonly string $message; public readonly DateTimeImmutable $timestamp; + public readonly BeenRejected $been; // Self-evidence of failure public function __construct( - #[Input] array $errors, // Immanent from validation - #[Inject] Logger $logger, // Transcendent - #[Inject] ErrorCodeGenerator $generator // Transcendent + #[Input] array $errors, // Immanent nature + #[Inject] Logger $logger, // Transcendent force + #[Inject] ErrorCodeGenerator $generator // Transcendent force ) { $this->errorCode = $generator->generate(); $this->message = "Order failed: " . implode(', ', $errors); $this->timestamp = new DateTimeImmutable(); + // Self-evidence of failure + $this->been = new BeenRejected( + reason: 'validation_failed', + timestamp: $this->timestamp, + evidence: [ + 'error_count' => count($errors), + 'error_types' => array_keys($errors), + 'error_code' => $this->errorCode + ] + ); + $logger->logOrderFailure($this->errorCode, $errors); // Side effect } } ``` +Both success and failure carry their own self-evidence of completion. Instead of external tests, the objects themselves maintain complete records of what occurred. + ## Final Objects vs Input Classes | Input Classes | Final Objects | @@ -105,8 +144,12 @@ The path from Input to Final Object represents a complete transformation journey 2. **Being Classes**: Transformation stages ("Here's how I change") 3. **Final Object**: Complete result ("Here's what I became") -Users primarily care about Input (what they provide) and Final Objects (what they get back). The Being Classes in between are the framework's responsibility—the machinery of transformation that creates the bridge between intention and result. +Users primarily care about Input (what they provide) and Final Objects (what they get back). The Being Classes in between are our responsibility as designers. It's crucial to understand the temporal transformation of the domain well and design the mechanisms of that transformation to bridge intention and result. + +## Transformation Complete + +Final Objects express the state of entelecheia (complete realization). They are fully realized beings that no longer need transformation. -## Natural Completion +The immanent nature that began with Input Classes, through encounters with various transcendent forces and natural transformation, finally reaches this completed form. There is no more "trying to become" or "intending to change." Everything is complete, and the value that users truly sought is realized here. This is the essential value of our system. -Final Objects embody the completion of natural transformation. They don't need to "do" anything more—they simply *are* the result that was meant to emerge from the original input's encounter with the world's capabilities. +This is the destination that Be Framework aims for in programming—existence that embodies not "what to do" but "what to be." From 35b11a2b485823d10b3b5ffed0ebb1a7ad205640 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Fri, 12 Sep 2025 14:10:17 +0900 Subject: [PATCH 8/9] Restructure Chapter 5 to eliminate redundancy and enhance clarity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added Heraclitus philosophical quotation with proper NewsWeek-style formatting - Added "倉容の流れ" / "Patterns of Change" section headings after quotations - Consolidated redundant "Branching Destinies" and "Conditional Transformation" into unified "Conditional Branching Pattern" - Removed obvious "Fork-Join Pattern" that was just parallel data collection - Enhanced "Self-Organizing Pipelines" section with UNIX pipes comparison - Updated pattern selection list to remove redundancy - Improved final message to be more natural - Applied consistent structure across both Japanese and English versions 🀖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- manuals/1.0/en/05-metamorphosis-patterns.md | 86 ++++++++++----------- manuals/1.0/ja/05-metamorphosis-patterns.md | 85 ++++++++++---------- 2 files changed, 85 insertions(+), 86 deletions(-) diff --git a/manuals/1.0/en/05-metamorphosis-patterns.md b/manuals/1.0/en/05-metamorphosis-patterns.md index 42a80e8..eda5d4b 100644 --- a/manuals/1.0/en/05-metamorphosis-patterns.md +++ b/manuals/1.0/en/05-metamorphosis-patterns.md @@ -7,7 +7,13 @@ permalink: /manuals/1.0/en/05-metamorphosis-patterns.html # Metamorphosis Patterns -Be Framework supports various patterns of transformation, from simple linear chains to complex branching destinies. Understanding these patterns helps you design natural transformation flows. +> "No man ever steps in the same river twice." +> +> —Heraclitus, Fragments (c. 500 BC) + +## Patterns of Change + +Be Framework supports various patterns of transformation, from simple linear chains to complex branching. Understanding these patterns helps you design natural transformation flows. ## Linear Metamorphic Chain @@ -32,9 +38,9 @@ final class WelcomeMessage { /* ... */ } Each stage naturally leads to the next, like a river flowing to the sea. -## Branching Destinies +## Conditional Branching Pattern -Objects can have multiple possible futures based on their nature: +Objects can have multiple possible futures based on their nature. This is natural transformation that branches into different types based on conditions: ```php #[Be([ApprovedApplication::class, RejectedApplication::class])] @@ -55,42 +61,9 @@ final class ApplicationReview } ``` -The object determines its own destiny through **Type-Driven Metamorphosis**. - -## Fork-Join Pattern - -A single input branches into parallel transformations that later converge: - -```php -#[Be(PersonalizedRecommendation::class)] -final class UserAnalysis -{ - public readonly PersonalizedRecommendation $being; - - public function __construct( - #[Input] string $userId, // Immanent - #[Inject] BehaviorAnalyzer $behavior, // Transcendent - #[Inject] PreferenceAnalyzer $preference, // Transcendent - #[Inject] SocialAnalyzer $social // Transcendent - ) { - // Parallel analysis - $behaviorScore = $behavior->analyze($userId); - $preferenceScore = $preference->analyze($userId); - $socialScore = $social->analyze($userId); - - // Convergence - $this->being = new PersonalizedRecommendation( - $behaviorScore, - $preferenceScore, - $socialScore - ); - } -} -``` - -## Conditional Transformation +### Other Conditional Branching Examples -Sometimes transformation depends on runtime conditions: +Feature levels and permissions follow the same pattern: ```php #[Be([PremiumFeatures::class, BasicFeatures::class])] @@ -111,6 +84,10 @@ final class FeatureActivation } ``` +The object determines its own destiny through **Type-Driven Metamorphosis**. + + + ## Nested Metamorphosis Complex objects can contain their own transformation chains: @@ -134,7 +111,26 @@ final class OrderProcessing ## Self-Organizing Pipelines -The beauty of these patterns is that they're **self-organizing**. Objects declare their own destinies, and the framework naturally follows the transformation paths without external orchestration. +The beauty of these patterns is that they're **self-organizing**. Like UNIX pipes that combine simple commands to create powerful systems, Be Framework combines typed objects to create natural transformation flows. + +### Comparison with UNIX Pipes + +```bash +# UNIX: Text flows through externally controlled pipelines +cat access.log | grep "404" | awk '{print $7}' | sort | uniq -c +``` + +```php +// Be Framework: Rich objects flow through intrinsically controlled pipelines +$finalObject = $becoming(new ApplicationInput($documents)); +// Objects themselves know their next transformation destination +``` + +Key evolution: +- **UNIX**: External shell controls the pipeline +- **Be Framework**: Objects declare their own destiny with `#[Be()]` + +### Self-Organization in Action ```php // No controllers, no orchestrators—just natural flow @@ -147,14 +143,18 @@ match (true) { }; ``` +This self-organization provides: +- No external orchestration needed +- Type safety maintained +- Capabilities provided through dependency injection +- Testable independent components + ## Pattern Selection Choose patterns based on your domain's natural flow: - **Linear**: Sequential processes (validation → processing → completion) -- **Branching**: Decision points (approve/reject, success/failure) -- **Fork-Join**: Parallel analysis that converges -- **Conditional**: Feature flags, permissions, subscriptions +- **Conditional Branching**: Decision points (approve/reject, success/failure, permission levels) - **Nested**: Complex operations with sub-processes -The key is to let the transformation emerge naturally from the domain logic, not force it into artificial patterns. +The key is to let transformation emerge naturally from the domain's flow, not force it into artificial patterns. diff --git a/manuals/1.0/ja/05-metamorphosis-patterns.md b/manuals/1.0/ja/05-metamorphosis-patterns.md index 543afbc..d1e81f1 100644 --- a/manuals/1.0/ja/05-metamorphosis-patterns.md +++ b/manuals/1.0/ja/05-metamorphosis-patterns.md @@ -7,7 +7,13 @@ permalink: /manuals/1.0/ja/05-metamorphosis-patterns.html # 倉容パタヌン -Beフレヌムワヌクは、単玔な線圢チェヌンから耇雑な分岐する運呜たで、様々な倉容パタヌンをサポヌトしたす。これらのパタヌンを理解するこずで、自然な倉容フロヌを蚭蚈できたす。 +> 「同じ川に二床入るこずはできない」 +> +>   —ヘラクレむトス『断片』玀元前500幎頃 + +## 倉容の流れ + +Beフレヌムワヌクは、単玔な線圢チェヌンから耇雑な分岐たで、様々な倉容パタヌンをサポヌトしたす。これらのパタヌンを理解するこずで、自然な倉容フロヌを蚭蚈できたす。 ## 線圢倉容チェヌン @@ -32,9 +38,9 @@ final class WelcomeMessage { /* ... */ } 各段階は自然に次ぞず導かれ、川が海に流れるようです。 -## 分岐する運呜 +## 条件分岐パタヌン -オブゞェクトはその性質に基づいお耇数の可胜な未来を持぀こずができたす +オブゞェクトはその性質に基づいお耇数の可胜な未来を持぀こずができたす。これは条件によっお異なる型ぞず分岐する自然な倉容です ```php #[Be([ApprovedApplication::class, RejectedApplication::class])] @@ -55,42 +61,9 @@ final class ApplicationReview } ``` -オブゞェクトは**型駆動倉容**を通しお自身の運呜を決定したす。 - -## フォヌク・ゞョむンパタヌン +### 他の条件分岐䟋 -単䞀の入力が䞊列倉容に分岐し、埌に収束したす - -```php -#[Be(PersonalizedRecommendation::class)] -final class UserAnalysis -{ - public readonly PersonalizedRecommendation $being; - - public function __construct( - #[Input] string $userId, // 内圚的 - #[Inject] BehaviorAnalyzer $behavior, // 超越的 - #[Inject] PreferenceAnalyzer $preference, // 超越的 - #[Inject] SocialAnalyzer $social // 超越的 - ) { - // 䞊列分析 - $behaviorScore = $behavior->analyze($userId); - $preferenceScore = $preference->analyze($userId); - $socialScore = $social->analyze($userId); - - // 収束 - $this->being = new PersonalizedRecommendation( - $behaviorScore, - $preferenceScore, - $socialScore - ); - } -} -``` - -## 条件付き倉容 - -時ずしお倉容はランタむム条件に䟝存したす +機胜レベルや暩限による分岐も同様のパタヌンです ```php #[Be([PremiumFeatures::class, BasicFeatures::class])] @@ -111,6 +84,9 @@ final class FeatureActivation } ``` +オブゞェクトは**型駆動倉容**を通しお自身の運呜を決定したす。 + + ## ネストした倉容 耇雑なオブゞェクトは独自の倉容チェヌンを含むこずができたす @@ -134,7 +110,26 @@ final class OrderProcessing ## 自己組織化パむプラむン -これらのパタヌンの矎しさは、それらが**自己組織化**であるこずです。オブゞェクトは自身の運呜を宣蚀し、フレヌムワヌクは倖郚のオヌケストレヌションなしに自然に倉容パスに埓いたす。 +これらのパタヌンの矎しさは、それらが**自己組織化**であるこずです。Unixパむプが単玔なコマンドを組み合わせお匷力なシステムを䜜るように、Beフレヌムワヌクは型付きオブゞェクトを組み合わせお自然な倉容の流れを䜜りたす。 + +### Unixパむプずの比范 + +```bash +# Unix: テキストが流れる倖郚制埡のパむプラむン +cat access.log | grep "404" | awk '{print $7}' | sort | uniq -c +``` + +```php +// Be Framework: リッチなオブゞェクトが流れる内圚的制埡のパむプラむン +$finalObject = $becoming(new ApplicationInput($documents)); +// オブゞェクト自身が次の倉容先を知っおいる +``` + +重芁な進化 +- **Unix**: 倖郚のshellがパむプを制埡 +- **Be Framework**: オブゞェクト自身が`#[Be()]`で運呜を宣蚀 + +### 自己組織化の実珟 ```php // コントロヌラヌもオヌケストレヌタヌもなし—ただ自然な流れ @@ -147,14 +142,18 @@ match (true) { }; ``` +この自己組織化により +- 倖郚オヌケストレヌションが䞍芁 +- 型安党性が保たれる +- 䟝存性泚入による胜力の提䟛 +- テスト可胜な独立したコンポヌネント + ## パタヌンの遞択 ドメむンの自然な流れに基づいおパタヌンを遞択しおください - **線圢**: 順次プロセス怜蚌 → 凊理 → 完了 -- **分岐**: 決定ポむント承認/拒吊、成功/倱敗 -- **フォヌク・ゞョむン**: 収束する䞊列分析 -- **条件付き**: 機胜フラグ、暩限、サブスクリプション +- **条件分岐**: 決定ポむント承認/拒吊、成功/倱敗、暩限レベル - **ネストした**: サブプロセスを持぀耇雑な操䜜 -重芁なのは、倉容をドメむンロゞックから自然に生たれさせるこずであり、人工的なパタヌンに匷制するこずではありたせん。 \ No newline at end of file +重芁なのは、倉容をドメむンの自然な流れから生たれさせるこずであり、人工的なパタヌンに匷制するこずではありたせん。 From 2e68a7124124c3d2214fd948401391e4003bae55 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Fri, 12 Sep 2025 15:08:17 +0900 Subject: [PATCH 9/9] Restructure Chapter 5: From Patterns to Metamorphosis Philosophy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Transform Chapter 5 from pattern catalog to philosophical overview of metamorphosis, integrating Einstein's space-time inseparability with Heraclitean flow philosophy. Major changes: - Replace Heraclitean quote with Einstein's authentic 1916 general relativity quote - Add core concept: time and domain cannot be separated - Restructure from pattern-focused to essence-focused metamorphosis overview - Replace linear patterns with temporal flow (T0→T1→T2→T3) - Rename conditional branching to "self-determination of destiny" - Remove quantum superposition section for practical balance - Add comprehensive implementation guidelines - Conclude with Heraclitean philosophy connecting to Be Framework essence Both Japanese and English versions updated with philosophical depth while maintaining practical utility as framework documentation. 🀖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- manuals/1.0/en/05-metamorphosis-patterns.md | 133 ++++++++++++------- manuals/1.0/ja/05-metamorphosis-patterns.md | 136 +++++++++++++------- 2 files changed, 171 insertions(+), 98 deletions(-) diff --git a/manuals/1.0/en/05-metamorphosis-patterns.md b/manuals/1.0/en/05-metamorphosis-patterns.md index eda5d4b..8568e29 100644 --- a/manuals/1.0/en/05-metamorphosis-patterns.md +++ b/manuals/1.0/en/05-metamorphosis-patterns.md @@ -1,46 +1,46 @@ --- layout: docs-en -title: "5. Metamorphosis Patterns" +title: "5. Metamorphosis" category: Manual -permalink: /manuals/1.0/en/05-metamorphosis-patterns.html +permalink: /manuals/1.0/en/05-metamorphosis.html --- -# Metamorphosis Patterns +# Metamorphosis -> "No man ever steps in the same river twice." +> "Space and time cannot be defined independently of each other." > -> —Heraclitus, Fragments (c. 500 BC) +> —Albert Einstein, The Foundation of the General Theory of Relativity (1916) -## Patterns of Change +## Time and Domain Are Inseparable -Be Framework supports various patterns of transformation, from simple linear chains to complex branching. Understanding these patterns helps you design natural transformation flows. +Just as Einstein discovered the inseparability of time and space, the Be Framework considers time and domain as a single entity that cannot be divided. Approval processes have their approval time, payments have their payment time, and transformation naturally emerges along the unique temporal axis that each domain logic possesses. -## Linear Metamorphic Chain +## Irreversible Flow of Time -The simplest pattern: A → B → C → D +Object metamorphosis follows the arrow of time in a unidirectional flow. There is no returning to the past, no remaining in the same moment: ```php -// Input +// Time T0: Birth of input #[Be(EmailValidation::class)] final class EmailInput { /* ... */ } -// First transformation +// Time T1: First metamorphosis (T0 is already past) #[Be(UserCreation::class)] final class EmailValidation { /* ... */ } -// Second transformation +// Time T2: Second metamorphosis (T1 becomes memory) #[Be(WelcomeMessage::class)] final class UserCreation { /* ... */ } -// Final result +// Time T3: Final existence (encompassing all past) final class WelcomeMessage { /* ... */ } ``` -Each stage naturally leads to the next, like a river flowing to the sea. +Each moment never returns, and new existence preserves previous forms as memory within itself. Like a river flowing, time moves only in one direction. -## Conditional Branching Pattern +## Self-Determination of Destiny -Objects can have multiple possible futures based on their nature. This is natural transformation that branches into different types based on conditions: +Like living beings in reality, objects determine their own destiny through the interaction between intrinsic nature and external environment. This is not following a predetermined route, but natural metamorphosis responding to the circumstances of that moment: ```php #[Be([ApprovedApplication::class, RejectedApplication::class])] @@ -49,11 +49,12 @@ final class ApplicationReview public readonly ApprovedApplication|RejectedApplication $being; public function __construct( - #[Input] array $documents, // Immanent - #[Inject] ReviewService $reviewer // Transcendent + #[Input] array $documents, // Intrinsic nature + #[Inject] ReviewService $reviewer // External environment ) { $result = $reviewer->evaluate($documents); + // Destiny is decided at this very moment $this->being = $result->isApproved() ? new ApprovedApplication($documents, $result->getScore()) : new RejectedApplication($result->getReasons()); @@ -61,31 +62,6 @@ final class ApplicationReview } ``` -### Other Conditional Branching Examples - -Feature levels and permissions follow the same pattern: - -```php -#[Be([PremiumFeatures::class, BasicFeatures::class])] -final class FeatureActivation -{ - public readonly PremiumFeatures|BasicFeatures $being; - - public function __construct( - #[Input] User $user, // Immanent - #[Inject] SubscriptionService $service // Transcendent - ) { - $subscription = $service->getSubscription($user); - - $this->being = $subscription->isPremium() - ? new PremiumFeatures($user, $subscription) - : new BasicFeatures($user); - } -} -``` - -The object determines its own destiny through **Type-Driven Metamorphosis**. - ## Nested Metamorphosis @@ -149,12 +125,71 @@ This self-organization provides: - Capabilities provided through dependency injection - Testable independent components -## Pattern Selection +## Implementation Guidelines + +### When to Choose Linear Metamorphosis + +For sequential processing where each stage prepares the data needed for the next: + +```php +User Registration → Email Verification → Account Activation → Welcome Notification +``` + +This is suitable when failure at any stage should halt the entire process. + +### When to Choose Conditional Branching + +When the same input branches into different results based on nature or permissions: + +```php +// Implementation example: Feature differentiation by payment capability +#[Be([FullAccess::class, LimitedAccess::class, ReadOnlyAccess::class])] +final class AccessDetermination +{ + public readonly FullAccess|LimitedAccess|ReadOnlyAccess $being; + + public function __construct( + #[Input] User $user, + #[Inject] PaymentStatus $payment + ) { + $this->being = match($payment->getStatus()) { + 'premium' => new FullAccess($user, $payment->getFeatures()), + 'basic' => new LimitedAccess($user, $payment->getLimits()), + default => new ReadOnlyAccess($user) + }; + } +} +``` + +### When to Choose Nested Metamorphosis + +When executing multiple independent processes in parallel and aggregating their results: + +```php +final class OrderCompletion +{ + public function __construct( + #[Input] OrderData $order, + #[Inject] Becoming $becoming + ) { + // Independent parallel processing + $this->inventory = $becoming(new InventoryCheck($order->items)); + $this->payment = $becoming(new PaymentProcess($order->payment)); + $this->shipping = $becoming(new ShippingArrange($order->address)); + } +} +``` + +## Design Principles + +Choose metamorphosis patterns according to the natural flow of domain logic: -Choose patterns based on your domain's natural flow: +- **Don't Force**: Don't force into artificial patterns +- **Keep Simple**: Choose the most simple and understandable form +- **Testable**: Each metamorphosis stage can be tested independently +- **Type Safe**: Next type is guaranteed by `#[Be()]` -- **Linear**: Sequential processes (validation → processing → completion) -- **Conditional Branching**: Decision points (approve/reject, success/failure, permission levels) -- **Nested**: Complex operations with sub-processes +Objects govern their own metamorphosis. -The key is to let transformation emerge naturally from the domain's flow, not force it into artificial patterns. +Heraclitus said "the river flows" is not correct, but rather "the flowing is the river." He believed that existence cannot be separated from change. Be Framework likewise believes that to capture essence, domain and time cannot be separated. +Domains are temporal existence. There are possibilities and being at each moment. Capturing how input classes, being classes, and final objects naturally metamorphose along the flow of time is the core of the Be Framework. diff --git a/manuals/1.0/ja/05-metamorphosis-patterns.md b/manuals/1.0/ja/05-metamorphosis-patterns.md index d1e81f1..2a256ba 100644 --- a/manuals/1.0/ja/05-metamorphosis-patterns.md +++ b/manuals/1.0/ja/05-metamorphosis-patterns.md @@ -1,46 +1,46 @@ --- layout: docs-ja -title: "5. 倉容パタヌン" +title: "5. メタモルフォヌシス" category: Manual -permalink: /manuals/1.0/ja/05-metamorphosis-patterns.html +permalink: /manuals/1.0/ja/05-metamorphosis.html --- -# 倉容パタヌン +# メタモルフォヌシス -> 「同じ川に二床入るこずはできない」 +> 「空間ず時間は独立に定矩できない」 > ->   —ヘラクレむトス『断片』玀元前500幎頃 +>   —アルベルト・アむンシュタむン『䞀般盞察性理論の基瀎』1916幎 -## 倉容の流れ +## 時間ずドメむンは分割できない -Beフレヌムワヌクは、単玔な線圢チェヌンから耇雑な分岐たで、様々な倉容パタヌンをサポヌトしたす。これらのパタヌンを理解するこずで、自然な倉容フロヌを蚭蚈できたす。 +アむンシュタむンが時間ず空間の䞍可分性を発芋したように、Beフレヌムワヌクでは時間ずドメむンは分割できない䞀぀の実䜓です。承認プロセスには承認の時間が、決枈には決枈の時間があり、それぞれのドメむンロゞックが持぀固有の時間軞に沿っお倉容が自然に珟れたす。 -## 線圢倉容チェヌン +## 䞍可逆的時間の流れ -最もシンプルなパタヌンA → B → C → D +オブゞェクトの倉容は時間の矢に沿った䞀方向の流れです。過去に戻るこずも、同じ瞬間に留たるこずもできたせん ```php -// 入力 +// 時間 T0: 入力の誕生 #[Be(EmailValidation::class)] final class EmailInput { /* ... */ } -// 第䞀倉容 +// 時間 T1: 第䞀倉容T0は既に過去 #[Be(UserCreation::class)] final class EmailValidation { /* ... */ } -// 第二倉容 +// 時間 T2: 第二倉容T1は蚘憶ずなる #[Be(WelcomeMessage::class)] final class UserCreation { /* ... */ } -// 最終結果 +// 時間 T3: 最終存圚すべおの過去を内包 final class WelcomeMessage { /* ... */ } ``` -各段階は自然に次ぞず導かれ、川が海に流れるようです。 +各瞬間は二床ず戻らず、新しい存圚は前の圢態をその内郚に蚘憶ずしお保持したす。川が流れるように、時間は䞀方向にのみ流れたす。 -## 条件分岐パタヌン +## 運呜の自己決定 -オブゞェクトはその性質に基づいお耇数の可胜な未来を持぀こずができたす。これは条件によっお異なる型ぞず分岐する自然な倉容です +珟実の生物ず同様に、オブゞェクトは内圚的な性質ず倖郚環境の盞互䜜甚によっお、自身の運呜を決定したす。これは予め決められたルヌトを蟿るのではなく、その瞬間の状況に応じた自然な倉容です ```php #[Be([ApprovedApplication::class, RejectedApplication::class])] @@ -49,11 +49,12 @@ final class ApplicationReview public readonly ApprovedApplication|RejectedApplication $being; public function __construct( - #[Input] array $documents, // 内圚的 - #[Inject] ReviewService $reviewer // 超越的 + #[Input] array $documents, // 内圚的性質 + #[Inject] ReviewService $reviewer // 倖郚環境 ) { $result = $reviewer->evaluate($documents); + // 運呜は今この瞬間に決たる $this->being = $result->isApproved() ? new ApprovedApplication($documents, $result->getScore()) : new RejectedApplication($result->getReasons()); @@ -61,31 +62,6 @@ final class ApplicationReview } ``` -### 他の条件分岐䟋 - -機胜レベルや暩限による分岐も同様のパタヌンです - -```php -#[Be([PremiumFeatures::class, BasicFeatures::class])] -final class FeatureActivation -{ - public readonly PremiumFeatures|BasicFeatures $being; - - public function __construct( - #[Input] User $user, // 内圚的 - #[Inject] SubscriptionService $service // 超越的 - ) { - $subscription = $service->getSubscription($user); - - $this->being = $subscription->isPremium() - ? new PremiumFeatures($user, $subscription) - : new BasicFeatures($user); - } -} -``` - -オブゞェクトは**型駆動倉容**を通しお自身の運呜を決定したす。 - ## ネストした倉容 @@ -148,12 +124,74 @@ match (true) { - 䟝存性泚入による胜力の提䟛 - テスト可胜な独立したコンポヌネント -## パタヌンの遞択 +## 実装䞊の遞択指針 + +### い぀線圢倉容を遞ぶか + +シヌケンシャルな凊理で、各段階が次に必芁なデヌタを準備する堎合 + +```php +ナヌザヌ登録 → メヌル怜蚌 → アカりント有効化 → りェルカム通知 +``` + +各段階での倱敗は党䜓を停止させる必芁がある堎合に適しおいたす。 + +### い぀条件分岐を遞ぶか + +同じ入力から性質や暩限によっお異なる結果に分岐する堎合 + +```php +// 実装䟋支払い胜力による機胜差 +#[Be([FullAccess::class, LimitedAccess::class, ReadOnlyAccess::class])] +final class AccessDetermination +{ + public readonly FullAccess|LimitedAccess|ReadOnlyAccess $being; + + public function __construct( + #[Input] User $user, + #[Inject] PaymentStatus $payment + ) { + $this->being = match($payment->getStatus()) { + 'premium' => new FullAccess($user, $payment->getFeatures()), + 'basic' => new LimitedAccess($user, $payment->getLimits()), + default => new ReadOnlyAccess($user) + }; + } +} +``` + +### い぀ネストした倉容を遞ぶか + +耇数の独立した凊理を䞊行しお実行し、それぞれの結果を集玄する堎合 + +```php +final class OrderCompletion +{ + public function __construct( + #[Input] OrderData $order, + #[Inject] Becoming $becoming + ) { + // 独立した凊理を䞊行実行 + $this->inventory = $becoming(new InventoryCheck($order->items)); + $this->payment = $becoming(new PaymentProcess($order->payment)); + $this->shipping = $becoming(new ShippingArrange($order->address)); + } +} +``` + +## 蚭蚈原則 + +倉容パタヌンの遞択は、ドメむンロゞックの自然な流れに埓っおください + +- **匷制しない**: 人工的なパタヌンに無理やり圓おはめない +- **シンプルに**: 最も単玔で理解しやすい圢を遞ぶ +- **テスト可胜**: 各倉容段階が独立しおテストできる +- **型安党**: `#[Be()]` によっお次の型が保蚌される + +オブゞェクトは自らが自らの倉容を芏定したす。 + +ヘラクレむトスは『川が流れおいる』のではなく『流れおいるのが川だ』ず蚀いたした。存圚は倉化ずは切り離せないず考えたのです。Be Frameworkも同じように本質を捉えるためにはドメむンず時間は切り離せないものず考えたした。 +ドメむンは時間的存圚です。その時その時の可胜性ず存圚がありたす。入力クラス、存圚クラス、最終オブゞェクトが時間の流れに沿っお自然に倉容しおいく様を捉えるこずが、Beフレヌムワヌクの栞心です。 -ドメむンの自然な流れに基づいおパタヌンを遞択しおください -- **線圢**: 順次プロセス怜蚌 → 凊理 → 完了 -- **条件分岐**: 決定ポむント承認/拒吊、成功/倱敗、暩限レベル -- **ネストした**: サブプロセスを持぀耇雑な操䜜 -重芁なのは、倉容をドメむンの自然な流れから生たれさせるこずであり、人工的なパタヌンに匷制するこずではありたせん。