B4J Question Public Subs vs. Private Subs: any differences besides accessibility?

MegatenFreak

Active Member
Licensed User
Hi.
As an old habit, I never declare my Subs as Private in any modules. I was wondering if it would be professionally wrong when I'm the only one working with the code.
I feel careless for making all subs public, but it causes no conflicts in the code, I'm sure.
Would declaring them as Private imply any difference besides its accessibility? Because if it does, I would feel obliged to fix my code.
Thanks a lot in advance.
 

Sandman

Expert
Licensed User
Longtime User
For what it's worth, I do the opposite: I declare everything private - as a way to help me maintain a higher level of separation between different parts of the code.

(I have a history of creating glorious balls of spaghetti code where things call each other all over the place. Insanity ensued, but I prevailed and came out on the other side with a desire to keep things separated and have them interact cleanly instead.)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I was wondering if it would be professionally wrong when I'm the only one working with the code.
Yes, it is a mistake. It makes the code more difficult to maintain. When you see a private sub you immediately know that it can only be called from the current module so it is easier to know what will be affected by changes to this sub.
 
Upvote 0
Top