Search the web
Sign In
New User? Sign Up
domaindrivendesign · Domain-Driven Design
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Presentation Models   Message List  
Reply | Forward Message #13652 of 16097 |
Re: [domaindrivendesign] Presentation Models

Would you mind post some code? Does interface help?

On Fri, Jul 3, 2009 at 10:03 PM, Hendry Luk <hendrymail@...> wrote:


Extracting into reusable methods become harder when we deal with 2 different domains and separate bounded-context.

I can only refactor so much, but i still need to create 2 domain object for Promotion (for example). One for command (which contains more accurate representation of Promotion from transaction/business view), and another one for query (Promotion as seen on UI/presentation by users).

In many cases, they are the same. I can write in Promotion object domain on Command side to define how the a particular promotion works on customer's bill.

When this promotion gets passed through messaging, I will end up doing the same logic in Query side of Promotion domain (to make sure promotion is applied appropriately to CustomerBillSummary report, and SubscriptionBillSummary report, BillDetail report, etc).

I can extract out this logic leaving domains of both bounded-contexts pretty anemic... if possible at all. The fact that the promotion works on totally different domain (between transaction-domain and report domain) makes it extremely hard to avoid duplication.

How does everyone overcome this problem?

Is CQS only intended for applications where auditting is heavily crucial (e.g. finance/accounting)?

And in "conventional" (non CQS) DDD application, how do you deal with screen-specific lists (while avoiding data-access problem)? Do you expose application-service and even repositories to presentation DTOs?


On Fri, Jul 3, 2009 at 11:37 PM, Carfield Yim <carfield@...> wrote:


Sorry to jump in to the discussion.... in fact I am not exactly sure if I understand your question totally.... but if you find that are duplication of logic, isn't you can always extract to a common method and reuse in difference place?



On Fri, Jul 3, 2009 at 9:34 PM, Hendry Luk <hendrymail@...> wrote:


Not sure what I was trying to say there :P
That should read:
My problem is: while in some particular cases, domains for query and command are different, but in most cases they are very similar.


On Fri, Jul 3, 2009 at 11:29 PM, Hendry Luk <hendrymail@...> wrote:
My biggest problem with CQS at the moment, is that processing Command inevitably involves queries.
From my understanding, however, command context doesn't normally communicate with query context. Instead, it reconstructs the entity from historical commands.
My problem is, while in particulary area of the applications domains for query and command are different, but they're mostly similar.
I.e., in most applications, the business domain during write is very similar with business domain of read. Nevertheless, in CQS we have to rewrite the same logic twice: one in each context (command and query).

For example, applying promotional discount to an order. This logic will have to live in command, so we could apply the promotion to domain entities using specific business logic.
In the other end of the communication, the same command gets fed as an event-message to the other context. The other context will apply same business logic, but in completely different view of the same elephant. It mostly deals with updating various 'query-specific' datastore, and knows nothing about domain-entity.
So in this case, the same logic has to be rewritten in both command side and query side.

And to make it even more complicated, the query-specific datastore is deliberately unnormalized. E.g., if you have different view for order per customer, and order per account, we make redundant maintenance, which is fine. However, when we introduce new concept like promotion, developers need to remember to maintain both viewpoints of that order. I think unnormalization for reporting-friendly purpose causes maintenance trouble, but can be justified for many reporting purposes (as in "reporting"), but i think would be maintenance nightmare if applied liberally for all queries in the application.

I know I'm still missing a lot of pieces in CQS. But it's difficult for me to overcome this issue without any implementation out there that I can use as reference (is there any?).

Cheers



On Fri, Jul 3, 2009 at 11:04 PM, Greg Young <gregoryyoung1@...> wrote:


What duplication? It is the same amount of code just put into different places.

Also it does not *have* to be against 2 different data sources ....
using 2 data sources does add a lot of complexity due to eventual
consistency ... If you use just 1 data source then things are
relatively straight forward.

Greg



