Comments on: Protect Your Immutable Object Invariants in More Complex Java Objects https://speedment.com/protect-your-immutable-object-invariants-in-more-complex-java-objects/ Build Fast Java Applications for the Fastest Business Performance Fri, 01 May 2020 05:21:37 +0000 hourly 1 https://wordpress.org/?v=5.1.1 By: Stas https://speedment.com/protect-your-immutable-object-invariants-in-more-complex-java-objects/#comment-120 Wed, 04 May 2016 11:06:02 +0000 https://speedment.com/protect-your-immutable-object-invariants-in-more-complex-java-objects/#comment-120 I don't think this is an ideal design to return a List but make it unmodifiable under the covers. You are effectively misinforming a user of that object about its return types, as there's nothing on your class that would warn a user that the returned list is read-only and is out of bounds.

Wouldn't it be much simpler and clearer to change List<String> getWorks() to Iterable<String> getWorks()?

]]>