java - Avoid if/else in constructor - NavigableMap? -
I have the following code, depending on input to the constructor I need to start some values which is a simple POJO. These values are continuous, as you can see.
Although I did not like / had read about Naviglame as an alternative to building and maintaining category values .. how to improve / clean down or really use it?
Thanks
Private Calibrated Calibrated Value; Public Calibration Properties (Longtime Audnumer) {Setgellbretted Value (ONM); } Private vide sealtabilited value (long ONNumber) {if (ONNumber <762) {this cubified value = new calibrated (K, H, K, I, V, H, N, F); } And if (odNumber & lt; 866) {this. Cylibrated Values = New Calibrated (K1, H1, K0_INV, H0_INV, F1); } And if (odNumber & lt; 1011) {this. Cylibrated Values = New Calibrated (K2, H2, K2_INV, H2_INV, F2); } Else {this.calibratedValues = new calibrated (K3, H3, K3_INV, H3_INV, F3); } // two exceptions (odNumber == 858) {this. Silified Value = New Calibrated (K2, H2, K2_INV, H2_INV, F2); } If (ONM == 1005) {This sealed value = new calibrated (K3, H3, K3_INV, H3_INV, F3); }} Public Calibrated GetCalibratedValues () {calibratedValues Return; } / ** Convenience category * / static class to be used to capture calibrated values; {Double double] static class; Private double [] h; Private double [] kin; Private double [] hindu; Private Double Ch; Calibrated (double [] k, double [] h, double [] kw, double [] hinn, double f) {this.k = k; This is H = H; this.kinv = kinv; this.hinv = hinv; This.f = f; } Public Double [] getK () {Return k; } Public Double [] getH () {Return h; } If you are not using / else here in the constructor, But you should use more meaningful names, if you read this code after one year then you will not know what they mean - I mean constructor parameters and class properties There is a bigger logic list in your constructor. You can create your class inside some factory methods Examples:,
public static calibrated createSmallCaribration () {Return new calibrated (K0, H0, K0_INV H0_INV, F0); } If you do that you can make your constructor package even visible. And you will know what happens to each constructor configuration,
Comments
Post a Comment