1

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:

  1. Internationalization – We don’t do this now, but we consider if we could implement this in future
  2. Performance – String comparison is vastly less efficient than basic type comparison if values
  3. Size – Strings take up more space in messages than integers
  4. 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.
8
  • Where is the relationship between the statuses and their ints stored? On the DB, the client side or both?
    – Robbie Dee
    Commented Oct 1, 2015 at 11:47
  • The status is recorded as the word "PAID" on the database, server is php based so apparently that's a normal everyday thing (?)
    – Graeme
    Commented Oct 1, 2015 at 13:21
  • So where would you plan on introducing such an int?
    – Robbie Dee
    Commented Oct 1, 2015 at 13:41
  • I would change the makeup of the database. But, my concern is that at the level of transport, a String is being sent which is assumed to be directly output as part of the UI.
    – Graeme
    Commented Oct 1, 2015 at 13:43
  • 1
    OK, but you do realise that as part of this there would be effort to send the lookup data separately for consumption client-side?
    – Robbie Dee
    Commented Oct 1, 2015 at 13:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.