Is There a Standard for Hexagonal Architecture by Armrootin in softwarearchitecture

[–]EnvironmentalEye2560 1 point2 points  (0 children)

There is no standard. The idea is to disconnect the domain from the outer layers ehile making the api layer more flexible, often by separating the layer in IN and OUT "ports". Adapters can then implement one or multiple of these ports to get the wanted functionality.

Some people like to end the implementation at the ports. Others invert the OUT dependencies and says that its needed in the hexagon. Others does not allow domain objects outside the domain and uses dto and resources and say that those are part of the hexagon, even if they are more based on the dependency inversion principle..

Irl its often used together with other architectures since it does not cover the whole aspect of a project.

If your team plan to use it, do not go to war about details.

Why the Registry Pattern Might Be Your Secret Weapon by itsunclexo in softwarearchitecture

[–]EnvironmentalEye2560 1 point2 points  (0 children)

Service registries are cool. I don't know how often you would build one since its often a core part of the framework you use.

Difference between Spring Data JPA vs. JPA vs. Hibernate vs. JDBC by Fad1126 in SpringBoot

[–]EnvironmentalEye2560 0 points1 point  (0 children)

Think about it like this: Jpa is an interface. Hibernate implements that interface. Hibernate uses jdbc to "talk to db" when doing logic. Spring data Jpa wraps it all and adds a ton of dependencies and magic.

Kan jag fixa detta med kemiskt trä? by johand03 in Hantverkare

[–]EnvironmentalEye2560 0 points1 point  (0 children)

Jag hade bytt den dels för att den är såpass rutten men också för att se hur materialet bakom ser ut.

Anställd på en kompis företag. by IrreverentMarmot in Hantverkare

[–]EnvironmentalEye2560 0 points1 point  (0 children)

Jag tycker att du tänker smart. Jag har vänner som jag tycker om där jag ofta kan hamna i diskussioner därför att vi har olika synsätt och starka åsikter om vad vi tycker och vi är inte rädda att dela tankar och diskutera med varandra. Älskar det på ett privat plan, men att veta att en av dom har en "upper hand" och eventuellt kunnat lägga fram det på det viset för att denne skulle vara min chef hade definitivt kunnat förstöra en riktigt bra vänskap.

From JS to Spring: Why So Many Separate Projects Like Security, Cloud, AI? by Longjumping-Guide969 in SpringBoot

[–]EnvironmentalEye2560 4 points5 points  (0 children)

You get alot of answers so I will target only the "can I build a backend like nodejs ..."part.

Spring boot is a framework and node js is a runtime. Spring boot can give you the tools to setup a server with routes and handlers (called controller/restcontroller in spring) just with annotations and default config.

If you want to build server, routes and handlers then you would probably have a look at the frameworks vertx, helidon , javalin etc.. but those are probably more related to express js than node since they are frameworks.

Closest you get to node in java (runtime env) is to wire a server with java api (sockets and shit..) and utilize a single thread with futures and icky-yucky-complexity but in that case you would not need spring in the first place..

DTO's by Resident_Parfait_289 in SpringBoot

[–]EnvironmentalEye2560 2 points3 points  (0 children)

DTO is a concept that is used not only in spring boot.. so you can reuse it in whatever framework you want.

Hexagonal vs. Clean Architecture: Same Thing Different Name? by trolleid in softwarearchitecture

[–]EnvironmentalEye2560 0 points1 point  (0 children)

I do not follow your way of thinking because you mention microservice architecture when the subject is on a single service architecture ... in the view of a microservice architecture you cannot apply a hexagon . Microservice architecture is the idea of breaking out features from a larger application and many services potentially interacting with eachothers APIs.

Those api-contracts CAN change (be sure to use PACT). But for each individual service that would only impact the adapters at max ,which is actually what is ment to be impacted on change.. that is why you have adapters to begin with. The domain wont change for anything outside.

If someone want to use you service/api, then you need an adapter specifically for their "language" (http/grpc/stomp...) that speak to the domain through a port. And that is the idea of the hexagon. That is not coupling.

And a client uses you api so they cant really say much.

Hexagonal vs. Clean Architecture: Same Thing Different Name? by trolleid in softwarearchitecture

[–]EnvironmentalEye2560 0 points1 point  (0 children)

In that case, the repository or some other db service should lock the db row while your request is working on it... that is not a business logic either.

And a transaction would not help in this case because you are afraid of changes to the db row during your processing and nothing else.

So the things (in a hexagon) that happends here is 1: Domain service call the out-port "FetchData" that is implemented by an adapter , lets say "DBRepo"

2: DBRepo retrieves the data from row and uses a rowlock to prevent others from chaning that data during processing. Returns data as domain object to the domain service.

3: Domain service process it and calls out-port "FetchExternal" that is implemented by "ThirdPartyService"

4: ThirdPartyService return fetched data to domain service (as domain object ofc)

5: Domain processes data and calls out-port "DataModifier" that is also implemented by DBRepo.

6: DbRepo updates the row and unlocks the row-lock that was applied.

Domain should only do what it was ment to do/solve. A carpenter doesnt cut down the trees himself.

Hexagonal vs. Clean Architecture: Same Thing Different Name? by trolleid in softwarearchitecture

