Home / Companies / Contentful / Blog / Post Details
Content Deep Dive

Taming verbosity in the Java CMA SDK 2.0: Method chaining and fluent interfaces

Blog post from Contentful

Post Details
Company
Date Published
Author
Mario Bodemann
Word Count
1,082
Language
English
Hacker News Points
-
Summary

The Contentful Java SDK has been released, featuring a new method chaining feature that simplifies code readability and reduces verbosity. Method chaining allows developers to chain multiple setter methods together, making the code more concise and easier to read. This approach is particularly useful when dealing with complex resource structures or cascading settings. However, it's essential to use chaining with care, as overusing it can lead to confusing code. The Contentful Java SDK recommends adopting this paradigm where it makes sense, while keeping changes of return types in fluent interfaces to a minimum. By using method chaining effectively, developers can build better digital experiences with Contentful.