The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Janus (1) [Avatar] Offline
Hi Mark and Steven

Thank you for writing this book.

Do you have any plans on elaborating on factories compared to the 1. edition? I read the book with five other people and we all had a hard time getting started on factories combined with dependency injection.
And as we get further and further into dependency injection writing more and more code with these patterns, questions keep coming up regarding factories. One of our latest factories need to create a list of Recommandations. Each Recommandation have a different complex object graph, and our customers reuses a different set of Recommandations. That means we would end up having a rather large factory that needs a lot of pure dependency injection maintainance in each Recommandations constructor and in the different set of Recommandations depending on the customer. So we started looking into container based factories for handling the complex object graphs, but is this the right path? And how do we handle a lot of Recommandations implementing the same interface, but we only need to resolve a subset depending on the customer? And if we start looking into Domain Driven Design with private setters, how do we inject primitive types together with complex object graphs in the constructor? When we search the internet all examples are typically simple factories and we end up inventing our own solutions.
I don't expect you to answer the questions here, it's just to show you what we are trying to comprehend. smilie

Best regards, Janus
Steven van Deursen (43) [Avatar] Offline
Hi Janus,

You’ll be glad to hear that we rewrote the advice around Abstract Factories completely in the second edition. The first edition described Abstract Factories as *the* solution any time you needed to deal with the creation of dependencies that depended on runtime data, and any time a dependencies’ lifetime needed to be managed outside the Composition Root. In the second edition, although we still see value in the use of Abstract Factories, we recognize that more often than not, Abstract Factories are over-used, and better solutions are quite often available.

My advice would be to read chapter 6.2 of the second edition. That part focusses completely around Abstract Factories abuse and described alternative solutions.

When it comes to DDD and having Domain Entities consume Dependencies, chapter 4.3 of the second edition describes in some detail how Method Injection is the way to go here.

Although the second edition isn’t finished, if you pre-order it today, you already get the e-book with the first 8 chapters. I hope the already available material will point you into the right direction.

If you have any questions after reading the second edition, please let me know.