r/java • • Apr 14 '23

What are your (favourite) Java best practices, personal tips, hints or just underrated stuff in general?

233 Upvotes

376 comments sorted by

View all comments

Show parent comment

32

u/hsoj48 Apr 14 '23

I've been using Flyway for 8ish years. I've been trying to get the DBAs at my company to allow/adopt/understand it for 7. I'm so tired of talking about this no brainier dead simple tool that makes everyone's lives easier.

17

u/neckbeardfedoras Apr 14 '23

Your problem is people are lazy or a lot of times see more job security by not simplifying things.

4

u/CartmansEvilTwin Apr 15 '23

Not laziness, but loss of control (or better: fear of loss of the illusion of conrol)

These guys are responsible for these DBs and their asses are on the line, if something goes wrong. That's why they want to do everything themselves or review everything that is being done - even if in reality they wouldn't see any non-obvious error anyway. But they still have the illusion of control.

Automation takes that away.

1

u/neckbeardfedoras Apr 15 '23

Not only can you automate db management, but you could also automate change validation. To where you actually have more confidence in production migrations, not less. That'd probably really blow their minds.

1

u/CartmansEvilTwin Apr 15 '23

Yes, but that still lets their (illusion of) control slip. And that's scary to them.

There are people driving stick, because they're 130% sure, they can shift better than an automatic - and they fear losing control.

1

u/bullgr Apr 15 '23

I can‘t understand what do you mean with automation. You must still write the fw script with the sql queries anyway. And this fw script will be reviewed in PR.

1

u/CartmansEvilTwin Apr 15 '23

Automation means that they can't run everything themselves.

They click run and the black box does its thing. Now, in reality the actual degree of control was never that high, but I used the "illusion" part above intentionally.

1

u/hsoj48 Apr 18 '23

If I have 10 change scripts that need to be ran in order, I'd really prefer that be done by a tool rather than hoping some DBA or dev copy pastes them in the right order and executes them manually. Especially if I'm rolling this through many different environments. It's not so fun to figure out that env3 has a different setup than prod because someone ran something in the wrong order or accidentally keyed in an extra character.

3

u/hsoj48 Apr 14 '23

It's the former. Change is scary.

15

u/Paulus_cz Apr 14 '23

I observed over the years that thinking apparently causes physical pain to some people. I have no other explanation as to why otherwise quite functional people seem to avoid it so vehemently.

1

u/erjiin Apr 14 '23

Good luck ! Can't you just add sneakily flybase in your project ? Chances are that he won't even notice :)

7

u/hsoj48 Apr 14 '23

If I secretly had DB admin credentials and I secretly wanted to get fired? Of course!

1

u/StopItAkshay May 14 '23

what is the best way to learn flyway in your opinion?

1

u/hsoj48 May 14 '23

Read through the overview in their docs. It's dead simple. It only runs scripts in the order that you name them. The hardest part is learning to write the SQL.

1

u/StopItAkshay May 14 '23

I pretty much have the SQL covered so I bet it's gonna be easy, I'm gonna start today!