We have an engineer on our team that would like to the do the following inside of JSON data:
"visible": "$(= state 'state_c')"
Now in the model he has the following method to determine the state:
protected function getCurrentState():String
{
var state:String = "defaultState";
if (xxxx)
state = "state_A";
else if (xxxx)
state = "state_B";
else if (xxxx)
state = "state_C";
else
state = "state_D";
return state;
}
Now elsewhere whenever I need to update the state I would call the following:
data.state = getCurrentState();
The notation used in JSON data is in prefix notation (LISP) in case you were curious. The code where the model exists is written in AS3 and the object named 'data' above is that of type Object.
I am against this idea and I don't understand the value of putting logic into data. I have never seen a paradigm that would be used this way. I think this breaks the MVC architecture design and introduces many different problems. Here are my biggest issues with this design:
1) All the logic is type unsafe (data is type-unsafe)
2) Now the developer must know how to do three separate things to complete a task (write the programmer portion of the JSON data, write the correct prefix notation, and put correct logic in code)
3) I don't see a good way to unit test this behavior
4) Spreads logic into multiple areas of code and thus will make finding an error more difficult.
I am looking for any opinions on this matter. Why would this be a good idea? Are my reasons for disliking it valid? Is there some value I am missing?