Does this sounds wrong in design? I am trying to see the most flexible way to handle a template that could get changed over time. For example, with the first version of the application template can have 10 fields. Next version of template can have 15 fields. Issue would not be so much of addition of fields but removal/change of a meaning of field name. The template would be stored as JSON representation. So storing in database with different variations is not a problem. The problem is how best to represent this in OO design principles. Also, in a classical Spring MVC with JSP views what would the best way to handle different variations of stored templates over time?
I was thinking If I store version and Type in database with record(JSON).
To do that in my base interface(Marker like interface) I have 2 methods String getVersion() and getType() would that be wrong considering design principles? If I do this I can query depending the type for any child class when retrieving those objects from database. Imagine the object is stored as flat structure(JSON) in database. For example - > findXTypes() as method. In the method implementation I can find by Type='.tostring()' in the query.
It gets complicated when viewing them .I could do this in controller by @RequestMapping(value = "/myTemplate", method = RequestMethod.GET) public String showRecord(@RequestParam ...) { .... return "myTemplate"+Type + TemplateVersion ; }
Then I would have to introduce a new JSP(View) per version. Not great I know, but otherwise I would have to handle the version in IF statements in the same view, which would be more difficult.
Any good ideas?
Aucun commentaire:
Enregistrer un commentaire