DDD Approach to Access External Information

The first thing I noticed was the improper use of the bank account factory. The factory, pretty much as you have it, should be used by the repository to create the instance based on the data retrieved from the data store. As such, your call to accountRepository.FindByID will return either a FixedBankAccount or SavingsBankAccount object … Read more

Does the Single Responsibility Principle work in OOP?

I like to state the single responsibility principle this way: “Every thing you write — every module, class, interface, or method, should have one job. It should do the whole job and only that job. Notice that some of these things you write are big (modules), some are small (methods), some are in between (classes), … Read more

What is an example of the Single Responsibility Principle? [closed]

The most effective way to break applications is to create GOD classes. Those are classes that keep track of a lot of information and have several responsibilities. One code change will most likely affect other parts of the class and therefore indirectly all other classes that use it. That in turn leads to an even … 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

Interface Segregation Principle- Program to an interface

Robert Martin has a very good explanation of Interface segregation principle (ISP), in his book “UML for Java Programmers”. Based on that, I don’t think ISP is about an interface being “focused” on one logical, coherent group of things. Because, that goes without saying; or, at least it should go without saying. Each class, interface … Read more

What is the scope of the Single Responsibility Principle? [closed]

Bob Martin has tried to clear this up on multiple occasions. The problem is that there are two different principles in play here; and it’s extremely unfortunate that one of them doesn’t really have a name, which is why it’s commonly conflated with the SRP. Functions should do one thing. They should do it well. … Read more

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

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 is a condensed … Read more