Tomer Ben David (8) [Avatar] Offline
#1
"Modules need to be loosly coupled but strongly cohesive". I would love to follow this. What I fail to understand is how is it possible lets say I have the following modules for an accounting system:

Reporting module
Audit module
Account management module
Account archiver module
Etc many more modules (or just those)

Let's say its just so happens that all these modules need to use the account properties

Account Id
Account name
Account balance
Account address

So each of their domain bounded context in each module will have a definition of such ADT with all these properties the reason each of these modules will have this definition repeated is for decouple so if I change that ADT in one module it does not effect other modules. But now I have code duplication. If on the other hand I use a shared module with a single definition of account ADTs reused by all modules I don't have decoupling and I get no code duplication

So is there any way out of this?

Thanks
Debasish Ghosh (111) [Avatar] Offline
#2
Loose coupling doesn't imply that we cannot share anything between them. Account ADT, if used in multiple modules, you can very well share. This can be either in the form an import or in the form of another module - depending on the amount of information you would like to share.

There's also a related concept called Bounded Context, which I discuss later in the book. Bounded Contexts are of larger granularity than modules. But even they can also share information through proper model of communication. This is described in great details in Eric Evans' DDD book. I also discuss this in chapter 5 in quite some details.

Thanks.