Re: Interfaces?
Posted: Thu May 22, 2008 10:26 pm
I'd say, for interfaces...
class Bee implements live_being, flying_being {
It's a live_being, and it HAS to breath, feed and reproduce.
It's a flying_being, so it also HAS to fly.
But not all live beings breath the same way, feed the same and reproduce the same way.
And not all flying_beings fly the same way, but they do fly.
So the Bee has to breath, feed and reproduce, as well as fly, but it does it in its own way.
}
It's good if you want multiple of the same thing, like different Template Parsers or different Database Abstractors. All have to do the same things, but they can do it the same way. If I knew of interfaces, a framework I was planning to do a long time ago would benefit a lot from it, as I had to explicitly say you could create your own drivers, but they had to have the same function names as the original ones, to keep compatibility with other apps relying on them.
class Bee implements live_being, flying_being {
It's a live_being, and it HAS to breath, feed and reproduce.
It's a flying_being, so it also HAS to fly.
But not all live beings breath the same way, feed the same and reproduce the same way.
And not all flying_beings fly the same way, but they do fly.
So the Bee has to breath, feed and reproduce, as well as fly, but it does it in its own way.
}
It's good if you want multiple of the same thing, like different Template Parsers or different Database Abstractors. All have to do the same things, but they can do it the same way. If I knew of interfaces, a framework I was planning to do a long time ago would benefit a lot from it, as I had to explicitly say you could create your own drivers, but they had to have the same function names as the original ones, to keep compatibility with other apps relying on them.