Advanced Ncqrs Examples

327 views
Skip to first unread message

T.C. Boring

unread,
May 3, 2013, 2:43:09 PM5/3/13
to ncqr...@googlegroups.com
Hello,
 
I've been through the three samples available on Ncqrs' GitHub page.  Does anyone have any more advanced samples?  I'm creating a real system using Ncqrs, and have an entire data model that I need to code to.
 
thanks,
 
Tom
theBoringCoder

Pieter Joost van de Sande

unread,
May 3, 2013, 4:33:53 PM5/3/13
to ncqr...@googlegroups.com
Any specific topic you are looking for?
--
You received this message because you are subscribed to the Google Groups "ncqrs-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ncqrs-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

T.C. Boring

unread,
May 3, 2013, 4:43:21 PM5/3/13
to ncqr...@googlegroups.com
I need to build out my domain types.  My domain types have properties that link to other event types.  Not sure how to do that in Ncqrs because all the samples have domain types which have simple properties.

Pieter Joost van de Sande

unread,
May 3, 2013, 5:05:37 PM5/3/13
to ncqr...@googlegroups.com
Can you share an concrete example?

-- 
Pieter Joost van de Sande
Sent with Sparrow

Abdul Qudoos

unread,
May 3, 2013, 5:27:41 PM5/3/13
to ncqr...@googlegroups.com, ncqr...@googlegroups.com
By domain types linking to other event types do you mean navigation properties to other domain objects? You may need to re-establish your root aggregates. 

--
Qudoos

Qudoos Chaudhry

unread,
May 3, 2013, 10:46:16 PM5/3/13
to T.C. Boring, ncqr...@googlegroups.com
I would recommend reading this.
 
ncqrs provides a framework to architect an application utilizing CQRS and Event Sourcing. I am sure you have read about this if you are interested in ncqrs. The thing to keep in mind is you don't save the state of your domain object, rather you save the events that have occurred on the domain object. Then you build the domain object by playing those events when you need the latest version of the domain object. This means you cannot mix and match domain objects the way you have in your model. Unless Globe is a value object (which I highly doubt) this does not belong on the server object. To me they both look like separate
 
On one hand you have an EF model and on the other hand you are trying to use ncqrs. I would highly recommend educating yourself about this before jumping into it with a  real project.
 
Hope it helps.
 
Sent from Windows Mail
 
From: T.C. Boring
Sent: ‎May‎ ‎3‎, ‎2013 ‎7‎:‎18‎ ‎PM
To: abdul....@gmail.com
Subject: Re: Advanced Ncqrs Examples
 
Sorry, I meant types in my domain that have properties that are types in the domain--not events.  My bad.
 
Example: In my read model, I have Servers and Globes.  Each server represents a web server, and has, among other things, a collection of Globes.  Each globe represents a Google Earth globe, and has, among other things, a collection of servers.  In EF, they look like this:
 
    public class Server : ReadModelEntity
    {
        #region Constructor(s) & Destructor(s)
        internal Server()
        {
            this.Globes = new HashSet<Globe>();
        }
        #endregion
        #region Property(s)
        public virtual ICollection<Globe> Globes { get; set; }
        public string Name { get; set; }
        #endregion
    }
    public class Globe : ReadModelEntity
    {
        #region Field(s)
        private Uri uri;
        private string uriString;
        #endregion
        #region Constructor(s) & Destructor(s)
        internal Globe()
        {
            this.GlobeProperties = new HashSet<GlobeProperty>();
            this.Servers = new HashSet<Server>();
        }
        #endregion
        #region Property(s)
        public virtual ICollection<GlobeProperty> GlobeProperties { get; set; }
        public virtual ICollection<Server> Servers { get; set; }
        public Uri Uri
        {
            get
            {
                return this.uri;
            }
            set
            {
                this.uri = value;
                this.uriString = this.uri.ToString();
            }
        }
        public string UriString
        {
            get
            {
                return this.uriString;
            }
            set
            {
                this.uriString = value;
                this.uri = new Uri(this.uriString);
            }
        }
        public string Realm { get; set; }
        #endregion

T.C. Boring

unread,
May 4, 2013, 10:27:43 PM5/4/13
to Qudoos Chaudhry, ncqr...@googlegroups.com
I understand DDD, CQRS, and Event Sourcing.   The MyNotes NCQRS sample uses EF for the read model, so I don't see the problem with my use of EF for my read model.

Yeah, I've read stuff by Udi, and Greg Young, and Martin Fowler on DDD, CQRS, and Event Sourcing...so that link doesn't help.  My problem is understanding how to lay out my Domain correctly using NCQRS.

Sent from my Windows Phone

From: Qudoos Chaudhry
Sent: 5/3/2013 7:46 PM
To: T.C. Boring; ncqr...@googlegroups.com
Subject: RE: Advanced Ncqrs Examples

Abdul Qudoos

unread,
May 5, 2013, 8:32:27 AM5/5/13
to T.C. Boring, ncqr...@googlegroups.com
I apologize. I saw your EF model and thought it was your domain model. From what I understand, your read model does/should not have a domain like structure. My understanding is that each screen in your view should have one "stored" read model. This data should not be normalized according to RDBMS's. it should be a denormalized view of the screen. This responsibility segregation of writes vs. read is what makes the reading if the data fast.

Based on this you can store your servers and globes multiple different ways on how you are displaying them. 

This is my understanding and I am not an expert. I have built a system like this using ncqrs and have bad no issues. 

One thing you will need to consider is the capability to replay your events. 

Hope it helps. 

--
Qudoos

Greg Young

unread,
May 5, 2013, 6:19:11 PM5/5/13
to ncqr...@googlegroups.com, T.C. Boring
It's not always 1-1
--
You received this message because you are subscribed to the Google Groups "ncqrs-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ncqrs-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
Le doute n'est pas une condition agréable, mais la certitude est absurde.

Abdul Qudoos

unread,
May 5, 2013, 7:53:37 PM5/5/13
to ncqr...@googlegroups.com, ncqr...@googlegroups.com, T.C. Boring
Yes I understand that. Thanks. :)

