1

In a calendar app adopting a MVC architecture, the Model consists of objects representing the days of the week.

The View consists of labels displaying the days as strings or integers, depending on the user interaction.

Therefore I need some logic in my app for the mapping from strings to integers, and viceversa. Is this logic, business logic or presentation logic?

As first thought, I decided to include this logic to the View, because the format in which the data is displayed is a View responsibility.

However a second thought came to me, when I realised the mapping describes how data is manipulated and transformed, therefore it should be included in the Model, and not in the View.

asked Jul 1, 2017 at 15:28

1 Answer 1

1

It's presentation logic. Think about the string you are converting it to. What language is it in?

Business logic is the same regardless of language. You just need to know the date.

answered Jul 1, 2017 at 15:34
4
  • Ok. One more question: let's say I want to compute how many days has been since the beginning of the month. Is that business logic instead? Commented Jul 1, 2017 at 16:14
  • are you using it for presentation or is it part of the business logic? Commented Jul 1, 2017 at 16:17
  • From your comment I deduce that it can be both depending where I use it? Commented Jul 1, 2017 at 16:20
  • 1
    yes, anything can potentially be anywhere. for example maybe you have a business rule which says the prices change depending on the first letter of the day of the week. in that case it would be language dependent Commented Jul 1, 2017 at 16:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.