I am currently writing a program which is having a lot of code duplication between the GUI aspect and the data storage aspect, and I was wondering if my proposed solution follows acceptable design principles.
Basically, I have some Data objects, which have a List holding some more information. Then the GUI displays the object, and a JList which displays all the information in the Data object's List. In the GUI, users can add or remove information to the object's list, and this is visually reflected in the JList.
However, this results in me having to maintain the GUI JList and the object List separately:
private void addInformation(String s) {
this.listmodel.addElement(s);
this.dataObject.getList().add(s);
}
(Obviously that is a very simple example but you get the idea). It also means that I'm using up twice as much memory holding both lists. Would it be acceptable for me to create a class which implemented both the ListModel and the List interfaces and then only need to update the single combined list/listmodel? I'm still studying at uni and I want to make this project the best I possibly can in terms of maintainability by others and adherence to best practices.