--
Qudoos
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

theBoringCoder

unread,
May 8, 2013, 1:54:50 PM5/8/13
to ncqr...@googlegroups.com, T.C. Boring
Actually, I apologize.  It's obvious to me now that, although I've done a lot of reading, much of it has not sank in.  Conceptually, I understand the large blocks of DDD + CQRS + ES...but trying to implement these things is another matter.  I get the "You're diong it wrong" award for the code fragments I posted previously.  I'm one of those people that, when it comes to new technology, learns more by manipulating samples and working with working code than reading documentation, papers, and blog postings.  After doing this first project with DDD + CQRS + ES, it'll all sink in and my next project with it will be done lightening fast.

I read that post by Udi that you suggested, and it just didn't help clear anything up.  I think my biggest problem is that I'm falling into behaviors that I developed after many years of developing in the CRUD-based context.  I built my Read Model first because, like a bad developer, I reach for my data modeling tools (a.k.a SQL Server Management Studio) first when designing/building something new--because I still think in the context of modeling out the entities & how the data will look at rest.

What I need is something like http://dddsample.sourceforge.net/ built using Ncqrs.  For me, it'd be like a Rosetta Stone.

thanks,

Tom
theBoringCoder

Qudoos Chaudhry

unread,
May 8, 2013, 2:01:27 PM5/8/13
to ncqr...@googlegroups.com, T.C. Boring
The reason I suggested Udi's post was because of how quickly we jump to model things in terms of 1-many relationshipts. Sometimes just thinking a bit we may realize that its not as such. I saw your comment about Servers-Globes-Servers and thats the first thing that came to mind. 

Anyhow, you are the only one facing this challenge. I too faced this challenge and feel silly about some of the questions I had/asked when I first started looking at CQRS/ES. Spend time on identifying your domain properly and finding the verbs. The read side of things can be easily implemented by the other team members of your company...;)
Sent from my bulky computer.

Qudoos Chaudhry

unread,
May 8, 2013, 2:02:00 PM5/8/13
to ncqr...@googlegroups.com
Sorry I meant you are NOT the only one. LOL.

theBoringCoder

unread,
May 8, 2013, 7:06:03 PM5/8/13
to ncqr...@googlegroups.com
Understood.

Galen Parker

unread,
May 8, 2013, 10:15:33 PM5/8/13
to ncqr...@googlegroups.com, T.C. Boring
Hi mate, there are no such fully functional samples using NCQRS unfortunately, that I have seen.

The prototype project I used NCQRS on ending up using nServiceBus as well and generally things worked ok. 

However there are less opinionated ways to do this work than using NCQRS and that's generally why the community has moved on to other more flexible solutions and NCQRS has stagnated.

theBoringCoder

unread,
May 14, 2013, 2:41:45 PM5/14/13
to ncqr...@googlegroups.com, T.C. Boring, ga...@landlordcentral.com.au
"However there are less opinionated ways to do this work than using NCQRS..."
 
Such as?  I ask because the other CQRS + Event Sourcing project I worked on, at a different place of employment, we had an architect who rolled all the low level pieces--the type of stuff found in Ncqrs.  Now, I'm trying to do CQRS + Event Sourcing on a project where I'm the sole resource, and I just don't have time to roll my own.
 
Also, in case anyone is interested, I reworked the "MyNotes" sample a bit, and added it to my Ncqrs fork as "MyNotes 2012": https://github.com/theBoringCoder/ncqrs/
Reply all
Reply to author
Forward
0 new messages