You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
Pyrsistent is a number of persistent collections (by some referred to as functional data structures). Persistent in the sense that they are immutable. All methods on a data structure that would normally mutate it instead return a new copy of the structure containing the requested updates. The original structure is left untouched. This will simplify the reasoning about what a program does since no
おすすめ書籍 エリック・エヴァンスのドメイン駆動設計 (2011) “Domain DrivenDesign” Eric Evans (2003) DDD 信者の聖書。その難解さから「鈍器」と呼ばれる。抽象度が高く、分厚いので 読み通すの大変だが、何回読んでも発見がある。ここで整理されている概念は、 10 年以上経った今も色褪せない。 実践ドメイン駆動設計 (2015) “Implementing Domain Driven Design” Vaughn Vernon (2011) Evans 本の中身は本質を突いているが、その実践は容易でない。本書は、 Evans 本以降の10年間に発表された新しい開発技法を取り込みながら、 DDD の考え方 を実践に移すにはどうすれば良いかを記述した指南書。 ※ 読むのに挫折しても、鈍器としてなら使えます ※ ※ 翻訳レビューに参加しました。
概要 やや古い記事だけど、InfoQ のドメイン駆動設計・開発の実践には次のように書かれています。 ドメイン・クラスがData Access Object(DAO:データ・アクセス・オブジェクト)クラスに依存し、サービス・クラスがドメイン・クラスに依存するという設計上の依存関係がDDDによる実装に際してDIを"なくてはならない"ものにしています。 Python の場合、DI(依存性の注入)の実現には Inject が便利です。 利用例 ざっと100行程度でサンプルを書くと、このような形になります。 # -*- coding: utf-8 -*- import uuid from abc import ABCMeta, abstractmethod import inject def config(binder): binder.bind(UserRepository, UserMemory
Architecture Patterns with Python (aka "Cosmic Python") - Book by Harry Percival and Bob Gregory featuring DDD and strategic patterns (forthcoming on O'Reilly, also available in early release on safari Clean Architectures in Python - Book by Leonardo Giordani based on his post Domain-Driven Rails - a book by Robert Pankowecki & Arkency Team about DDD, CQRS, Event Sourcing related to Rails projects
from __future__ import annotations import sqlite3 import unittest import uuid from dataclasses import dataclass @dataclass(frozen=True) class UserId: value: str @dataclass(frozen=True) class Username: value: str @dataclass(frozen=True) class FullName: first_name: str family_name: str @dataclass class User: id: UserId username: Username name: FullName def change_username(self, new_username: Usernam
import dataclasses import unittest @dataclasses.dataclass(frozen=True) class FullName: full_name: str @dataclasses.dataclass class User: def __init__(self, full_name: FullName): self.full_name = full_name def change_full_name(self, new_name: FullName) -> None: if new_name is None: raise ValueError(f"{new_name} is invalid argument") self.full_name = new_name class TestUserEntity1(unittest.TestCase)
バージョン Python 3.7.0 目次 ドメインサービスとは エンティティ自身に横断的な知識を実装 ドメインサービスに横断的な知識を実装 使う場面によっては別の案があるかも ドメインサービスとは ドメインサービスは、値オブジェクトとエンティティの横断的な知識を実装することが許されている。 エンティティ自身に横断的な知識を実装 エンティティに横断的な知識を持たせるように実装してみる。 ユーザ自身に他のユーザとの重複を判断させるのは、確かに違和感がある。 from __future__ import annotations import unittest import uuid from dataclasses import dataclass @dataclass(frozen=True) class UserId: value: str @dataclass(frozen=True)
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く