Hidden Potential
I use to ask, “What is the point of having private methods?” It seemed unnecessary to have some hidden. That wasn’t until I started separating large functions in to many smaller ones. Then it became an issue of too many methods appearing when accessing Xcode’s autocomplete.

And that’s just six functions! I usually have 6 for initialization setup alone! Now granted I know my classes since I did write them, but that isn’t what we should be worrying about as programmers. It is ourselves two weeks from now or the new guy jumping in to the code to help, or even review! (gasp)
Using private (Access Control) can help make code more readable. If I review a class and I see that there is a private method, I will know immediately that it will not be used anywhere else in the code and is only relevant to that class.

So when should I use access control functionality such as private? I’ve started simply using them for anything called in initialization. After that, I will look to privatize helper methods that I know will not be called outside of the class or struct.

In this class, movementController() is only called in update() and the other four private methods are all called in movementController(). The rest of my code doesn’t need to know about how or why this bunny needs to move, just that it does.
There are other access levels aside from private, but the only other one we care about right now is fileprivate. It works very similar to private but it skips over the scope that the private variable or method resides in and gives access to the whole file. So, why use fileprivate over private?
Well, we usually don’t! The only other time I use fileprivate is in extensions of a class. I like to organize my code by using extensions, grouping similar functionality and methods in to those extension make it readable for me. But since an extension is within different brackets and thus different scopes, private methods don’t have access to other extensions. If all your extensions are in the same .swift file, fileprivate will allow the methods to be private and still usable.

In this example, I have an extension housing all methods related to subviews that need to be initialized. Only loadSubviews() is fileprivate since it is called outside of the extension.
So to wrap it up, take some time to get use to using private and fileprivate. It might not be too important in smaller projects, but I see its potential in organization especially when we step in to the world of architectural design. Not all methods are created equally! Some stay in the shadows, but they still do good work.
