I am writing a class in java of Monte-Carlo algorithm. Here is the written code -
public class MonteCarlo {
int[][] matrix;
public void monteCarlo(List<Node> nodeList) {
matrix = new int[nodeList.size()][nodeList.size()];
}
private void initMatrix(List<Node> list, int[][] matrix) {
}
}
In here initMatrix method i am passing two parameter. But the matrix array is globally declared. I personally sometime found that is helpful to keep track which method is responsible for what. But is it a bad coding practice to pass a variable parameter even it is declared in globally.
Aucun commentaire:
Enregistrer un commentaire