News for hackers. Stuff that matters.
Re:Java record pattern matching in JDK 19 by Fellshard on Saturday May 14, 2022 @04:12PM (#31381865)
There are some cases when it's actually simpler or more maintainable or more useful to do the dispatch locally. A language that allows you to both is tougher to learn and can have a higher risk of pitfalls, but also means that a seasoned practitioner can apply the right tool in the right situation.

In terms of the classic 'patterns', it's the difference between standard dispatch and the 'Visitor' pattern. There are cases where you want to specify each case of data structure locally, and others where you want to specify each method of each variant locally. Welcome to the expression problem!

There are cases in Java where you do want a true POJO - just a bag of structured data. This is probably a very strong candidate for using along side that.

There are no comments on this comment yet.