Relative Content

Tag Archive for inheritance

Many small classes vs. logical (but) intricate inheritance

I’m wondering what is better in terms of good OOP desing, clean code, flexibility and avoiding code smells in the future. Image situation, where you have a lot of very similar objects you need to represent as classes. These classes are without any specific functionality, just data classes and are different just by name (and context) Example:

Code reuse via inheritance [duplicate]

This question already has answers here: Code Smell: Inheritance Abuse [duplicate] (9 answers) Closed 11 years ago. I have a set of classes that are all dealing with some related tasks. These tasks do have different inputs and outputs. This causes it to become impossible to have the tasks done via shared code without having […]

Should I test inherited methods?

Suppose I have a class Manager derived from a base class Employee, and that Employee has a method getEmail() that is inherited by Manager. Should I test that the behaviour of a manager’s getEmail() method is in fact the same as an employee’s?

How often is Inheritance used?

I admit that I am a junior developer, and so far I’ve only built simple web applications in ASP.NET MVC. But I’ve never had to use the inheritance aspect of Object Oriented Programming in my own classes! It is true that in using ASP.NET MVC I inadvertently use inheritance (any controller I create will inherit from the base controller class), but I am referring here to the conscious use of inheritance in my design of a particular web system.