I tend to disagree with most others on this list. I actually find the first way cleaner and easier to read.
In your example:
//like Set<String> jobParamKeySet = jobParams.keySet(); Iterator<String> jobParamItrtr = jobParamKeySet.iterator(); Could be also written as //dislike Iterator<String> jobParamItrtr = jobParams.keySet().iterator();
the first method (the one you like) contains a lot of irrelevant information. For example, the whole point of an iterator interface is to give you a standard interface that you can use to loop through any supporting implementation. Thus, the fact that this is a key does not affect the code itself. All you need is an iterator to iterate over the implemented object.
Secondly, the second implementation actually gives you more information. It tells you that the code will ignore the implementation of jobParams and that it will only iterate over the keys. In the first code, you must first track that jobParamKeySet (as a variable) to find out what you are repeating. Also, you don't know if / where jobParamKeySet is used elsewhere in the area.
Finally, as a last comment, the second method makes it easy to switch implementations, if necessary; in the first case, you may need to transcode two lines (the first assignment to a variable if it changes from a set to something else), while in the second case you only need to change one line.
Thus, there are all limitations. A chain of 10 calls on the same line can be difficult to read and debug. However, 3 or 4 levels are usually clear. Sometimes, especially if an intermediate variable is required several times, it makes sense to declare it explicitly.
In your second example:
Actually, itβs hard for me to understand which parameters are processed by Bar.processParameter(param) . It will take me more time to map param to the variable instance to see that it is Foo.getParameter() . In the first case, the information is very clear and very well presented - you process the parameters Foo.getParameter() . Personally, I think the first method is less error prone - it is unlikely that you accidentally use Foo2.getParamter() when it is within the same call, rather than a separate line.