I have a MineSweeper program, where I am facing a scenario similar to.,
Where is my problem?
class operation{
<Data's needed for all operations>
/*(Each operation needs all the datas.)*/
public mainOperation(){ // user can call this mainOperation whenever they want to do some work.
operation_ABC();
operation_LMN();
}
private void operation_ABC(){
helper_DEF(); //This helper does partial work of ABC()
helper_IJK(); //This helper does remaining work of ABC()
}
private void DEF(){..//access and work on data..}
private void IJK(){..//access and work on data..}
private void operation_LMN(){
helper_OPQ();
< some work on data >
helper_RST();
}
private void helper_OPQ(){..//access and work on data...}
private void helper_RST(){..//access and work on data...}
}
What I need?
What I need is some way to group the methods and reduce the visibility of helper_DEF and helper_IJK within operation_ABC. Here , I named it clearly operation_ or helper_ but the real scenario in my program is....
private void backEndActionTaker(){
<type: private void > initializeMinePlacer();
<type: private void > mineValueAssigner();
}
Readability Problem: Developers who needs to read/extend this code will surely find difficult to segregate operation and helper as everything seems like an operation at one glance.
What I worked? I planned of creating inner classes without any data, but I felt 2 uneasy-things.
class operation_ABC{
exec_ABC(){
helper_1();
helper_2();
}
private helper_1(){......//Access outer class data...}
private helper_2() {.........}
}
- creating a class without any data-member.
- whenever I have to call that operation, I have to create an object and call that.(static inner classes methods willn't work because the helper methods access outer class data.)