What’s an Aggregate Root?

In the context of the repository pattern, aggregate roots are the only objects your client code loads from the repository. The repository encapsulates access to child objects – from a caller’s perspective it automatically loads them, either at the same time the root is loaded or when they’re actually needed (as with lazy loading). For … Read more

What is the difference between Builder Design pattern and Factory Design pattern? [closed]

With design patterns, there usually is no “more advantageous” solution that works for all cases. It depends on what you need to implement. From Wikipedia: Builder focuses on constructing a complex object step by step. Abstract Factory emphasizes a family of product objects (either simple or complex). Builder returns the product as a final step, … Read more

Naming Classes – How to avoid calling everything a “Manager”? [closed]

I asked a similar question, but where possible I try to copy the names already in the .NET framework, and I look for ideas in the Java and Android frameworks. It seems Helper, Manager, and Util are the unavoidable nouns you attach for coordinating classes that contain no state and are generally procedural and static. … Read more

Difference between static class and singleton pattern?

What makes you say that either a singleton or a static method isn’t thread-safe? Usually both should be implemented to be thread-safe. The big difference between a singleton and a bunch of static methods is that singletons can implement interfaces (or derive from useful base classes, although that’s less common, in my experience), so you … Read more

What are drawbacks or disadvantages of singleton pattern? [closed]

Paraphrased from Brian Button: They are generally used as a global instance, why is that so bad? Because you hide the dependencies of your application in your code, instead of exposing them through the interfaces. Making something global to avoid passing it around is a code smell. They violate the single responsibility principle: by virtue … Read more

What is dependency injection?

The best definition I’ve found so far is one by James Shore: “Dependency Injection” is a 25-dollar term for a 5-cent concept. […] Dependency injection means giving an object its instance variables. […]. There is an article by Martin Fowler that may prove useful, too. Dependency injection is basically providing the objects that an object … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)