On Fri, Jul 3, 2009 at 7:28 AM, Hendry Luk<hendrymail@...> wrote:
>
>
> Hi guys,
>
> I'm wondering what's your take about where presentation models get dealt
> with? E.g. screens where we do complex search/filtering then display the
> result in a very pedantic list of screen-specific representation.
> Ideally, presentation models are established in presentation-layer, whereas
> application-services and repositories produce the domain entities required
> to constitute the presentation. However, there are data-access implications,
> e.g. lazy-load.
> Hiding stuffs behind application-service, repository etc makes it difficult
> to make screen-specific projection (from ORM into DTO) to avoid N+1
> lazy-loading. E.g., a screen to search customers, which was initially nice
> and easy until the client ask a change request to add a column to the
> search-result list: "number of subscriptions the customer has".
>
> It's so tempting to let applicaiton-service (or repository) to deal directly
> with screen-specific DTO. But application layer is not supposed to deal with
> DTO or presentation-models. Many purists have always preached the importance
> of having mappers to translate DTO to application-layer, and that
> application-layer should only deal with domain objects. I just can't figure
> out how to maintain data-access optimization this way.
>
> OK, I'm aware of philosophy like CQS that separates query into different
> bounded context and data-store from usual domain entities. But I haven't
> bought into this yet. The upkeep cost for logic duplication is IMO enormous,
> and I can't justify yet to move to that architecture until I know better
> about it (which would be for another post).
>
> Cheers
> Hendry
>
>

--
Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer
de votre attention











Fri Jul 3, 2009 2:34 pm

c8133594
Offline Offline
Send Email Send Email

Forward
Message #13652 of 16097 |
Expand Messages Author Sort by Date

Extracting into reusable methods become harder when we deal with 2 different domains and separate bounded-context. I can only refactor so much, but i still...
Hendry Luk
hendrypa
Offline Send Email
Jul 3, 2009
2:04 pm

Would you mind post some code? Does interface help? ... Would you mind post some code? Does interface help? On Fri, Jul 3, 2009 at 10:03 PM, Hendry Luk <...
Carfield Yim
c8133594
Offline Send Email
Jul 3, 2009
2:35 pm

I'll pick an example from Greg's example of adding item to order, and try to put my understanding of the presentation into this code. We have a AddProduct...
Hendry Luk
hendrypa
Offline Send Email
Jul 4, 2009
3:44 am

CQS happens within a bounded context, not between them. The challenges you're outlining would be dealt with using multiple BCs. Most retail domains have a...
Udi Dahan
udidahan7
Offline Send Email
Jul 6, 2009
7:33 pm

Please forgive my ignorance if I have a misunderstanding here, but I'm still reading up on all this stuff. Do bounded contexts require than you can present...
gmurray_alt
Offline Send Email
Jul 6, 2009
8:53 pm

Security can be its own bounded context - yours is one such case. BTW, multiple bounded contexts can be running within a given process. -- Udi Dahan From:...
Udi Dahan
udidahan7
Offline Send Email
Jul 6, 2009
9:21 pm

... Does anybody know of diagrams which help show such DDD architectural principles visually? Seems like that could be helpful to newbies. sincerely....
Raoul Duke
theraoulduke
Online Now Send Email
Jul 6, 2009
9:25 pm

... My friend Björn has some drawings and an introduction to CQS made during a discussion with Greg (at QCon I think): ...
Sebastian Jancke
sebastian.ja...
Offline Send Email
Jul 7, 2009
6:21 pm

Personally my biggest obstacle in learning CQS is that, i have seen lots of beautiful texts and drawings about it, but i haven't found any code. When I...
Hendry Luk
hendrypa
Offline Send Email
Jul 8, 2009
6:31 am

Hendry, Which part of the beautiful code turns ugly and in what way? -- Udi Dahan From: domaindrivendesign@yahoogroups.com ...
Udi Dahan
udidahan7
Offline Send Email
Jul 10, 2009
12:12 pm

Greg, "What duplication? It is the same amount of code just put into different places." I think what he means is the same rules concerning the same concept...
Nuno Lopes
nbplopes
Offline Send Email
Jul 10, 2009
2:09 pm

I think i missed Udi's "intepretation". Copy and paste would help... One question, why would you have to code the same rule in multiple places? Shouldn't the...
Greg Young
gumboismadeo...
Offline Send Email
Jul 10, 2009
2:13 pm

