I have written a new shiny Todo service with my favorite front-end and back-end framework. To minimize coupling I return data in some standard format like JSON or Protobuf and leave it up to the client to interpret and display it in a way it feels suitable.
The user can select multiple items which on selection should show different UI as compared to normal item, it can be done by adding selected
field to the objects as soon as I receive them on the client, setting them initially to false. But later I would need to sync the application state with the server and I wouldn't want to send the original data with the selected
attribute hence before sending it back to server I must remove the selected
attribute from the objects.
Since, javascript
in my current choice for dealing with front-end code so, it seems pretty trivial to add or remove fields on the fly. But suppose I need to add 10 more states to my front-end then I need to do Augment my original Model again and again.
I need to know is this the correct approach to deal with such a situation?