Why we should not call public method from another public?

Does your compiler balk at you when you try? No? Then it's legal in that respect.

Does the person providing this 'advice' produce any canonical document explaining the standard (either in the industry or within your organisation)? No? Then it's opinion.

Consult your company standards, but otherwise, I call nonsense.


If you call a public methods from other public methods it makes unit testing more complicated. If one method is depended on another method of the same class you can't mock it to test it separately. So you may have to write test code for the same method twice.

see also Unit testing a method that calls another method

Tags:

Java