Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ドメイン層を再モデリング&リファクタリング #55

Open
ebinase opened this issue May 5, 2022 · 5 comments
Open

ドメイン層を再モデリング&リファクタリング #55

ebinase opened this issue May 5, 2022 · 5 comments
Assignees
Labels
Type: Documentation Improvements or additions to documentation Type: Maintenance Manage environment

Comments

@ebinase
Copy link
Owner

ebinase commented May 5, 2022

API実装・フロント連携をするプレゼンテーション層を充実させる前に、少しごちゃごちゃしていたドメイン層を改めて整理してみる。

@ebinase ebinase self-assigned this May 5, 2022
@ebinase
Copy link
Owner Author

ebinase commented May 5, 2022

@ebinase ebinase added Type: Documentation Improvements or additions to documentation Type: Maintenance Manage environment labels May 5, 2022
@ebinase
Copy link
Owner Author

ebinase commented May 7, 2022


ドメイン層を以下のように大別

  • Othello
  • GameOrganizer
  • Bot
  • Common

上から純粋なオセロのルールなど、参加者や対戦モードなどのゲームとしてのオセロの管理、ボット、自作ライブラリ等

ebinase added a commit that referenced this issue May 7, 2022
@ebinase
Copy link
Owner Author

ebinase commented May 19, 2022

OthelloとTurnを再定義

純粋な遊戯としてのOthello、その中で毎ターン変化する項目としてTurnを定義する。

Othello

  • Id
  • Turn
  • 連続スキップ数(ゲームの終了条件に関係)

OthelloはEntity、TurnはValueObjectとして再定義。

ドメイン層のディレクトリ構造を下記に変更

  • OthelloCore(OthelloやTurnなどオセロをプレイするためのコアメンバ。これさえあればプレイ自体は可能。)
  • GameOrganizer(仮。オセロを人がプレイする上で必要な参加者の管理を主に行う)
  • Bot(ボットを実装。盤面などの情報を引数にして処理結果を返す関数みたいなイメージ)
  • Common(仮。自作行列計算ライブラリなど。OthelloCoreに統合 or 別ライブラリとして切り出し?)

大きな変更をする上での対策

TDDをメインに実装

クラスの構造やディレクトリ名の変更などかなり修正範囲が大きくなる。
そこでテストエラーが発生することを恐れず大きな変更を加えてから、分割統治の考え方で一つ一つの機能のテストをグリーンにすることを目指す。
その積み重ねから最終的に動作する安定した状態への復帰を目指す。
(ついでにカバレッジも上げていく)

@ebinase
Copy link
Owner Author

ebinase commented May 19, 2022

Turnの修正完了

これを元にOthelloのリファクタリング開始

ebinase added a commit that referenced this issue May 19, 2022
ebinase added a commit that referenced this issue May 21, 2022
ebinase added a commit that referenced this issue May 29, 2022
@ebinase
Copy link
Owner Author

ebinase commented May 29, 2022

Othelloの修正完了

次はGameの修正だけど、いったん保留へ。
フロント側へOthelloの基本機能を提供するため、バックエンドのwebページはダウンさせる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Documentation Improvements or additions to documentation Type: Maintenance Manage environment
Projects
Development

No branches or pull requests

1 participant