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 comments

3

u/wildjokers Apr 14 '23

this. I hate it when people let you want to remember all class fields and methods and conflicting local variable's names. UGH. USE this, super, and "qualify" static stuff in this exact manner as well. Thank you.

Place I am at now doesn't allow to use this. for self calls and when I first started here (about 5 years ago) it was a huge adjustment to not use them because for the first 16 yrs of my career I was at a place that required it.

I still miss it because I think it improves readability, it makes method calls consistent and let's me know exactly where the method is when I am reading the code.

1

u/Brahvim Apr 15 '23

Very sad. What about m_?

2

u/wildjokers Apr 15 '23

m_ and p_ are abominations :-) They are both hard to type and hard to read.

1

u/Brahvim Apr 15 '23

I use p_ for parameters anyway, :joy:! Helps out me if not anybody else, haha.

→ More replies (5)