Among other things, the CQRS has a rule that each of the methods has one responsibility. So we can't have this in the model:
public class Store {
public Item getOrCreateItem(int id)
{
//logic
}
//....
}
and this in the controller:
Store store = new Store();
Item item = store.getItem(1);
We must have this in the model:
public class Store {
public Item createItem()
{
//logic
}
public Item getItem(int id)
{
//logic
}
//....
}
which leads to this in the controller:
Store store = new Store();
Item item = store.getItem(1);
if (item !== null) {
Item item = store.createItem();
}
But now we have a lot of code in the controller...
Is there any better way to seperate the methods than to have the extra code in the controller, which should contain little code?