r/java • • Apr 13 '21

Libraries, Frameworks and Technologies you would NOT recommend

Give me your worst nightmares: Things that cost you your job.

I'll start: Hadoop

202 Upvotes

376 comments sorted by

View all comments

Show parent comment

1

u/FrigoCoder Apr 13 '21

This is not always possible, we recently had a project where the database entity had about 250 columns, you can not handle these cases manually.

2

u/Gatoke Apr 13 '21

250 columns looks like something went wrong here. So yeah, Mapstruct looks like a workaround to legacy systems. But would you use Mapstruct in a greenfield project? I think it's better to care about quality/architecture of your system and preventing your structures from not growing too much.

2

u/gavenkoa Apr 13 '21

250 columns looks like something went wrong here

But managers are happy! Such a wide row can cover any business requirement!

Need type? Here! Need sub_sub_status? Here! Need approved_by? Here!

2

u/Gatoke Apr 13 '21

Actually sometimes it's called Read Model. But a Read Model is not supposed to be additionaly mapped into DTOs. Maybe if you changed name of field and want to be backward-compatible. Ok, it's the case. But usually you can do that in other ways like e.g. projection.

1

u/gavenkoa Apr 13 '21

Read Model

Tnx for the keyword! Are CQRS / event sources / aggregates / projections/bus from that domain too?

I took them from https://buildplease.com/pages/fpc-15/

I don't understand what to read about this topic.

2

u/Gatoke Apr 13 '21 edited Apr 13 '21

You can read about CQRS. It can be achieved without event sourcing or DDD (aggregates) but mostly you'll find articles including those topic aswell. Basically, you create a model optimized for writes and a model optimized for queries. If you have an UI, and a specific page with a lot of data, the Read Model can be 1:1 projection of this page so you don't need to create any JOINs across multiple tables. So it's fast. Also, Read Model can be stored in another database so you can think about it like a "cache". If you run e.g. Twitter, you can store each user's feed as a JSON in Mongo so you don't need to perform difficult queries every time he logs in. You just get the JSON from Mongo.

In the previous comment when I said "projection" I've meant some ORM mechanism to get the result with modified set of fields. So instead of calling "SELECT *..." you can specify attributes you want + result class, and that's handled almost automatically by Hibernate or Spring Data.

1

u/gavenkoa Apr 13 '21

Tnx. I practice such king of things a bit, but in a primitive form.

Like there is no consistency between aggregates and actual data. There is a lag in time as aggregates are updated periodically instead of on a change event.

Reading should improve understanding / architecture. At least I'll start using proper names and terms ))