Greg, "I think i missed Udi's "intepretation". Copy and paste would help..." Well my understanding of his explanation around CQS. Rarely I read the words of...
Nuno Lopes
nbplopes
Offline Send Email
Jul 10, 2009
2:33 pm

... I would say you are pretty far from clear ... Its really a problem that you write this drabble as if it is from a position of authority when you have no...
Greg Young
gumboismadeo...
Offline Send Email
Jul 10, 2009
2:43 pm

I think you might have an authority problem that os deeper then this thread becouse you come with that word quite often. I'm not even challenging your...
Nuno Lopes
nbplopes
Offline Send Email
Jul 10, 2009
5:35 pm

One last remark. I haven't told anyone that Event Sourcing is about persistance of messages so I don't know where have you got that part. You must be confusing...
Nuno Lopes
nbplopes
Offline Send Email
Jul 10, 2009
5:39 pm

Seriously are you just a troll or what? I copy and pasted the exact line you wrote that I was referring to. I will paste it again ... ... -- Les erreurs de...
Greg Young
gumboismadeo...
Offline Send Email
Jul 11, 2009
4:30 pm

Hi Greg. Usage of parentesis http://www.ehow.com/how_4516252_use-parenthesis-writing.html It was suplemental information (step 3) It does mean that it defines ...
Nuno Lopes
nbplopes
Offline Send Email
Jul 12, 2009
8:35 pm

Nuno I have invited you previously to put together coherent questions on CQS and related ideas with the point of me answering them. I have yet to receive this...
Greg Young
gumboismadeo...
Offline Send Email
Jul 13, 2009
1:57 am

Greg, From me you already got several. Sone went without an answer etc. Some were answered (not the most importants) etc. Not only me but also others. Anyway...
Nuno Lopes
nbplopes
Offline Send Email
Jul 13, 2009
7:25 am

Nuno, You make outrageous statements like "its all just salesmanship ... no substance". I repeatedly give you opportunities to bring forward a list of coherent...
Greg Young
gumboismadeo...
Offline Send Email
Jul 13, 2009
4:39 pm

"As far as I am concerned you should bugger off to where ever trolls go when people stop listenning to them." The feeling is mutual. Nuno PS: What you called...
Nuno Lopes
nbplopes
Offline Send Email
Jul 13, 2009
5:17 pm

UNSUBSCRIBE From: domaindrivendesign@yahoogroups.com [mailto:domaindrivendesign@yahoogroups.com] On Behalf Of Nuno Lopes Sent: 13 July 2009 18:17 To:...
Gareth Down
garethdown44
Offline Send Email
Jul 13, 2009
5:26 pm

About me posting here is up to me to decide for how long Don't know why you ate do worried about it. Nuno. ... I would say you are pretty far from clear ......
Nuno Lopes
nbplopes
Offline Send Email
Jul 10, 2009
5:44 pm

... Oh I was interpreting that in CQS you should always store commands (not states) and recreate the state from there (although there are periodic snapshots). ...
Hendry Luk
hendrypa
Offline Send Email
Jul 13, 2009
5:11 am

Hi Hendry, ... Events, not commands. And I don't believe that's strictly necessary for CQS - only the Event Sourcing side of CQS (although Greg argued with me...
Michael Hart
michaelhartau
Online Now Send Email
Jul 13, 2009
6:49 am

Hi Michael, Is that correct? It seems more logical to me that since your objects have their state "built up" or modified by commands, those commands are the ...
Lee Henson
leemhenson
Offline Send Email
Jul 13, 2009
10:35 am

... I think there are a couple of things to keep separate. "Commands" are "suggestions and "events" are "what happened". Commands are done using programming...
Rickard Öberg
rickardoberg
Offline Send Email
Jul 13, 2009
10:40 am

Hi Lee, ... You're right that initially your domain is modified by commands - but at what stage would you store the command? Only after it's been successfully...
Michael Hart
michaelhartau
Online Now Send Email
Jul 13, 2009
11:16 am

Making commands == events is something that can be done to save time in a project. There are however *many* reasons why you would generally not want this to be...
Greg Young
gumboismadeo...
Offline Send Email
Jul 13, 2009
4:21 pm
 First  |  |  Last 
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help