112
votes
Accepted
Clean Architecture: Use case containing the presenter or returning data?
The Clean Architecture suggests to let a use case interactor call the actual implementation of the presenter (which is injected, following the DIP) to handle the response/display. However, I see ...
75
votes
What does Robert C. Martin mean by SQL being unnecessary?
Bob Martin is clearly exaggerating to make his point more clear. But what is his point?
Does he just want people to stop using SQL/Relational Databases because of SQLi attacks?
To my understanding,...
58
votes
Accepted
Ways to share DTO across microservices?
My advice? Do not share these DTOs among the applications in any kind of library. Or at least don't do this right now.
I know, seems very counter-intuitive. You are duplicating code, right? But this ...
58
votes
What does Robert C. Martin mean by SQL being unnecessary?
Bob Martin's opinion is just that; one man's opinion.
A programmer is expected to understand the system he is writing well enough to exercise reasonable care about its security and performance. That ...
51
votes
How many design patterns and levels of abstraction are necessary?
How many ingredients are necessary for a meal? How many parts do you need to build a vehicle?
You know that you have too little abstraction when a little implementation change leads to a cascade of ...
43
votes
Is using Observer pattern a good idea while building a Chess Game?
Having a "Map object that keeps track of all the cells to which it can travel" looks to me like an example of premature optimization.
Instead of remembering all those cells for each piece "just in ...
39
votes
Accepted
Function returning true/false vs. void when succeeding and throwing an exception when failing
Throwing an exception is simply an additional way of making a method return a value. The caller can check for a return value just as easily as catch an exception and check that. Therefore, deciding ...
35
votes
Function returning true/false vs. void when succeeding and throwing an exception when failing
There is absolutely no reason for returning true on success if you don't return false on failure. What should the client code look like?
if (result = tryMyAPICall()) {
// business logic
}
else {
...
29
votes
Are there advantages to hard-coding data values into a program?
Really? No Possible Valid Use Cases?
While I agree that hard-coding is generally an anti-pattern or at least a very bad code smell, there are plenty of cases where it makes sense. Here are a few.
...
24
votes
How many design patterns and levels of abstraction are necessary?
The problem with design patterns can be summed up with the proverb "when you're holding a hammer, everything looks like a nail." The act of applying a design pattern is not improving your program ...
24
votes
Clean Architecture: Use case containing the presenter or returning data?
In a discussion related to your question, Uncle Bob explains the purpose of the presenter in his Clean Architecture:
Given this code sample:
namespace Some\Controller;
class UserController ...
22
votes
Is using Observer pattern a good idea while building a Chess Game?
My suggestion is to make things as simple as possible. The more information you give to an object, the more complex it becomes, and the harder it is to keep track of it.
Let's break your program ...
21
votes
Is the Entity Component System architecture object oriented by definition?
NO. And I'm surprised how many people voted otherwise!
Paradigm
It's Data-Oriented a.k.a. Data-Driven because we are talking about the architecture and not the language it's written in. Architectures ...
21
votes
Accepted
Is CQRS/MediatR worth it when developing an ASP.NET application?
I think you're expecting too much of the pattern you're using. CQRS is specifically designed to address the difference in model between query and commands to the database, and MediatR is just in-...
20
votes
Accepted
Is "evolutionary software architecture" a contradiction?
Neal Ford's keynote on Evolutionary Architecture can be found here.
Paraphrasing:
Architecture is the decisions
that you wish you could get right early
in a project, things that people ...
19
votes
Ways to share DTO across microservices?
When it comes to Microservices, services' development life cycles should be independent too.*
Different SLDC and different dev teams
in a real MS system, there could be several teams involved in the ...
17
votes
What does Robert C. Martin mean by SQL being unnecessary?
What is he actually saying?
Is he saying replace SQL with No-SQL technologies?
TL;DR: Yes (sort of)
In a more recent talk than the one you linked to on basically the same topic he says: "The ...
15
votes
Ways to share DTO across microservices?
I'm trying to design every service to be as independent as possible
You should be publishing events. Events are certain type of messages that represent a solid fact about something that has happened ...
15
votes
Accepted
Can CQRS pattern exist without mediator pattern?
Command Query Responsibility Separation (CQRS) separates reading and writing into two different models.
A "conventional" architecture looks like this:
A CQRS architecture looks like this:
Notice ...
14
votes
Accepted
How to handle "circular dependency" in dependency injection
What you can do is to create a factory, MainFactory that returns an instance of ConcreteMain as IMain.
Then you can inject this Factory into your Runner constructor.
Create the Main with the ...
14
votes
Accepted
Database design for objects with multiple states
Sounds like you have 3 major categories of data you are trying to store:
General job data (job id, job requester id, job receiver id etc)
State transitions (job started, job finished)
State-specific ...
13
votes
Avoiding constructors with many arguments
I wouldn't do option 2, because then you have forever convolved your object's construction with boost property tree parsing. If you're comfortable with a class that needs that many parameters, you ...
12
votes
How to architect a store to avoid overselling inventory (distributed database scenario)
It depends on the widget.
If the widget is rare and expensive (exactly 10 Ferraris), then the approach you're following is correct. Of course, you also need to account for inventory that's being ...
12
votes
What are some approaches used in financial applications to prevent deposit/withdrawal sync problems?
Transactions
A transaction wraps all of the required steps for a particular business operation and guarantees that either all of the steps succeed or they all rollback to the original state in the ...
11
votes
Accepted
Detecting breaking changes when modifying shared code
We've had a few problems where a contractor changed something in a common project and unknowingly this breaks a number of other solutions
That's is unfortunate
We're currently trying to decide a ...
11
votes
Singleton design for small/medium sized music player project
Is this approach to making these key Objects easily available when needed good architecture? Is there a better approach to this issue?
The much maligned singleton pattern occasionally has it's uses ...
11
votes
What does Robert C. Martin mean by SQL being unnecessary?
SQL is a detail. Knowledge of a detail should not spread.
As SQL is used in more and more places in your code your code becomes more and more dependent on it.
As you learn more and more SQL tricks ...
11
votes
Accepted
Microservices communication: Avoiding single point of failure
As you rightly say, having a component dedicated to pass around messages is definitely better than having every service responsible for knowing how exactly to reach all collaborating services. ...
10
votes
Is the Entity Component System architecture object oriented by definition?
Entity component systems (ECSs) can be programmed in an OOP or functional manner depending on how the system is defined.
OOP way:
I have worked on games where an entity was an object composed of ...
10
votes
Accepted
Repository pattern with service layer - too much separation?
Yes, the service layer is an overhead if you don't have any business logic there. Layered architecture looks like an overhead when a layer (in your case service) is not doing much. But a layered ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
architectural-patterns × 364architecture × 161
design-patterns × 88
microservices × 47
design × 39
domain-driven-design × 26
enterprise-architecture × 26
c# × 24
patterns-and-practices × 18
mvc × 17
java × 16
object-oriented × 12
object-oriented-design × 11
cqrs × 10
layers × 10
.net × 9
clean-code × 9
database-design × 8
clean-architecture × 8
javascript × 7
database × 7
event-sourcing × 7
api-design × 6
dependency-injection × 6
asp.net-mvc × 6