2 ms·
In many (most?) languages chaining leads to longer lines unless programmer makes an extra effor to break them. Compare: user = manager.getUser() mobi
by theamk 4y ago
In many (most?) languages chaining leads to longer lines unless programmer makes an extra effor to break them. Compare:
user = manager.getUser()
mobile = user.getPhone(PhoneType.mobile)
area = mobile.getAreaCode()
vs
area = manager.getUser().getPhone(PhoneType.mobile).getAreaCode()
- hrbf 4y agoGood example and exactly what I meant. Having each call on its own line doesn’t solve anything if you also nest the calls.
- Sohcahtoa82 4y agowhat about... area = manager .getUser() .getPhone(PhoneType.mobile) .getAreaCode(); I see this form a lot in Java and Kotlin code, especially in Kotlin where a single function is just assigned to a chain of functions like the one above.