Tag Info

Hot answers tagged

10

There are always trade offs to consider between conflicting design principles. The way to resolve it is to look at the underlying reasons behind the principles. In this case, being unable to run a query without running the command is problematic, but being unable to run a command without running the query is generally harmless. As long as there's a way to ...


8

Decoupling only works if there really is separation. Consider if you have an ordering system: Table: CUSTOMER Table: ORDER If that's all you've got, there's no reason to decouple them. On the other hand, if you have this: Table: CUSTOMER Table: ORDER Table: CUSTOMER_NEWSLETTER Then you could argue that ORDER and CUSTOMER_NEWSLETTER are part of two ...


7

Disclaimler: I'm only taking my first steps in the CQRS world, but I can offer my current understanding of the matter and we'll see if others confirm. All I write below has an underlying "as I see it" theme, and is not authoritative. The 80% case To answer your question, commands are indeed a point-to-point affair. When a command enters a controller (MVC ...


6

You've run into a problem that many have before you...a database optimized for reading is seldom good for write efficiency and vice versa. One approach that has evolved from this read-write impediment is CQRS (Command Query Responsibility Segregation). Despite Wikipedia linking the two together CQRS and CQS are technically different. CQS just demands that a ...


6

(Disclaimer: I am the author of Scritchy) I can not talk for the other frameworks, but in my case, Scritchy merely exists because I wanted to provide a quick and easy to use tool for writing CQRS apps, also taking away some of the burden of writing similar command handlers over and over... As the experts are saying: CQRS in it's most basic representation ...


5

Where I work we have an ESB to which 6 different applications (or should I say "endpoints") are connected. Those 6 applications work with 3 different Oracle schemas on 2 database instances. Some of these applications coexist in the same schema not because they are related but because our database infrastructure is managed by an external provider and ...


4

Decoupling databases and keeping the data consistent between them is an expert level task. It is very easy to get wrong and end up with the problems of duplicates etc, that the current system is designed to avoid. Frankly, taking a working system and doing this is pretty much a guarantee of introducing new bugs for no real value to the users.


4

There are several ways of going about this. You know your team best. It's best to ask yourself at what level of abstraction you need to speak for them to comprehend. Cqrs is really about seperating read logic from write logic. This is best explained by comparing it to todays layered architecture as promoted by database vendors (video section over on ...


4

To try and answer your question, lets look at where the pattern came from. Command Query Separation (CQS) where the querying will not change the state of the object (Only the commands would). The key point (in this context) is a class would consist of both Commands and Queries. Command Query Responsibility Segregation (CQRS), holds the same principal ...


4

I haven't heard of Command-Query-Separation(CQS) before, but it seems that it would relate to Single Responsibility Principle(SRP), which states that a function/class ideally should be responsible for doing one thing and one thing only. If your command code is 20 lines of code and query code is another 30 lines and they are all in one function body, clearly ...


3

With multithreading, you just can't separate queries and commands, unless you have an external lock which serializes calls. The usual approach looks like this: // query + command // moves value at top into external thread-local storage `value` // may fail and return `false` bool ThreadSafeStack::try_pop(Value& value) { lock_guard guard(m_lock); ...


3

Not sure that there is a 'one true way' answer for a design approach that, to be fair, is still evolving. First, DDD and CQRS are not the same thing although the CQRS folks seem to have derived from a DDD-influenced starting point. There's a lot going on in the DDD mindset and much of it has to do with properly defined boundaries of problems, communication ...


3

I've seen the worst possible nightmares in software architecture due to data integration, and the best weapon against this type of mess that I've encountered so far id DDD-Style Bounded Contexts. Which is not very far away from "SOA done right", on a certain sense. However, data itself is not the best way to attack the problem. One should focus on the ...


3

You shouldn't delete the events from your event store. These represent something that happened. If something happens now, then you should know it too, therefore add an event that will force your aggregate to go back to some previous state. That's a pity to delete information from your database. think about the example of the cart from greg young and the ...


3

I'd do the simplest possible thing that would work, which (for me) would be to keep everything in a database. I'd probably store the media outside the database, just to reduce the load on the connection pool (transferring several GB of data can tie up a DB connection for a long time), but other than that just keep it simple. Write every configuration ...


3

I think you need to separate two types of validation in this case; domain validation and application validation. Application validation is what you have when you verify that the command property 'text' is between 20 and 200 characters; so you validate this with the GUI and with a view-model-validator that also executes at the server after a POST. The same ...


3

I think you are on to a winner here. You have several options for scaling (from easiest to requires some effort). Buy a bigger machine. Run each component on its own server. Run more servers for each component (except for the Database) Replicate the database and service the "visitors" queries from the replication. Partition the database by "member id" and ...


2

The only question I would have is how the command service processes your commands. Are they handled asychronously or is your client waiting for the command service to process the command and complete the write to the repository before returning an ack/nack? If you're looking for scalability, that may be one area that you could focus on to improve ...


2

Besides "CQRS" solutions, what's often applied is an ESB (Enterprise Service Bus). CQRS is all around messaging and these types of frameworks exist around messaging. MassTransit http://masstransit-project.com/, https://github.com/MassTransit/MassTransit NServiceBus http://www.nservicebus.com/, https://github.com/NServiceBus/NServiceBus Eh, BizTalk, sorta. ...


2

If it's a system with any sort of scale involved (i.e. multiple users), you are almost certainly going to need a database. You should only need one. Databases are already designed to handle concurrency. Caching will come into play if, and when, you become the next Netflix. In other words, YAGNI (You ain't gonna need it, at least not yet). Caching is ...


