Constructors vs Factory Methods [closed]

Ask yourself what they are and why do we have them. They both are there to create instance of an object. ElementarySchool school = new ElementarySchool(); ElementarySchool school = SchoolFactory.Construct(); // new ElementarySchool() inside No difference so far. Now imagine that we have various school types and we want to switch from using ElementarySchool to … Read more

What is the dependency inversion principle and why is it important?

What Is It? The books Agile Software Development, Principles, Patterns, and Practices and Agile Principles, Patterns, and Practices in C# are the best resources for fully understanding the original goals and motivations behind the Dependency Inversion Principle. The article “The Dependency Inversion Principle” is also a good resource, but due to the fact that it … Read more

DDD – the rule that Entities can’t access Repositories directly

There’s a bit of a confusion here. Repositories access aggregate roots. Aggregate roots are entities. The reason for this is separation of concerns and good layering. This doesn’t make sense on small projects, but if you’re on a large team you want to say, “You access a product through the Product Repository. Product is an … Read more

Aspect Oriented Programming vs. Object-Oriented Programming

Why “vs”? It is not “vs”. You can use Aspect Oriented programming in combination with functional programming, but also in combination with Object Oriented one. It is not “vs”, it is “Aspect Oriented Programming with Object Oriented Programming”. To me AOP is some kind of “meta-programming”. Everything that AOP does could also be done without … Read more

OOP vs Functional Programming vs Procedural [closed]

All of them are good in their own ways – They’re simply different approaches to the same problems. In a purely procedural style, data tends to be highly decoupled from the functions that operate on it. In an object oriented style, data tends to carry with it a collection of functions. In a functional style, … Read more

Constructors in Go

There are some equivalents of constructors for when the zero values can’t make sensible default values or for when some parameter is necessary for the struct initialization. Supposing you have a struct like this : type Thing struct { Name string Num int } then, if the zero values aren’t fitting, you would typically construct … Read more

What is the difference between aggregation, composition and dependency? [duplicate]

Aggregation implies a relationship where the child can exist independently of the parent. Example: Class (parent) and Student (child). Delete the Class and the Students still exist. Composition implies a relationship where the child cannot exist independent of the parent. Example: House (parent) and Room (child). Rooms don’t exist separate to a House. The above … Read more

Explanation of the UML arrows

Here’s some explanations from the Visual Studio 2015 docs: UML Class Diagrams: Reference: https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/modeling/uml-class-diagrams-reference 5: Association: A relationship between the members of two classifiers. 5a: Aggregation: An association representing a shared ownership relationship. The Aggregation property of the owner role is set to Shared. 5b: Composition: An association representing a whole-part relationship. The Aggregation property … Read more

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