1,657 reputation
514
bio website blog.ploeh.dk
location Copenhagen, Denmark
age 44
visits member for 3 years, 9 months
seen 20 hours ago

Programmer/architect. Author of Dependency Injection in .NET. Creator of AutoFixture.


Dec
16
comment Mocking the context of application
Relevant literature: Working Effectively with Legacy Code.
Dec
16
comment Mocking the context of application
@EngineerSpock "I don't what to add the same dependency just everywhere." Why not? Please bear with me; often, attempting to answer questions like these can lead to deeper insights.
Dec
15
comment Mocking the context of application
+1 although I'd use Pure DI instead of a DI Container.
Nov
17
comment What and how much domain code should be put in an F# module
Perhaps, if that particular Bounded Context is so big, it would make sense to put it in a separate library..?
Jun
10
answered Designing communications for extensibility
Apr
5
comment Why should one subclass instead of composite when using the Factory Method design pattern?
On the conceptual level, there's not much difference. The mechanisms are language-dependent, so I don't think it makes sense to discuss them in general terms.
Apr
4
comment Why should one subclass instead of composite when using the Factory Method design pattern?
That's how I always use it, at least, so that sounds just about right :)
Apr
4
comment Why should one subclass instead of composite when using the Factory Method design pattern?
Yes, and you've also just described the difference between inheritance and composition. As the Design Patterns book state, we should favour composition over inheritance. In this case, composition is superior to inheritance because the Abstract Factory is reusable between multiple clients, whereas the Factory Method is coupled to the client.
Apr
4
comment Why should one subclass instead of composite when using the Factory Method design pattern?
That last comment of yours is zeroing in on the differences. Factory Methods usually exist only for the benefit of the base class. It's a way to apply the Open/Closed Principle by enabling clients to extend that particular class by overriding its Factory Method(s). Abstract Factory, on the other hand, only has a single responsibility: it creates objects. If composed with client classes, it can be reused across many different classes. Note also that Abstract Factory doesn't rely on inheritance. It can implement a factory interface instead of deriving from a base class.
Mar
28
answered Dependency Injection vs Mixing Levels of Abstraction
Mar
20
answered Why should one subclass instead of composite when using the Factory Method design pattern?
Mar
8
comment Empty virtual method on base class VS abstract methods
None of these suggestions are particularly good. If you have a finite, well-known set of concrete (non-polymorphic) types, the Visitor pattern is usually the best approach. However, be aware that the Visitor pattern violates the Open/Closed Principle...
Mar
3
awarded  Yearling
Jan
9
awarded  Good Answer
Oct
29
awarded  Critic
Sep
14
revised Is it a bad practice to modify code strictly for testing purposes
Corrected grammar error
Jun
9
awarded  Good Answer
May
23
awarded  Announcer
May
23
awarded  Nice Answer
May
23
answered Is it a bad practice to modify code strictly for testing purposes