Access Modifiers and Programmer (mis)Trust
So I've been looking at some new languages recently, particularly dynamic languages like Ruby and Python. One of the first things I noticed about their syntax was the lack of access modifiers. I suppose the assumption could be made that since C# is type-enforced that it lends itself to access modifiers but I also wonder if maybe it's just a case of programmer mistrust.
If I'm writing an API that's going to be consumed by other developers, am I really so paranoid that I need to lock things away into isolated boxes to prevent misuse? No, I think I fairly well trust consumers of my code to understand my code prior to using it or do so at thier own peril.
I can see the argument being made that it makes the API cleaner if implementation code is hidden from the consumer. I don't disagree, but I think that problem is better solved by encapsulating implementation logic into a lower level class. This has the added benefit of making the implementation available for anyone that wants to take a look under the covers, but still providing a clean API layer.
So what am I really proposing here? Should we just mark everything public everywhere? No, I don't think that's really what I'm saying. What I am saying, is that it's interesting that a number of dynamic languages have decided to trust thier developers more than C# and I just think that's interesting.
Category: Uncategorized Comment »