Is using double class inherit can be dangerous?

I am using this kind of model:

  • class A extends class B
  • class C extends class A

example as short piece of my code:

class InterfaceController extends AbstractActionController
{
    public function getRole() {
        $userLogin = $this->getAuthService()->getIdentity();
        if ($userLogin != null && $userLogin != "")
        {
            $userData = $this->getUsersLoginTable()->getUserByLogin($userLogin);
            if ($userData) 
            {
                $role = $userData->user_Permissions;
            }
            else
            {
                $role = null;
            }
        }
        return $this->role;
    }    
}

class PostsController extends InterfaceController
{
    public function postsMainViewAction() {
       $layout = $this->layout();
       $layout->setTemplate('mainSite/layout');
       $view = new ViewModel();
       $view->setTemplate('Posts/posts/index');
       return array(
           'role' => $this->getRole()
       );
    }
}

Example is based on Zend Framework 2 application My question however is still more general about OOP model

Question is as follows: "Can this use of extend classes negative influence to application performance ?"

Answers


The weakest spot in the example you give is that you don't show any methods (at the time I answered the question). Without any methods given, we can only say that it is superfluous.

If you wouldn't regard superfluous as a problem, then there is no problem.

As there ain't no logic involved as well, the logic can not be flawed by that inheritance you describe.

Hope this helps. In other cases, e.g. if your classes actually have methods, look for:

  • Composition over Inheritance
  • Liskov Substitution Principle

Need Your Help

Grails/Groovy taglib handling parsing dynamically inserted tags

grails groovy

Is there a way to have a custom taglib operate on data loaded in a .gsp file such that it picks up any tags embedded in the data stored in the database. For instance, let's say I'm doing:

iOS6, UIWebView and position:fixed

cordova ios6

We have a PhoneGap application that has navigation bar and tab bar "implemented" as divs with fixed position (see screen 1).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.