If you find some methods whose definitions are more or less similar, only different by the method name, it may use meta programming to simplify the things to make your model more clean and DRY.
If you find some methods whose definitions are more or less similar, only different by the method name, it may use meta programming to simplify the things to make your model more clean and DRY.
Consider this simple example where we have an article with three states.
Before
Now this code can be written as:
After
This makes your code drier and cleaner. And adding more states makes it easier to modify.