There are many times when I am not sure whether a particular method should be private or not. For example, now I am building a class that is responsible for creating a report. This class has a buildReport method and several methods that collect the necessary data for buildReport.
// single public method // uses a set of helper methods public buildReport() // helper methods private avgSurveyTime() private fetchVendors() private fetchSendCounts() private ...
I am discussing whether these helper methods should be published. The only method that I really plan to call at the moment is buildReport() . However, it would be useful to get a list of providers with fetchVendors() , etc.
I see two schools of thought about this: you can always expose as little as possible. (In this case, many of my classes will have only one public method) OR you can expose anything that might be useful to the class user.
Is there a good rule to decide when methods should be public / private?
design oop
AaronSzy Apr 20 '10 at 16:17 2010-04-20 16:17
source share