Skip to content
Advertisement

Why we should not call public method from another public?

I was told by someone that we should not call a public method of a class from another public method in same class.
Now i am not able to understand this as i dont see any problem with that.
Once a method has been declared public then its contract is fixed for lifetime and hence there should not be any problem in calling it from another public method.

So I am not sure if that statement is true or its ok to call public api from another public api [This is from design perspective]?

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement