4 ms·
Personally, in C#, I don't enjoy debugging and maintaining Fluent APIs. An exception thrown in the chain is sometimes opaque and the necessary extension method
by yawgmoth 7y ago
Personally, in C#, I don't enjoy debugging and maintaining Fluent APIs. An exception thrown in the chain is sometimes opaque and the necessary extension methods to make everything come together is not neat code. The former reason is why I also discourage use of object initializers.
- tluyben2 7y agoI like those API's much better for reading, but when there are issues with them, like you say, debugging is often a right pain compared to the other examples. Especially when a chain became a bit too long (over time) and there is suddenly a null somewhere (for whatever reason). VS indicates the error in the first line of the chain and debugging can become quite hairy. Is that better in other language runtimes/debuggers?
- lonelappde 7y agoThe proper place to pay the dev cost is once in the library, not in all its callers.
- GordonS 7y agoIf you want to be more opaque, I guess you could do: ```c# var file = File("source"); file.CopyTo("target"); ``` (apologies if this is formatted badly; no clue what HN supports here, and I'm on mobile)