What design pattern to use for one big method calling many private methods
Posted
by Jeune
on Stack Overflow
See other posts from Stack Overflow
or by Jeune
Published on 2010-06-12T14:52:54Z
Indexed on
2010/06/12
15:02 UTC
Read the original article
Hit count: 236
design-patterns
I have a class that has a big method that calls on a lot of private methods. I think I want to extract those private methods into their own classes for one because they contain business logic and I think they should be public so they can be unit tested.
Here's a sample of the code:
public void handleRow(Object arg0) {
if (continueRunning){
hashData=(HashMap<String, Object>)arg0;
Long stdReportId = null;
Date effDate=null;
if (stdReportIds!=null){
stdReportId = stdReportIds[index];
}
if (effDates!=null){
effDate = effDates[index];
}
initAndPutPriceBrackets(hashData, stdReportId, effDate);
putBrand(hashData,stdReportId,formHandlerFor==0?true:useLiveForFirst);
putMultiLangDescriptions(hashData,stdReportId);
index++;
if (stdReportIds!=null && stdReportIds[0].equals(stdReportIds[1])){
continueRunning=false;
}
if (formHandlerFor==REPORTS){
putBeginDate(hashData,effDate,custId);
}
//handle logic that is related to pricemaps.
lstOfData.add(hashData);
}
}
What design pattern should I apply to this problem?
© Stack Overflow or respective owner