3 ms·
"Often, such private methods have gnarly dependencies because they directly access or modify internal state. Moving these methods to appropriate collaborators (
by martinp 17y ago
"Often, such private methods have gnarly dependencies because they directly access or modify internal state. Moving these methods to appropriate collaborators (again, creating new classes as necessary) exposes such dependencies."
This is usually why I create private methods in the first place. The methods modify internal state and they're too specific to the problem in question to move them into a separate class. Making them public just doesn't make sense and seems to break the principle of encapsulation.
Also, wouldn't moving these methods into a new class affect performance? For example if you have a private method that does some complex operations on a private/local collection, instead of performing the operations directly on the collection you have to pass the it back and forth to the public method in another class.