Bit i have read that it is better to ensure to modify one aggregate each time, so it shouldn't recommended to modify orders and buyers in the same process.
Modifying one aggregate is not the same as modifying one aggregate entity.
Your aggregate may consist of several tables' worth of data, e.g. a Person
aggregate with many Address
es and Car
s as subaggregates.
For example, if you were to create a new person with all their address and car information, you would need to update three tables to insert it all, but you would still only be modifying one aggregate.
Tangentially, IF the "modify one aggregate" advice is referring to one aggregate instance (rather than aggregate type), I also don't quite agree with the advice you've been given.
For example, if I'm trying to do a bulk import of a lot of people from e.g. an import file, I want all of those aggregates in a single transaction. It would be a horrible user experience if some of the import succeeded and the user was now forced to come up with a new file that only contains the ones that failed. It is better to not import anything so the user can fix the existing file and try again.
Others might disagree with that example and say they prefer to already import the things that work. That's okay, as long as it makes sense for their use case. Both approaches can be valid. The point I'm trying to make here is that if your advice says that you're allowed to only do one of these and not the other as a blanket rule, I wholeheartedly disagree.
and perhaps in some complex process, if i modify an aggregate it affects to another aggregate.
That is indicative of bad aggregate design - to some extent. There are business cases where it can make sense but this is very contextual.
Generally speaking, your aggregates should be independent modules of your business logic that have no bearing on one another (other than potentially a reference ID to another aggregate).
I should in principle be able to separate your codebase into microservices, one per aggregate, without much effort or needing to break up any coupling between the aggregates.
In summary. Is it really needed a unit of work with DDD?
As far as I'm concerned, UOWs and DDD have nothing directly to do with one another. They're both a kind of good practice and I tend to use them both frequently, but each for their own reason.