OOP: Is it bad practice to have abstract classes that contain properties that are not needed by subclasses?

Say you have an abstract ClassA that has 3 properties: Prop1, Prop2, and Prop3. These aren't abstract properties, just regular.

Now say you have two or more classes that inherit from ClassA but only say two of the subclasses actually use Prop3.

Is this bad design? Or is this the point of having it as abstract? Would it be better to create an interface with a contract of get/set on the three properties and then throw a NotImplementedException (or whatever the language equivalent is) from the class that doesn't use Prop3?

submitted by /u/goooobasaur
[link] [comments]

from Software Development – methodologies, techniques, and tools. Covering Agile, RUP, Waterfall + more! http://bit.ly/2Su0yS3

Leave a comment

Design a site like this with WordPress.com
Get started
search previous next tag category expand menu location phone mail time cart zoom edit close