{"action":"opened","issue":{"url":"https://api.github.com/repos/yvoyer/calculation-example/issues/2","repository_url":"https://api.github.com/repos/yvoyer/calculation-example","labels_url":"https://api.github.com/repos/yvoyer/calculation-example/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/yvoyer/calculation-example/issues/2/comments","events_url":"https://api.github.com/repos/yvoyer/calculation-example/issues/2/events","html_url":"https://github.com/yvoyer/calculation-example/issues/2","id":148652406,"number":2,"title":"Factory methods vs. handlers","user":{"login":"webdevilopers","id":3479626,"avatar_url":"https://avatars.githubusercontent.com/u/3479626?v=3","gravatar_id":"","url":"https://api.github.com/users/webdevilopers","html_url":"https://github.com/webdevilopers","followers_url":"https://api.github.com/users/webdevilopers/followers","following_url":"https://api.github.com/users/webdevilopers/following{/other_user}","gists_url":"https://api.github.com/users/webdevilopers/gists{/gist_id}","starred_url":"https://api.github.com/users/webdevilopers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webdevilopers/subscriptions","organizations_url":"https://api.github.com/users/webdevilopers/orgs","repos_url":"https://api.github.com/users/webdevilopers/repos","events_url":"https://api.github.com/users/webdevilopers/events{/privacy}","received_events_url":"https://api.github.com/users/webdevilopers/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-15T12:52:57Z","updated_at":"2016-04-15T12:52:57Z","closed_at":null,"body":"Actually @yvoyer I don't understand this part enough yet.\r\n\r\nIn my example:\r\nhttps://gist.github.com/yvoyer/a778ac744ddf10012864#file-dormercalculation-php\r\nyou suggested to use a factory method to add my a price - see lines 44 to 47.\r\n\r\nATM I have a similar scenario. A `Customer` ( <=> `DormerCalculation`) has an `Order` ( <=> `DormerCalculationPrice`).\r\n\r\nIn my first attempt the Handler created the `Order`. The constructor of the `Order` required the `Customer`.\r\n\r\nAfter a while I thought about your example and read the \"Factory method on aggregate root\" chapter in the red book. In the example a `Forum` adds a `Post` / `Discussion` via factory method.\r\nThe advantage is too check if the forum wasn't already closed.\r\n\r\nMy problem is not so much deciding on which technique to choose. It's more about the terminology.\r\n\r\nAFAIU \"factory methods\" are a Domain-Driven Design approach.\r\nBut using commands and handlers originally come from the CQRS approach.\r\n\r\nNow does the CQRS appraoch recommend to move away the \"factory methods\" from the Domain Model and put the logic into the Handler - the way I tried in my first attempt?\r\n\r\nCurious about your answer!"}}