Private Method Anti(?)-Pattern

I’m not sure I agree with much of this, but it is an interesting summary of the views in favour of private methods. My main problem with the points as expressed in this article is the circular or self-referential nature of the arguments. For example, the author states:

Breaking up a public method that consists of n private methods into n public methods of n new classes only so that we can test that the methods are indeed invoked, however, introduces unwanted complexity and completely breaks encapsulation principles

Without ever acknowledging that it potentially only breaks his implicit definition of encapsulation. An alternative view is that the “outer” object is still well-encapsulated if it restricts access to its private objects, even where the methods on those objects are public.

Patric Fornasier’s Blog: Private Method Anti(?)-Pattern

Post a Comment

*Required
*Required (Never published)