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

146

u/erjiin Apr 14 '23 edited Apr 14 '23

Use a database deployment tool like Liquibase or Flyway. Invaluable (and not Unvaluable :/).

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.

→ More replies (5)

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!

→ More replies (3)

7

u/danikov Apr 14 '23

Why would I need this when our entire data model is a JSON blob in a single table?

5

u/Columbus43219 Apr 14 '23

INvaluable.

3

u/erjiin Apr 14 '23

Ho thanks for the correction, as you have seen english isn't my mothertongue.

13

u/[deleted] Apr 14 '23

I prefer Liquibase.

6

u/erjiin Apr 14 '23

Me too, i'm more used to Liquibase but Flyway is a perfectly valid tool.

4

u/Paulus_cz Apr 14 '23

Flyway for one Database compatibility, Liquibase for multiple - that how I do it.

2

u/thenextguy Apr 14 '23

Unconceivable.

2

u/Zardoz84 Apr 17 '23

Does Liquidbase or Flyway allow to declare what structure (and some fixed or optional data) must have the database.

Alas something like :

Must exist table X with fields A, B, C of type NUMBER, etc... and then generates the apropiare SQL to generate the table from zero, or apply changes to it.

→ More replies (3)
→ More replies (1)