Dependency Inversion Principle (SOLID) vs Encapsulation (Pillars of OOP)

Does IoC always break encapsulation, and therefore OOP? No, these are hierarchically related concerns. Encapsulation is one of the most misunderstood concepts in OOP, but I think the relationship is best described via Abstract Data Types (ADTs). Essentially, an ADT is a general description of data and associated behaviour. This description is abstract; it omits … Read more

Having a repository dependent on another repository

Repository should have single responsibility – persist one kind of entity. E.g. employees. If you have to delete some associated records from other repository, it looks like business logic. E.g. When employee is fired we should remove his work log And usual place for business logic is a domain services. This service will have both … Read more

Learning Single Responsibility Principle with C#

Let’s start with what does Single Responsibility Principle (SRP) actually mean: A class should have only one reason to change. This effectively means every object (class) should have a single responsibility, if a class has more than one responsibility these responsibilities become coupled and cannot be executed independently, i.e. changes in one can affect or … Read more

What is the meaning and reasoning behind the Open/Closed Principle?

It means that you should put new code in new classes/modules. Existing code should be modified only for bug fixing. New classes can reuse existing code via inheritance. Open/closed principle is intended to mitigate risk when introducing new functionality. Since you don’t modify existing code you can be assured that it wouldn’t be broken. It … Read more

Single Responsibility Principle vs Anemic Domain Model anti-pattern

Rich Domain Model (RDM) and Single Responsibility Principle (SRP) are not necessarily at odds. RDM is more at odds with a very specialised subclassof SRP – the model advocating “data beans + all business logic in controller classes” (DBABLICC). If you read Martin’s SRP chapter, you’ll see his modem example is entirely in the domain … Read more

In SOLID, what is the distinction between SRP and ISP? (Single Responsibility Principle and Interface Segregation Principle)

SRP tells us that you should only have a single responsibility in a module. ISP tells us that you should not be forced to be confronted with more than you actually need. If you want to use a print() method from interface I, you shouldn’t have to instantiate a SwimmingPool or a DriveThru class for … Read more

Application architecture/composition in F#

This is easy once you realize that Object-Oriented Constructor Injection corresponds very closely to Functional Partial Function Application. First, I’d write Dings as a record type: type Dings = { Lol : string; Rofl : string } In F#, the IGetStuff interface can be reduced to a single function with the signature Guid -> seq<Dings> … Read more

techhipbettruvabetnorabahisbahis forumuedueduseduedueduedueduedueduedus