Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

13
  • 6
    Another alternative is that since the ProcessingType options are known statically. You could just define a rest endpoint for each (e.g. @Mapping("/operation/confabulation"), etc.). Commented Oct 8, 2021 at 19:57
  • 1
    I may be wrong but doesn’t this look a lot like simulating polymorphism? Commented Oct 9, 2021 at 7:29
  • 3
    In programming, half of everyone will tell you something is an antipattern, while the other half will claim the same thing is not an antipattern. Write code that makes sense to you, or if you're working on a team, write code that's easily readable and changable by everyone. There are no hard rules. Antipatterns don't actually exist. (Now of course, someone is going to reply that they do exist, which would exemplify my point perfectly.) Commented Oct 10, 2021 at 20:16
  • 14
    So basically you bulletproof your argument by saying that everything that contradicts you just proves you right. I bet that's a way to win lots of discussions. Commented Oct 10, 2021 at 21:10
  • 1
    @chepner: we have method references since Java 8 as well. And I don't see any reason they wouldn't work here. IMHO this code violates OCP (open closed principle), because the class is not open for extension without modification. A method reference / function pointer would fit nicely, IMHO. Using the enum will result in violation of DRY (don't repeat yourself) sooner or later, since you implement the same if/else in some other place. Commented Oct 11, 2021 at 14:26