Revisiting Design Patterns after 20 by Edson Yanaga

Discover how to effectively use design patterns in Java 20, featuring strategies for improving code reusability, reducing complexity, and eliminating if-statements, in this talk by Edson Yanaga.

Key takeaways
  • Favor existing interfaces and functions over creating new ones.
  • Implement visitors by using function references instead of inheritance.
  • Compose methods instead of using inheritance for multiple behaviors.
  • Improve code by reducing the number of abstractions.
  • Design patterns can be misused if not applied correctly.
  • Create a specification and then use it to decide what code to execute.
  • Eliminate if-statements by using pattern matching.
  • Use strategy pattern to separate algorithms from their data structures.
  • Create a visitor pattern by using function references instead of inheritance.
  • Use records to simplify code and reduce the number of classes.
  • Test if the user has enabled notifications and then implement the notifications.
  • Design patterns can help developers create reusable code.
  • Java 20 provides features such as pattern matching and sealed classes.
  • Implement search queries using a specification.
  • Create a visitor pattern to traverse a tree structure.
  • Reduce the number of classes by using inheritance and polymorphism.
  • Use a specification to implement different behaviors.
  • Create a visitor pattern to implement complex algorithms.
  • Favor function composition over inheritance.
  • Reduce the number of abstractions by using interfaces.
  • Use pattern matching to reduce if-statements.
  • Design patterns can help developers create efficient and reusable code.