nestjs-rest-cqrs-example icon indicating copy to clipboard operation
nestjs-rest-cqrs-example copied to clipboard

Drying things up?

Open RobertLowe opened this issue 4 years ago • 2 comments

I noticed a lot of repetition (maybe this is just a cqrs thing), and I can understand that some is justified, but for example closedAt is defined 14 times across different objects/types https://github.com/kyhsa93/nestjs-rest-cqrs-example/search?q=closedAt

So my question is this, can you think of any way to dry up your CQRS pattern?

Thanks

RobertLowe avatar May 13 '21 20:05 RobertLowe

@RobertLowe I am also very concerned about it. I thought that it could be solved by inheriting the domain class, but it didn't work as expected. If you have any good ideas, please help. thank you.

kyhsa93 avatar Jul 28 '21 02:07 kyhsa93

I just wanted to write the same thing. I don't think it is necessary to re-define new interfaces every time I work with an account. For example, why would I define a new interface here when I can just use the domain model? 🤔

https://github.com/kyhsa93/nestjs-rest-cqrs-example/blob/master/src/accounts/application/queries/account.query.ts#L1

And there are other places like for example AccountFactory these methods are basically the same? 🤔

create(id: string, name: string): Account {
    return this.eventPublisher.mergeObjectContext(
      new AccountImplement({ id, name }),
    );
  }

  reconstitute(properties: AccountProperties): Account {
    return this.eventPublisher.mergeObjectContext(
      new AccountImplement(properties),
    );
  }

developer239 avatar Jan 19 '22 08:01 developer239

Message to comment on stale issues. If none provided, will not mark issues stale

github-actions[bot] avatar Nov 13 '22 03:11 github-actions[bot]