I was hoping for some advice:
I need to design a software solution for a medium-sized java / Swing application.
The application will have about 200 use cases requiring complex data validation and business logic.
Typically, this is my usual design:
- Create a simple POJO for each use case, with a custom constructor and custom validation and business logic within it's execute method. These Operations implment simple and complex data validation such as required fields, unique names and more complex constraints.
- Create a single controller that has a method for every use case. Each method takes custom parameters, constructs and executes it's related operation.
- For the sake of simplicity, I won't mention details about Data Model notification or Operation queuing mechanism.
This solution has worked will in the past because it encourages all developers to reuse existing controller methods and validation, however:
The new application will use dialogs extensively for data entry;
These dialogs are expected to implement the same complex data validation and business logic that the controller implements, however the dialogs are not expected to update the data model until the OK button is clicked.
I hate the idea of writing multiple versions of the same complex validation and business logic, due to the maintenance nightmare it invites.
How can I perform complex business logic and validation for both standard data model changes and "pending" dialog changes, given that the dialog doesn't commit it's changes until the OK button is clicked?
The data model may be quite large, so creating an in-memory clone of it and the controller doesn't seem viable.
Does anyone have any suggestions? If so, I'll be forever in your debt.