I’m trying to understand the practical importance of abstract classes in object-oriented programming, particularly in PHP.
From my understanding, abstract classes enforce child classes to implement specific abstract methods, which ensures some consistency. However, I feel like we could achieve the same functionality using method overriding.
For example, by simply overriding methods in the child classes, I could customize the behavior for each class without needing to enforce anything through abstract methods. This would result in slightly more code but would allow greater flexibility.
So,
Q1. what’s the unique purpose of abstract classes that can’t be achieved with just method overriding?
Q2. Why is it important for abstract classes to enforce abstract methods in child classes?
Q3. Is this enforcing thing is for developer who is developing the app or its enforcing some restriction on end user so that user wont be able to do his/her wishful thing like adding some user in some other category (which is restricted by our hard code)while giving access control to existing user where everything is handled dynamically?
If someone could explain this with a practical example or use case, that would help me understand better.