I'm working on an ASP.NET Webforms project, using the MVP Pattern (which the presenters as you may know use a Page Controller pattern). I'm given a rather complex inheritance chain for my controllers. Below I depict a small example of the structure I'm facing (it is way bigger structure in my app):
A lot of code among these controllers is duplicated (i.e. creating cookies in RegisterPageController and LoginPageController, access Customer data in ProfilePage and BuyProductPage...), so I decided to systematically apply Template pattern and create an inheritance structure that would allow me to reuse as much of the code as possible (i.e. Creating an AuthenticatedPageController that checks that the user is authenticated and then BuyProductPage and ProfilePageController inherits from this class, reusing the authentication part of the code).
However, as I progress refactoring my code and apply more Template pattern, the inheritance chain starts to become more and more complex, and sometimes trying to create a new hierarchy among all my other classes becomes too tedious.
I was wondering if there was a better approach to tackle my issues. I've been reading about composition (I read this post Alternative to "inheritance versus composition?") but I'm not sure about how to implement it nor if this would be the best approach for my case.
Can anyone enlighten me?