tags:

views:

273

answers:

1

Just a quick question. I understand that Singleton patterns can be extended and that inheritance is applied. I was just wondering if I called a base class and then a extended class is there additional overhead than if I just called the extended class by itself?

A: 

If what you're talking about is something like

class BaseSingleton {
    public function DoSomething() {
    }
}

class ExtendedSingleton extends BaseSingleton {
    public function DoSomething() {
        parent::DoSomething();
    }
}

then yes, there is overhead in the call being forwarded from the child class's DoSomething() to the parent class's. If ExtendedSingleton does not redefine DoSomething(), though, there is no additional overhead.

chaos
You mean the line "public function DoSomething() {parent::DoSomething();}" is redefining the DoSomething() function in the BaseSingleton class?
EddyR
Right.
chaos