I’m still a beginner in MVC, so I have problems in design.
I have many categories C1, C2, C3. Every category has her special structure. So every category should be presented in a Model Class. I also have for every category its own table in the database, mapped to eachother by Hibernate.
I need in my application, to get the data from an Excel File ( I succeeded the upload and getting data from excel file ). But the excel file should respect the structure of the category chosen in the form. So it means, if I choose in the select of the form C1, then I upload an excel file with a different structure, that file should be rejected…
So how could I design my application to process Excel files according to the indicated category??
Define an
ExcelStructureValidatorinterface, and have all your category classes (C1, C2 and C3) implement anmethod, which return the appropriate validator for the chosen category.
Other designs could be possible, or even better, but without more information about what a category is and how an excel file structure is linked to a category, it’s hard to provide the ideal solution. Some kind of factory for validators based on the category is needed, though. WHether the category should be the factory is debatable.