Aspx page.
many fields in the form
we are representing all the fields in a JS object.
we are only changing the status of the record in the UI to “0”. ( in the ui)
we need to save the new status in DB.
question :
should we
1) populate all the fields to the objects , send the whole object to server via ajax and walkthrough his fields in the server to see which has changed ?
or
2) generate a special command for changing status only , and send the command with ajax to the server ?
the first one is more OOP’ed but I dont find any logic at sending all the fields to the server – just to change the status…
p.s.
this is coming from an argue between me and a colleague
I suggested the second one. he , the first one
If you think of it from a CQS/CQRS perspective (command query separation / command query responsibility segregation), you’d go for the second approach (your approach) because what you’re describing is a specific command that you’re issuing and handling in your code. Your command that you’re sending up contains all the information needed to tell your system to do something (imperative tone). This way, you have code performing single responsibilities, which leads to more readable and more maintainable code.
I’d side with you in your argument.
Good luck!