But that’s functionally no different than what’s already there…
The reason the lines are so long isn’t because of anything Java related, it’s because of the field names themselves.
But that’s functionally no different than what’s already there…
The reason the lines are so long isn’t because of anything Java related, it’s because of the field names themselves.
That is an interesting point, but it’s not Java specific, you could do this exact thing in most other languages and it would look pretty much the same.
Considering the fact that in a lot of enterprise projects the data structures are not necessarily open to change, how would you prevent reaching through objects like this?
This just tells me you don’t use Java. Factory classes are just used to create objects in a standardized way, but this code isn’t creating anything, it’s just getting nested fields from already instantiated objects.
Sure, but most of the lines in the screenshot break down to:
object1.setA(object2.getX().getY().getZ().getI().getJ().getK().getE().getF(i).getG().toString())
Aside from creating a method inside the class (which you should probably do here in Java too) how would another language do this in a cleaner way?
I don’t know if I’d go that far. If you’re talking about a quick script then sure, whatever gets the job done. But for any actual project the use of good, consistent typing does a lot for readability and future-proofing. And in strongly-typed languages it can have a notable affect on the overall functionality too.
If you can’t tell from context whether something is a float or if it’ll overflow the int max then you probably need to re-think the entire method.
RedHat, CentOS, Debian, Ubuntu.
All are good choices.