Multiple variable declared on the same line
67 // todo: para gönder
68 public static boolean transfer(String id, String IBAN, double amount) {
69 // todo: kullanici kendi ibanina transfer para
70 double depositSender, depositReceiver; 71 String temp = SqlQuery.StringGetSQL("SELECT deposit FROM clients WHERE id=" + id, "deposit");
72 depositSender = stringToDouble(temp);
73 depositSender = depositSender - amount;
Multiple variable declared on the same line
96
97 // todo: borç öde
98 public static boolean payOffDebt(String id, double amount) {
99 double deposit, debt;100 String temp = SqlQuery.StringGetSQL("SELECT debt FROM clients WHERE id=" + id, "debt");
101 debt = stringToDouble(temp);
102 temp = SqlQuery.StringGetSQL("SELECT deposit FROM clients WHERE id=" + id, "deposit");
Description
Multiple variables (or fields) should not be declared on the same line.
Declaring more than one variables (or fields) on the same line makes the code harder to read. Things might get more confusing if some of those variables are initiliazed and some of them are not.
Bad Practice
class Klass {
private int a, b = 20;
private void method() {
double d1, d2 = 3.5, d3;
// ... rest of the code
}
}
Recommended
Consider declaring one variable per line.
class Klass {
private int a;
private int b = 20;
private void method() {
double d1;
double d2 = 3.5;
double d3;
// ... rest of the code
}
}