aagerdonsa
New Member
So, I am starting to gasp the concept of abstract and interface in PHP.
But when is it really ever useful?Sure I can with an interface make up the rules for my classes, so they all follow a specific pattern. But when is it really useful? And why should I make an abstract class instead of just making a class that works by it own but is useful for other classes.
Abstract I perhaps can put my head around and see a good use, for example by making a general class. Like making a abstract Database class, then extending it onto a Mysql- and a MsAccess database class. Giving both similar functions to work with, allowing seamless experience in both cases. But really, could anyone give me a better example of when abstract and interface are really useful?
And please note, I do know how it works, or how to write the code, just not how or when to use it.Thanks!
But when is it really ever useful?Sure I can with an interface make up the rules for my classes, so they all follow a specific pattern. But when is it really useful? And why should I make an abstract class instead of just making a class that works by it own but is useful for other classes.
Abstract I perhaps can put my head around and see a good use, for example by making a general class. Like making a abstract Database class, then extending it onto a Mysql- and a MsAccess database class. Giving both similar functions to work with, allowing seamless experience in both cases. But really, could anyone give me a better example of when abstract and interface are really useful?
And please note, I do know how it works, or how to write the code, just not how or when to use it.Thanks!