118
votes
Accepted
What is the use of DTO instead of Entity?
Whenever a developer asks "what's the point of doing this?", what they really mean is "I see no use case where doing this provides a benefit". To that end, let me show you a few ...
18
votes
Accepted
Project Structure of Domain Driven Design in maven Java Spring-Boot
Your new architecture is also not derive from Domain Driven Design. Of course in context of tactical patterns (as strategy patterns scope go beyond the code).
In Domain Driven Design you have plenty ...
17
votes
Accepted
How to communicate API Limit between multiple applications?
Consider a stateful proxy.
What you're asking for is essentially that the API be rewritten. But since you don't own it the next best thing is to create one that you do own that delegates to the one ...
15
votes
DDD - Is anemic domain model an antipattern? Shoud we be using rich domain models?
ADM is a good pattern for a solution of distributed services such a microservices. It fits many of today's web based business cases.
Consider if we have an Order Domain object. With an OOP approach ...
12
votes
API Gateway (REST) + Event-Driven Microservices
Repeat after me:
REST and asynchronous events are not alternatives. They're completely orthogonal.
You can have one, or the other, or both, or neither. They're entirely different tools for entirely ...
12
votes
Accepted
Are Spring beans declared as static a poor design choice?
Static is not a good idea, for many reasons:
They are harder to mock in unit tests
Permanent memory consumption¹
Is procedural
And some other disadvantages
Almost every disadvantage above can also be ...
12
votes
Java: Is it okay to abuse Spring beans (@Component) rather than use static final utility classes?
The prevailing assumption that static methods are not unit-testable seems to have arisen from developers being accustomed to writing unit tests against instantiable class instances, and all of the ...
12
votes
Accepted
“Depend on abstractions, not on concretions” what is the exact meaning of this term
Depend on abstractions, not on concretions It means, coding to interfaces, not to concrete classes?
For languages that support interfaces, this is generally the case. But that abstraction layer can be ...
11
votes
Accepted
Data Objects for each layer(DTO vs Entity vs Response objects)
There is no "correct" answer here. It's really about finding the tradeoffs you're happy with.
Sharing one model across layers trades coupling for development speed. It will allow you to get your ...
11
votes
“Depend on abstractions, not on concretions” what is the exact meaning of this term
Depend on abstractions, not on concretions.
It means, coding to interfaces, not to concrete classes?
Also known as "coding to the interface (not to confuse with interface the keyword), not the ...
9
votes
Accepted
How to write dynamic (non ORM) repositories that can return only the necessary data without creating many methods or data-objecs?
It would be wasteful to always fetch the entire objects.
First I would question this. If your objects are well-designed and not too bloated, the performance and memory overhead of fetching them ...
8
votes
Accepted
What typical hardware improvements can be made to improve a Web app's performance?
Before blaming Hibernate for performance issues, you should profile your application. By profiling a given request (if the whole application feels slow, just take any request), you'll get a more ...
8
votes
Accepted
How to compare passwords which is stored in DB in encrypted form in secure way?
Question- If are storing passwords in encrypted format in DB and in future when user login into our website how will we perform authentication?
You never, ever store passwords encrypted. Never. ...
8
votes
Accepted
Should business logic classes be POJO only?
I read about three-tier architecture and I have a question: I read that in business logic (that is, what is in logic tier) there should be bare Java classes,
These bare Java classes are called POJO's ...
6
votes
Java: Is it okay to abuse Spring beans (@Component) rather than use static final utility classes?
Here is my rule of thumb. Use static utility classes if the methods are just 1-2 lines and perform operations which are easy to name with just a word or two, and which are very unlikely to ever change....
6
votes
HATEOAS APIs and front end development
The benefits of HATEOAS (Hypermedia) are real for both internal and external APIs. However, the tooling is often lacking to take advantage of those benefits.
Let's start with the "problem" of having ...
6
votes
Accepted
How to deal with large data in Websocket message?
I'll propose an answer since it's been nearly a year.
As @Walfrat has pointed out:
Note that if you're echanging too much data, it might also be a design
problem that would lead to poor ...
6
votes
How to compare passwords which is stored in DB in encrypted form in secure way?
I don't know whether the interviewer asked something wrong on purpose to see whether you would correct him or he was just simply wrong. But when you used a hash function if someone breaks into the ...
6
votes
How to communicate API Limit between multiple applications?
There are a number of strategies you can use:
Create a middleman API that you control which:
Caches responses from the 3rd party API.
When the 3rd party API returns a 429 response, your middleman ...
5
votes
Accepted
Should I create a Repository Container to get my repositories?
No, you should not. Simply hiding the dependencies by another service class will not suddenly make your controller better.
Injecting the repositories into your controller directly is much better, ...
5
votes
Accepted
Creating interface fields to inject vs Objects?
What you're observing is actually called "coding to an interface."
Like dependency injection, it's a technique for keeping your code loosely coupled. That's why you tend to see them used together.
...
5
votes
Accepted
Should DTO have same structure as payload?
Let me reword your question in a more general fashion:
there are two different representations of the same block of data (here a DTO representation and a JSON representation)
there are different ...
5
votes
DDD - Is anemic domain model an antipattern? Shoud we be using rich domain models?
SOLID and DDD are orthogonal to each other, meaning they are really going in different directions from each other. You shouldn’t say that one is used to the exclusion of the other, since they can and ...
5
votes
Accepted
IEC 62304, Are Software Frameworks (Spring/JEE/Angular/React) considered SOUP?
Keep in mind that I'm not familiar explicitly with IEC 62304 (it's for medical device software and I've never worked with medical devices), I am familiar with similar standards, such as ISO 9001 and ...
5
votes
Accepted
How to reduce dependency on IOC Framework (Frameworks in general)
The easiest way to avoid dependencies on a framework is to not use a framework.
Abstracting frameworks just doesn't work in practice. For example Microsoft tried creating an abstraction over their ...
5
votes
performance suggestions on Aggregate root containing thousands of child entities
Leaky Abstractions and Abstraction Bypasses
When the abstraction breaks, and bypassing it feels prefferable, its time to fix the abstraction.
Find a cheap way to speed it up, and put off actually ...
5
votes
Layered architecture horizontal dependencies
As usual, it all depends.
If your application is basically a big ball of mud, with a single database and a complex data model underneath, where each JpaRepository is nothing more than a mirror of a ...
5
votes
Accepted
How to achieve both: clean (hexagonal) architecture with JPA goodies?
Achieving a clean architecture while leveraging the benefits of JPA can be challenging, but it's definitely possible. Here are some suggestions on to achieve this and considerations to be made:
...
5
votes
Hexagonal Architecture + Domain Driven Design. How to perform a correct implementation?
I'm sorry to say that there is no one silver bullet when designing software. There is no "correct" way to do anything. Everything is a trade-off between different aspects of the system, like ...
4
votes
Why is a Spring's HttpClientErrorException an unchecked exception?
No one got to the root of the problem. In spring-web, this is fine. The problem is that Spring Rest uses it, too. The purpose of the two are very different.
When spring-web is doing it's thing to ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
spring × 310java × 162
design × 30
architecture × 29
rest × 27
spring-boot × 27
dependency-injection × 23
spring-mvc × 21
design-patterns × 19
hibernate × 19
microservices × 18
jpa × 18
domain-driven-design × 15
web-applications × 12
java-ee × 11
unit-testing × 10
api × 9
object-oriented × 8
object-oriented-design × 8
mvc × 8
frameworks × 8
web-development × 7
transaction × 7
maven × 7
json × 6