This is a language-agnostic question, more about object-oriented design and how to organize interfaces. Let’s consider we have an abstraction called Font. We have a bunch of classes that extend/implement this abstraction. The instances of these classes can return their size and line height in different units of measurement (pixels, points). In order not to overcomplicate the question let's omit the part with setting these values. Also, let’s suppose that the requirements can be changed at any moment and we will have to add some new units of measurement (picas, inches, etc).
The question is - what would you prefer?
An interface with multiple non-parameterized get methods, e.g.
getSizeInPixels()
getSizeInPoints()
getSizeInPicas()
getLineHeightInPixels()
getLineHeightInPoints()
getLineHeightInPicas()
Or would you prefer the interface with only few parameterized get methods?
getSize(String unit)
getLineHeight(String unit)
Which of these approaches is better and why? Which of them looks more flexible and resilient to changes? What are the pros and cons of each in your opinion? Thanks in advance.