Given is the following package/class diagram of an implementation of java.util.List:
1. Which design principle is (most likely) hurt by the ArrayBasedList class?
In my opinion, the design principle that is hurt by the ArrayBasedList
class is the “Use inheritance as a Specialization” because the ArrayBasedList
is not (extends) only an Array (ArrayUtilites) but it has (implements) the methods from List
and ArrayUtilites
as well.
2. What would be the preferred way to model this situation in a correct way (as UML)?
The preferred way to model this situation in a correct way using UML will be to make the ArrayBasedList
implement the List
and the ArrayUtilites
interfaces. (Link unrelated classes with has a capabilities.)
My solution was based on How should I have explained the difference between an Interface and an Abstract class?
What do you think about my approach?