I’m developing for several months an application and every now and then I think about design patterns.
Let’s imagine you have an (web) application with several tabs. In each sheet you give the user some fields and tables to fill up or alter. There is a global save button which saves all sheets content. First of all you have to validate the field values before you are allowed to save. Also if there happens something while persisting your objects you have to stop your transaction and the saving of all sheets.
I’ve implemented something by myself with a logic handler class and for each tab sheet a sheet logic class. The logic hander controlls the sheet logic classes. After the save button click the logic handler invokes for every sheet logic it’s screenToData method which returns the objects to be saved. When loading the sheets the dataToScreen method is invoked.
Also I want to mention that the sheet logics have a separate class which handles the UI with its components. As you can see, logics are separated from UI handlers.
The scenario with tab sheets and separating UI handlers from logic is very common in my opinion. So I’m wondering if there are Java frameworks or design patterns which support you in developing such situations. The MVC design pattern is good for separating UI and logic but I’m looking for the saving / filling up scenario or the combination of it. What is here the state of the art?
I’m developing with Java and using vaadin, what is not that important.
You dont need to have a design pattern for every issue (KISS principle). I think the approach first checking all tabs with a validation method for correctness and then save them inside a transaction is adequate.