Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 2
    +1: I will do the IPerson example in my code to ensure I do not accidentally use any private methods when I'm writing code that should be copy/pastable to another IPerson implementation. Commented Feb 7, 2015 at 21:22
  • @CortAmmon I think you have a typo there, clearly you meant "work with polymorphism" rather than copy/pastable on that code :D Commented Feb 8, 2015 at 16:42
  • @BenjaminGruenbaum sure, for some definition of polymorphism ;-) Commented Feb 8, 2015 at 18:01
  • @CortAmmon how would you accidentally call a private method? Surely you meant internal? Commented Feb 8, 2015 at 19:43
  • @ColeJohnson either way. I wrote that thinking of a specific case that I run across where private is meaningful: factory methods that are part of the class being instantiated. In my situation, access to private values should be the exception, not the norm. I work on code which is going to long outlive me. If I do it this way, not only am I unlikely to use any private methods myself, but when the next developer copy/pastes this a few dozen places and the developer after that copies them, it decreases the odds that someone sees an opportunity to use private methods as "normal" behavior. Commented Feb 8, 2015 at 20:08