Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding interfaces that won't be actually used

Tags:

java

c#

oop

I currently have two interfaces(that I'll name here IA and IB):

interface IA {
    int Width;
    int Height;
    ...
}

interface IB {
    int Width;
    int Height;
    ...
}

that share the same two properties: they both have a Width and a Height property.

I was thinking if there is any point in defining an IMatrix interface containing a Width and Height properties:

interface IMatrix {
    int Width;
    int Height;
}

The thing is that although they share both the same properties, I won't make use of polymorphism with IMatrix in any of my coding: i.e., there won't by any situation where I'll want to use an IMatrix, I'll just want to use IA and IB. Adding an IMatrix seems more like over-engineering than other thing, but I'd like to ask you guys what your opinion is on the matter.

Thanks

like image 444
devoured elysium Avatar asked Feb 17 '26 06:02

devoured elysium


1 Answers

If you will not be using it specifically, then I would say there is no need for you to be adding it.

like image 78
Mitchel Sellers Avatar answered Feb 19 '26 18:02

Mitchel Sellers