BACKGROUND: I am starting to architect a web project using asp.net mvc.
I'm going to use a very common architecture where I have the following layers:
The Service layer interacts with the Biz, Data and Domain layers. The mvc controllers will have the service layer injected into them using a DI framework. The controllers will need to be aware of the Service layer interfaces and will reference the Domain objects (POCOs).
I have been told to keep in mind we need to expose portions of this website to mobile devices. The portions to expose via mobile devices is to be defined :-).
When rendering the site I can simply have a mobile layout that renders to a mobile device. But one thing management told me is mobile users might want additional functionality the website doesn't expose.
Maybe they want to access a feature that only a native mobile application can provide. Hey, I don't make up these requirements, this is what I was told :-).
THOUGHTS: My service layer is the gateway to storing objects in my database.
For any potential native mobile devices I was thinking about using the Web API to wrap my service layer.
What I want to do NOW is focus on on my asp.net mvc application and only worry about native mobile apps when those requirements become more defined.
QUESTION: would it provide any benefits to code the Web API layer now and have my mvc controllers use it?
Pros for creating the Web API now
- It will be coded and ready if / when a native mobile app comes online.
Cons for creating the Web API now
- It is overhead that is not needed, especially if I host the WebAPI in a seperate process or another site besides my original asp.net mvc site.
- The technology is fairly new and enhancemens will be forthcoming. If i wait until later some of the issues will be fixed.
- Who knows, my users may never want a native mobile device and the feature is never utilized.
The code becomes more complex because of having to maintain the web api layer now.
I'm looking at not worrying about the Web API layer for now and simply coding it when necessary.
Typically I don't worry about writing for functionality that is yet to be defined. But I thought it might not hurt to ask, you never know what some brilliant maverick programmer is doing out in the wild :-).