Lets's say I have a backend web API. It takes in a web request and returns some json. Other services then consume that json and do what they will with it.
My question is twofold:
1) Does this backend web API technically have a view (v in MVC)?
My thinking is no, since it doesn't actually display any frontend to the user.
2) Does the JSON object returned represent a model (m in MVC)?
Thanks!
1) Does this backend web API technically have a view (v in MVC)? My thinking is no, since it doesn't actually display any frontend to the user.
You are correct, it doesn't really have a View.
The Web API itself is simply going to return some data that was requested or something to indicate to the user that a request was performed properly (e.g. a JSON-formatted object indicating that a user was created, a collection of user objects, etc.)
Although a front-end could call the API and then use that information to render something, the Web API on it's own isn't going to do anything like that.
2) Does the JSON object returned represent a model (m in MVC)?
It can.
Each component of the MVC pattern plays an important role :
In this case, when you hit your Controller, you will likely be accessing some type of data and building a model. This model might use some business logic that you have designed yourself, or it might simply be content that was returned from your data layer, either way, the model, regardless of how it was created merely represents some type of data.
The "Model" is this case can be any type of data that you might decide to pass along to a View. Regardless of how it is serialized, if it is consumable either by a View or some other mechanism, you can think of it as a model.