Open Marfir opened 1 year ago
Processing speed.
Yes, you can also speed up your code writing with collections and streams.
I get the point by @Marfir. Arrays need additional care. And the getter of course expose the array for modifications. On the other hand I definitely do not want to add boxing/unboxing of those long/double values. And the charting library works with arrays as well - therefore I just pass them on.
(and maybe as a side remark: the code is > 11 years old. There are so many places where I think "gosh, was I drinking at the time?!?" 🤣 but I am practicing acceptance and try to balance time on features vs. refactoring. I try to do the same with the Java 17 upgrade - there are many place that could benefit from new language features, but I apply them as I touch files).
Yes. Sonar mostly mark lines that contains arrays because it's unsecured. It's also not improving the performance if you need to change manually the size of an array again and again.
I'm using jFreeChart in my project as long as I remember: https://www.jfree.org/jfreechart/samples.html With it you are not forced to using arrays. Yes I know this problem with huge old code base. My astronomy project has currently ~113k LoC (Java). It's only possible to using the 'boy-scout rule' to handle it.
The project heavily using old school Java arrays instead of collections. Collections available since Java 1.2 and the common save way. The code will be get an huge improvement. Then it's possible to using streams and also a lot of code checks (to avoid e.g. IndexOutOfBoundsException) can be removed.
e.g. see class PerformanceIndex