It is frequently said of Java that errors which are runtime errors in other languages are compile errors in Java.
The system of using strings rather than objects completely subverts that very large advantage of Java.
It requires a lot of unnecessary code to test whether the string is a legitimate one. It requires a lot of unnecessary if then else code or search loops, rather than using polymorphism, to select the correct action.
I cannot see where code like:
sites = getSites("farm");
is easier to manage than:
sites = getSites(SiteType.FARM);
The point is that the second one will not compile if SiteType.FARM doesn't exist or if it is incorrectly typed. The first will, if for example "ffarm" is typed by accident. So then I
have to write code to check to see if that has happened. This I will not do.
I did not suggest that the econ model should be restructured correctly (though, in the long run it would be a good idea), only that the interface to other models should use the robust system.
Having been involved in a system with 12,000 classes the prospect of 50 specials doesn't worry me if it makes the code more reliable and decreases the debugging load.
I am not really interested in "selling" anyone on good coding practices, I just refuse to use bad ones myself.
Cheers
The system of using strings rather than objects completely subverts that very large advantage of Java.
It requires a lot of unnecessary code to test whether the string is a legitimate one. It requires a lot of unnecessary if then else code or search loops, rather than using polymorphism, to select the correct action.
I cannot see where code like:
sites = getSites("farm");
is easier to manage than:
sites = getSites(SiteType.FARM);
The point is that the second one will not compile if SiteType.FARM doesn't exist or if it is incorrectly typed. The first will, if for example "ffarm" is typed by accident. So then I
have to write code to check to see if that has happened. This I will not do.
I did not suggest that the econ model should be restructured correctly (though, in the long run it would be a good idea), only that the interface to other models should use the robust system.
Having been involved in a system with 12,000 classes the prospect of 50 specials doesn't worry me if it makes the code more reliable and decreases the debugging load.
I am not really interested in "selling" anyone on good coding practices, I just refuse to use bad ones myself.
Cheers
Comment