4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

何度考えても結論が出ないDDD問題

Last updated at Posted at 2019-10-10

ドメインてなんや
model以上でアプリケーション以下のドメインという存在であらゆる設計が一貫性が失われる

callbackでもなくFormObjectでもなくmvcで解決しきるDHHのすごさ
複数モデルをtransaction内で処理する
https://gist.github.com/dhh/9348053
https://amolnpujari.wordpress.com/2013/04/09/184/
https://qiita.com/joker1007/items/2a03500017766bdb0234
https://qiita.com/masuidrive/items/f2ae316dc8e98b4ff82a
https://amolnpujari.wordpress.com/2013/04/09/184/
https://qiita.com/kamohicokamo/items/e7c31f61c99c9fc0fe7f
https://techracho.bpsinc.jp/hachi8833/2017_11_06/47607
https://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html
https://techracho.bpsinc.jp/hachi8833/2017_12_12/48367
https://api.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html
この方針がめちゃくちゃいいような気がする

If you just need to update fields in the same model, use Callbacks. You can still do this for field updates even if you also need other patterns for more complex needs.
If you have a form with multiple models or with form-specific validation, use a Form Object. But I don’t recommend adding secondary effects to a Form Object.
If you have only few secondary effects that you use rarely, or that aren’t on the critical path, use General Decorators.
If you have secondary effects that aren’t on the critical path, and they’re always used, use Events.
If you have many secondary effects called from multiple places in different combinations, or if they’re on the critical path, use Service Objects.
If your Service Objects are getting complex or repetitive, you can have them use General Decorators or broadcast Events instead of calling secondary effects directly.

validationを複雑さなく書く
https://gist.github.com/dhh/9672827
https://gist.github.com/dhh/10649506

2つのモデルに紐づくモデルのcontrollerでの扱い
https://gist.github.com/dhh/10022098

authenticationの分割
https://gist.github.com/dhh/10880690

Gridカウントサンプル
https://gist.github.com/dhh/10882430

テストが設計を駄目にする
https://dhh.dk/2014/test-induced-design-damage.html
https://blog.cleancoder.com/uncle-bob/2014/05/01/Design-Damage.html

環境毎の設定をymlで
https://gist.github.com/dhh/9afdbfd67e3c42c9f09e

https://www.youtube.com/channel/UCdx5Dk3EWTe2i8YDA7bfl6g
youtubeよりコード例
Screen Shot 2019-10-11 at 15.41.48.png
Screen Shot 2019-10-11 at 15.40.18.png
Screen Shot 2019-10-11 at 15.39.06.png
Screen Shot 2019-10-11 at 15.37.03.png
Screen Shot 2019-10-11 at 15.35.46.png
Screen Shot 2019-10-11 at 15.33.09.png
Screen Shot 2019-10-11 at 15.32.07.png
Screen Shot 2019-10-11 at 15.26.03.png
Screen Shot 2019-10-11 at 15.24.16.png
Screen Shot 2019-10-11 at 15.23.14.png

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?