New answers tagged design-patterns
0
votes
How to store product and pricing history in a product database?
I think prices of anything are very crucial and it is essential to store pricing so that they can be retrieved accurately without any complex logic except a single join.
For example: ProductA's price ...
-1
votes
Do Interactors in "clean architecture" violate the Single Responsibility Principle?
The Clean Architecture book clarifies SRP (p.62):
Historically, the SRP has been described this way:
A module should have one, and only one, reason to change.
Software systems are changed to satisfy ...
2
votes
Accepted
How encapsulating what varies can help us?
It is the nature of an example that it is simple and that a reader can easily grasp its entire content without needing an elaborate explanation.
It is the nature of real production code that things ...
0
votes
Access Token Or Alternative for Microservices For Resource Level Granular Checks
When you deal with db records, you dont use access tokens. You should somehow relate the user with the records they have access to. It could be by using the user-id in your resource-table or a ...
6
votes
Accepted
In poltergeist, whats wrong with "solely to trigger or initialize several other objects"? Isn't it is a good use of encapsulation and reuse?
First, let me say the Wikipedia article about Poltergeist, as it is written today in Sept. 2023, isn't very clear. It lacks an example, suffers from some overgeneralization and oversimplification, and ...
0
votes
Is it an anti-pattern to use interface for entity?
If you have a simple data-only object, declaring and using an interface costs very little.
Very often you don’t have a simple data object. Say you have an object that can persist or load itself. Or ...
0
votes
Is it an anti-pattern to use interface for entity?
Although not immediately obvious, your example demonstrates a common interface that represents the same conceptual data in two different domains.
This is one of the primary reasons to implement ...
0
votes
Accepted
How could I apply the strategy pattern to a react component?
Strategy vs composition
You are realy asking 2 questions here. How to use composition with React components and how to use the strategy pattern.
Let me first give you the traditional way to get rid of ...
0
votes
Is it an anti-pattern to use interface for entity?
The article you mention probably - more or less explicitly - places itself in the context of a Rich Domain model, or at least an architectural style where there is a "pure" business layer ...
0
votes
Alternatives to the singleton pattern
It depends very much what you mean by singleton. My definition: A “singleton instance” (not class) is an object that serves a specific purpose, that should be exclusively used for that purpose, that ...
0
votes
Is it an anti-pattern to use interface for entity?
I read an article about that using interface for entity is anti-pattern by these reasons
You need to understand this advice in context.
Programming to interface is a very well known and important ...
0
votes
Is it an anti-pattern to use interface for entity?
Two counterarguments:
quite often, there is a second implementation: a mock object for unit testing.
even if there isn't, it is a stronger split between interface and implementation.
9
votes
Is it an anti-pattern to use interface for entity?
Without the full context of this article, it's impossible to say exactly what the point of it was but I think I can provide a useful answer to your question.
The first bullet "Your interface ...
4
votes
Is it an anti-pattern to use interface for entity?
Put it to the test:
class JpaBook implements Book {
// implement entity for JPA
}
class RedisBook implements Book {
// implement entity for Redis(for caching)
}
If you delete implements Book and ...
6
votes
Is it an anti-pattern to use interface for entity?
Interfaces should be designed in their own right. They are not simply accessories to a class.
That said, this:
Your interface signature [is] identical to your class
can actually be fine. It just ...
0
votes
Accepted
What C# Object Composition strategy would you apply for CoreObjects with a governing 'ObjectType' property
This DesignType determines various fundamental characteristics of the design object, and various calculated values of the design type may have different calculations based on the DesignType. The ...
3
votes
How encapsulating what varies can help us?
As always the question for the "best" software design depends on the specific context and requirements, therefore there will likely be no definite answer, but lets introduce some concepts ...
1
vote
Is this a bad pattern for reporting/audit?
Put the item on a message queue
...
reporting events are frequently missing due to restarts
Restart of what ?
The message queue restarts:
Surely you should be using a message queue service (plenty of ...
0
votes
How encapsulating what varies can help us?
First of all: your pancakes know how to cook and plate themselves. In my opinion that's a code smell. It also obscures why you would want to encapsulate the pancakes.
Assume your EncapsulationExample ...
0
votes
How encapsulating what varies can help us?
Software engineering is about insuring against future, as yet unknown change.
As long as all your program never changes, i.e. all it does is serve pancakes, and pancakes have no other use than being ...
1
vote
Is this a bad pattern for reporting/audit?
The steps you listed in your question are a high level description of a standard solutions. It is too high level though, there are a lot of details of the implementation that are not trivial. First of ...
3
votes
Event-driven design with delayed consequences
It sounds like you have a lot of conditions going on here, not a bad thing, but I think you will definitely need to ensure that your events are organized. Spend some time and diagram out your sequence ...
3
votes
Accepted
Event-driven design with delayed consequences
Some part of your system needs to have the knowledge which fields of which objects are required before a certain procedure can be started. Usually, this knowledge is bundled with the procedure itself, ...
1
vote
Event-driven design with delayed consequences
Is there a clean way to do this with event-driven design?
Yes. Queue up a "query" or "interact" event, and attach the backlog fields.
This might arrange for an RDBMS query to ...
Top 50 recent answers are included
Related Tags
design-patterns × 4397design × 884
object-oriented × 673
object-oriented-design × 590
c# × 538
java × 497
architecture × 438
mvc × 191
php × 189
c++ × 188
domain-driven-design × 182
python × 127
programming-practices × 120
dependency-injection × 119
javascript × 110
patterns-and-practices × 110
.net × 99
architectural-patterns × 98
interfaces × 95
database × 89
api-design × 85
anti-patterns × 81
refactoring × 78
database-design × 76
solid × 76