2

I tend to resolve these naming conflicts by simply choosing different names. Perhaps you have already started calling these things by different names internally, if so, have the codebase reflect that. If not, think of something (UserCommand vs WriteCommand, Command vs Request, Action vs Command...) Basically, the overloading of the word "command" creates ...


2

First off, if that's your actual schema, it appears to be over-normalized. Hotel_Category | Categories Hotel_HotelType | HotelTypes Room_RoomType | RoomTypes Hotel_Room | Room are all candidates for being merged together by the pairing. So instead of 8 tables you would have 4. The double prefix on some of your tables is a hint that the normalization ...


1

First, add a virtual method Execute(cmd) to your Herbivorous, and put the code for the dispatching the commands to the command methods there. Then each subclass of Herbivorous can override that method and support all command methods specific to the subclass. Should look somehow like this: public class Cow: Herbivorous { public override void ...


1

Have a look at ZeroMQs documentation, especially the guide. I think you'd want something along the lines of their Figure 19 - Extended Request-reply. if not, there's a LOT of documentation there that should give you what you need in some combination. I'm not sure what you mean in point 3, but the rest looks like it needs a disconnected message passing ...


1

Well, you should not use the query subsystem for validations - use the command subsystem for that. Look into the picture in Fowler's article here - validations are typically placed at the command model side. If, for example, you try to give an entity a unique name, your command subsystem should throw an exception if that name was already used before. The ...


1

As long as you are aware that the actions outside the application will not be logged (I personally would not try to do auditing except through triggers but third part products are usually a separate problem because you have a limited ability to change the db itself.), the approach is OK. What is generally needed in auditing though is an approach where you ...


1

Should we tailor the audit log tables to fit the requirements of the front end? No. Generally this is better when you tailor the audit log tables to fit the requirements of auditors and then worry about the front-end later. Should we have separate tables to handle the "Actions" and have the events and auditing separate Yes. This gives you more ...


1

I think you need to create an interface in the BLL that holds your connection (datacontext, sqlConnection, or whatever). That concrete class would then go into the DAL. On initialization you would include the connection string. When you do a data read function you would pass along the datacontext or whatever you used for the connection. You could also ...


1

For completeness I thought to include an relevant snippet from Martin Fowler about ways to revert state: As well as events playing themselves forwards, it's also often useful for them to be able to reverse themselves. Reversal is the most straightforward when the event is cast in the form of a difference. An example of this would be "add $10 to ...


1

there are 2 main approaches external read/write locks as I said in the comments "failable" commands like the classic CompareAndSwap bool CaS(from,to){ if(from==state){ state=to; return true; } return false; } however this can result very large functions for non-trivial problem flow



Only top voted, non community-wiki answers of a minimum length are eligible