I think there isn't a large enough degree of separation between Business Logic, Data and Presentation in some of our products. I'm trying to explain this to collegues but I'm finding it difficult as I can't think of any examples or links which back up my feelings about specific instances which I think break MVC.
Our (versioned) API returns data like so GET - "api/v1.5/product?id=4":
"status": "PAID",
"category": "FISH",
"categoryImage": "www.site.com/images/fish.png"
The status field is, as you would expect, stateful and can contain "UNPAID", "PAID", "DELAYED".
Some of the UI developers are directly outputting this field to the UI but my experience tells me this field should be bringing back an representation of these fields, the UI should interpret these states and act accordingly.
Am I wrong? Does anyone have any resources I can read through or use as examples as to why data should be interpreted where possible?
Some of my reasoning for using an integer flag over a display String is as follows:
- Internationalization – We don’t do this now, but we consider if we could implement this in future
- Performance – String comparison is vastly less efficient than basic type comparison if values
- Size – Strings take up more space in messages than integers
- Data / Logic / UI divide etc – Divides between Logic, Data and Presentation should be reinforced where possible. Having a String “PAID” for a status may mean “paid” right now but this could change in future - the data would stay the same but it's meaning might change at the UI.