Ala.... Functional programming (spit).
It's garbage. Reads like garbage and is basically a Functional Programming hack on top of Proceedural dross in an OOP language. The world has gone nuts.
The correct OOP way to do this is to encapsulate functionality with the data it operates on.
in real-world programming, there’s rarely a single "correct" way to do things - especially when it comes to paradigms like OOP, functional, or procedural programming. These are tools, not dogmas, and they often complement each other.
Using predicates or other functional-style constructs in OOP code isn’t a "hack" - it’s just one of many ways to express intent clearly. What really matters is writing simple, readable, and maintainable code. That may sound easy, but it actually is not and takes a lot of experience and maturity. Experienced developers often lean toward simplicity because they’ve seen how complexity costs time and clarity.
On the other hand, newbies can sometimes over-engineer things in the name of "proper OOP" or modern trends, blindly applying patterns or paradigms without fully understanding their purpose - just believing "this is the right way" because it follows some principle they’ve read about.
In the end, good code isn’t about demonstrating theoretical purity - it’s about solving problems cleanly and understandably.
On one hand, you can design an elaborate hierarchy of classes that strictly follow object-oriented principles, but end up with bloated and overly complex code. In such designs, even simple tasks may require navigating deep inheritance chains, applying numerous design patterns, and carefully fitting into a rigid structure.
On the other hand, you can write straightforward procedural code that’s easy to read, easy to test, and easy to modify when requirements change. Sometimes simplicity and clarity bring far more value than architectural perfection.
You may have encountered situations where someone implements a solution that technically works, but the resulting code is so complex and convoluted that it's difficult to understand or maintain. Then someone else comes along and replaces it with a much simpler, more elegant version - something that's clear, readable, and easy to extend.
At first glance, the second solution may appear trivial. But in reality, it often reflects deeper experience. It likely came from someone who has solved similar problems many times before, who took the time to thoroughly analyze the root cause, observe every potential pitfalls during debugging, and refine the solution through multiple iterations - ultimately arriving at a simpler and more maintainable design.