For homework, I need to build a small java application.The main goal is to learn how to interact with XML. But a second goal is to learn how to build such an application.
I have quite some experience on programming, but little experience in designing programs. I've read about designpatterns and designprinciples like Solid and TDD. But I find it hard to know how to implement such ideas.
One problem I encounter is segregation between the GUI and the application. On the app, we want to be able to sort on different criteria. For each criteria, there would be a button (like the header of a list). This would then cause an event to be triggered. But how should I pass on what criteria should be sorted, and how would a send back the sorted data?
One could define a different event for each button, but then you would have several similar events with the only goal to differentiate between the sorting criteria.
Another approach would be to define one event, and then pass a string or int, which would specify on what criteria should be sorted, but then you would get a list of if else statements, and would not adhere to the open closed principle.
How would you design such a system.
Edit:
My biggest concern here is trying to get this 'open-closed'. As someone asked, the data is a collection of objects. Is there some way it's easy to add criteria to sort on? Or is this not really feasible to achieve?