Modules

When you place some classes together in a Module, you are telling the next developer who looks at your design to think about them together. If your model is telling a story, the Modules are chapters.
               Domain-Driven Design:Tackling Complexity in the Heart of Software
                                                                                                                                  -Eric Evans 
                                                                                                                                      

A common concern when building an Application following Domain-Driven Design is where to place the code. Specifically if you're using a PHP framework, it's important to know the recommended way to place the code, where to place Infrastructure code, and how the different concepts inside the model should be structured.

In Domain-Driven Design, there's a tactical pattern for this: modules. Nowadays, everyone structures code in modules. All languages have some sort of tool to group classes and language definitions together. Java has packages. Ruby has modules. PHP has namespaces.

Domain-Driven Design goes one step further toward packaging and grouping your classes together and gives semantic meaning to these building blocks. Indeed, it treats modules as a part of the model. As part of the model, it's important to find the best naming, group together Domain objects that are close to each other, and keep the Domain objects that aren't related decoupled. Modules should not be treated as a way to separate code but as a way to separate meaningful concepts in the model.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset