A humbling reminder of how far I have to go to be even near this guy's level.
A humbling reminder of how far I have to go to be even near this guy's level.
runWithNetworkElement("171.0.2.45", networkElement -> {
for (Route route : networkElement.routingTable()) {
System.out.printf("%15s -> %s%n", route.name(), route.ipaddr());
}
});Sure, Java 8 has lambads, but have their disposed of getters and setters and added some kind of properties?
If not, then the idiomatic way is not name(), it's getName().
(Of course without "unified property access", it's not that much different)
For example, both Google's AutoValue library and the Immutables library show examples of getters that drop the "get" prefix:
https://github.com/google/auto/tree/master/value
One argument against the prefix is that immutable value types don't have setters, so it's not as important to distinguish between them. Another argument is that immutable values aren't really objects in the object-oriented sense, so accessing a field really is just a data access as oppose to an action being performed by the class instance.
(I guess one aspect of Java that makes this less awkward to implement is that methods and fields have independent namespaces, so nothing stops the Route class from having both a "name" field and a "name()" method. That's possible because Java doesn't have first-class functions, so you can always determine from usage whether something is a field or a method.)