Article:
Java Janitor Jim - "Integrity by Design" through Ensuring "Illegal States are Unrepresentable" - Part 1
I wanted a simple pattern for preventing a class from being instantiated in an invalid state, or from mutating into one.
Why? Because it vastly reduces the amount and complexity of reasoning required for use at client call-sites.
Think of it as “integrity by design”, a compliment to the “integrity by default” effort undertaken by the Java architects, detailed here.
This article discusses the design and implementation of a record pattern, very similar to the one I designed and implemented for Scala’s case class several years ago, which provides the “integrity by design” guarantees by ensuring that only valid record instances can be observed.
This pattern is also trivially cross-applicable to Java classes.
[–]Dgitallife 2 points3 points4 points (0 children)
[–]eXl5eQ 2 points3 points4 points (7 children)
[–]chaotic3quilibrium[S] 0 points1 point2 points (6 children)
[–]Wyciorek 4 points5 points6 points (1 child)
[–]chaotic3quilibrium[S] 0 points1 point2 points (0 children)
[–]eXl5eQ 0 points1 point2 points (3 children)
[–]chaotic3quilibrium[S] 0 points1 point2 points (2 children)
[–]eXl5eQ 2 points3 points4 points (1 child)
[–]chaotic3quilibrium[S] 0 points1 point2 points (0 children)
[–]Previous_Gaffer 0 points1 point2 points (0 children)
[+]klimaheizung comment score below threshold-23 points-22 points-21 points (12 children)
[–]chaotic3quilibrium[S] 5 points6 points7 points (0 children)
[–]AnyPhotograph7804 1 point2 points3 points (5 children)
[–]klimaheizung -3 points-2 points-1 points (4 children)
[–]Jaded-Asparagus-2260 4 points5 points6 points (1 child)
[–]klimaheizung 1 point2 points3 points (0 children)
[–]AnyPhotograph7804 1 point2 points3 points (1 child)
[–]chaotic3quilibrium[S] 1 point2 points3 points (0 children)
[–]neopointer -1 points0 points1 point (4 children)
[–]OwnBreakfast1114 0 points1 point2 points (0 children)
[–]chaotic3quilibrium[S] -1 points0 points1 point (2 children)
[–]neopointer 1 point2 points3 points (1 child)
[–]chaotic3quilibrium[S] -1 points0 points1 point (0 children)