- Which architectural patterns you know?
- What does it mean single responsibility?
- What is the difference between facade and proxy/gateway?
- What can we do in the case of constructor with big number of parameters?
- How can be implemented builder?
- What is pattern Visitor?
- What is the issue can be solved by visitor?
- What can you say about pattern observer?
- How to initialize object depends on type?
- Why Dependency Injection is needed?
- Should services always return dtos?
- The difference between adapter and decorator?
- Layered Pattern
- Microkernel
- CQRS
- Event Sourcing
- Microservices
Every module should have one single responsibility. This means two separate concerns/responsibilities/tasks should always be implemented in separate modules. Robert C. Martin defines a “responsibility” as a “reason to change”. If a module has several responsibilities, there are several reasons to change this module—namely the requirements for each responsibility may change. On the other hand a reason to change a module also means that it is the responsibility of the module to implement the aspect that is changed.
- http://www.principles-wiki.net/principles:single_responsibility_principle
- https://javarush.ru/groups/posts/osnovnye-principy-dizajna-klassov-solid-v-java
Reviewing Facade in the GoF book and the link in another answer to Martin Fowler's Gateway, it appears that their focus is in opposite directions. Facade provides a simple uniform view of complex internals to (one or more)external clients; Gateway provides a simple uniform view of external resources to the internals of an application. This distinction lets us focus on which is more important in a design : With the Facade, the external system is our customer; it is better to add complexity facing inwards if it makes the external interface simpler. With the Gateway, the internal system is our customer; give it all the help we can, even if the externals are more complex.
Builder pattern.
We will configure all of the fields that we want on the builder, and then we'll use the builder to create models. At the same time, we'll remove the public constructor from the class and replace it with a private constructor so that models can only be created via the builder.
The core of this pattern is the Visitor interface. This interface defines a visit operation for each type of ConcreteElement in the object structure. Meanwhile, the ConcreteVisitor implements the operations defined in the Visitor interface. The concrete visitor will store local state, typically as it traverses the set of elements. The element interface simply defines an accept method to allow the visitor to run some action over that element - the ConcreteElement will implement this accept method.
- https://dzone.com/articles/design-patterns-visitor
- https://refactoring.guru/ru/design-patterns/visitor
So, while the Visitor may seem a bit strange at first, you can see how much it helps to clean up your code. That's the whole point of this pattern - to allow you seperate out certain logic from the elements themselves, keeping your data classes simple.
- https://dzone.com/articles/design-patterns-visitor
- https://refactoring.guru/ru/design-patterns/visitor
Observer is a behavioral design pattern. It specifies communication between objects: observable and observers. An observable is an object which notifies observers about the changes in its state.
Abstract Factory, Factory method
- https://www.geeksforgeeks.org/design-patterns-set-2-factory-method/
- https://www.geeksforgeeks.org/abstract-factory-pattern/
Dependency injection is one of two ways of how to remove dependencies in your code. It is very useful for configuration changes after compile-time, and it is a great thing for unit testing (as it makes it very easy to inject stubs and / or mocks).
- https://stackoverflow.com/questions/21554977/should-services-always-return-dtos-or-can-they-also-return-domain-models
- https://vaadin.com/learn/tutorials/ddd/ddd_and_hexagonal
Decorator, attach additional responsibilities to an object dynamically.
Adapter, adapts interface of an existing class to another interface.