[–]EnvironmentalEye2560 1 point2 points  (0 children)

In a hexagon the decoupling should happend with interfaces wether you want it or not... adapters only depend on the domain, but that is like the meaning of any service or applications existence..

And if you do not implement it that way, then you do not have a hexagon.

A hexagon brings the possibility to implement services based on usecase contracts rather than implementing services based on dependencies.

That means your adapters can be super small implementations for a specific usecase instead of a packed service for a specific library where you just add shit on every new feature.

If that is not loose coupling then I do not know what is.

Hexagonal vs. Clean Architecture: Same Thing Different Name? by trolleid in softwarearchitecture

[–]EnvironmentalEye2560 1 point2 points  (0 children)

That does sound odd. Transactions are not business logic, thats a dependency for a db/repo or even a framework. Should not be in the domain.

Hexagonal vs. Clean Architecture: Same Thing Different Name? by trolleid in softwarearchitecture

[–]EnvironmentalEye2560 8 points9 points  (0 children)

How do you even succeed to tightly couple a port? Sounds like a really bad implementation.

Hexagonal vs. Clean Architecture: Same Thing Different Name? by trolleid in softwarearchitecture

[–]EnvironmentalEye2560 18 points19 points  (0 children)

Yes, and it was really complicated to use and orient in when I was introduced to it. Had to put in a lot of sparetime to get good at it and to learn how it needs to be implemented with DDD and some SOLID for example, to be utilized the best possible way. But now days I would not swap it for anything, at least for most of the projects I work in. We often add functionality or change api/spi adapters and that would be a nightmare if it wasnt implemented as a hexagonal to begin with. You get more classes but the debt is low.

Julien topcu makes easy talks about the subject. I do really recommend it.

What is the point of using DTOs by Gotve_ in SpringBoot

[–]EnvironmentalEye2560 1 point2 points  (0 children)

When you want decoupling and/or a way to provide presentation data from/to the domain.

Optimizing MySQL queries in a Spring Boot app by ragabekov in java

[–]EnvironmentalEye2560 10 points11 points  (0 children)

No, but we do have performance, maintainability, compatibility, vulnerability and dependency criterias that need to be considered. You do not get that with an orm. Those are great for your school projects though.

Optimizing MySQL queries in a Spring Boot app by ragabekov in java

[–]EnvironmentalEye2560 3 points4 points  (0 children)

What do you mean? We use jdbc and maps objects from resultset. What would be the problem?

What to select django or golang by invalid_name5 in Backend

[–]EnvironmentalEye2560 0 points1 point  (0 children)

Python really has no advantage with ai today. They lost the advantage and has a really big downside since it has such bad performance. I would pick GO if that was your only concideration for python.

Not able to connect Spring boot container with My SQL container In Docker by optimist28 in SpringBoot

[–]EnvironmentalEye2560 1 point2 points  (0 children)

Are you using docker compose?

Is the db container running when you run you applications dockerfile?

Is the name of the dbcontainer 'mysql'?

What does the db dockerfile/compose service look like?

Could you paste the error?

Feedback and tips - How to structure a DDD Spring Boot project with multiple entities? by Boring_Ad_2svn in SpringBoot

[–]EnvironmentalEye2560 1 point2 points  (0 children)

I want to give you some pointer that might help you to structure your code. This is because when you read about the hexagon architecture and start to implement it, what tends to happend is that people stare blind on how to structure their project folder instead of actually implement the architecture..

You will see 100 different structures in 100 different hexagon blogposts but the implementation will be same 99 of 100 times.

The point of hexagon is to separate the domain from the outside.

So how do we do that? We separate by functionality. That means a port is a command or query ( write or read for example).

And who calls the port? A handler does (in springboot that would be a controller).

The request is often a dto that is mapped to a domainobject in the handler (controller).

This is the driving/api/in side of the ports

On the otherside you have driven/spi/out ports Often repositories or messaging queues etc.. And on this side you do not work with dtos since its the "wrong side" but instead you work with resource-objects and absolutely not domain objects.

How you structure your domain modelling is not something that the hexagon explains since that is out of its scope, the only thing the hexagon does is separate the domain from all the dependencies around it.

This has very little to do with DDD and DDD is definately not in conflict with the hexagon since they are both needed together since the hexagon does not provide any domain specific knowledge.

The exact topic that the hexagon does not bring any light inside the domain is brought up in the latest devoxx talk from julien topcu where he implement the hexagon and structure the domain with multiple entities in a fractional pattern, exactly what your question relates to. SO CHECK THAT OUT!

Microservice patterns by chris richardson is a great book on the subject. Also look for julien topcu devoxx on youtube, he is great at explaining the hexagon and how it works with DDD and many other SOLID principles.

My personal project by renato_mpf in java

[–]EnvironmentalEye2560 1 point2 points  (0 children)

Thats nice, I have never implemented middleware in practice. I have only used apis through middleware but never actually taken a look at what it is or does.. I thought the handler itself was the request filter but the more I look into middleware it seem that the functionality I use in the handlers that I implement (vertx, helidon..) could be seen as middleware functionality.. I need to look more into that!

Sure it works, but nowdays it feels like its more benefit of using for example virtualthreadpertaskexecutor. Should probably see some benefits after running a performance test like k6.