DEV Community

Discussion on: Ruby private method : a hack

Collapse
 
erikwhiting88 profile image
Erik • Edited

But for your business, daily app, I think it's a burden. Often these applications are already private anyway. Think about a Rails app : no one can see your code.

Making functions private isn't about literal privacy, it's about enforcing the way a class is implemented. If you're working on a project where you're the only dev, sure, maybe private functions are a burden, but in a team context it's the cheapest and most basic way to enforce architecture. Public methods are your class's interface and should communicate how you want/expect that class to behave or be used, private methods are for handling the details, you don't want calling class's/methods touching them.