Is there anything wrong with the below code? It is java codes, but somehow it looked like a C program to me. If there is something incorrect with the OO implementation, can you tell me the name of the violation? looking at S.O.L.I.D or CodeSmell but I still have no idea why the below codes looked weird to me.
public void root() {
BufferedWriter bw=new BufferedWriter ()
writeHTMLHeader(bw);
writeBody(bw);
}
public void writeHTMLHeader(BufferedWriter bw) {
bw.write("<html><head>");
...
bw.write("</head>");
}
public void writeBody(BufferedWriter bw) {
bw.write("<body>");
...
//pull some information
writeMenu(br);
...
bw.write("</body></html>");
}
public void writeMenu(BufferedWriter bw) {
Integer count=0;
writeSubMenu(bw, count);
bw.write("Some other menu items");
}
public void writeSubMenu(BufferedWriter bw, Integer count) {
bw.write("Some submenu items");
count=count+1;
}
so it is OK to pass bw and other variables (and changing them) while passing down the chain of methods call?