0

If I have an API and I am the one consuming it, should the front-end be a separate project? I'm using Visual Studio ASP.NET Core 1.x.

2 Answers 2

3

An API is an interface first and foremost (and what the "I" in "API" stands for).

In general, it makes sense to have an interface be a separate component to decouple it from the implementation underneath. This also makes it easy to share: you can provide a lean library with only the interface specification, making it easier to use and understand. At runtime, the implementation can be dynamically loaded.

Another benefit is if the implementation is not closely coupled at the module level, it is possible to swap in an alternate implementation. This could be a "mock" and could be useful if, for example, the underlying "real" implementation touches databases or other persistence (or remote) systems that you do not want to mess with during testing.

Do you need to keep the interface separate? No. Is it a good thing? Yes.

1
  • I feel like your answer, while being technically correct in the end, discusses a whole different subject.
    – Andy
    Commented Jan 25, 2017 at 7:04
1

From a "the way Visual Studio does black magic so I could easily shoot myself in the foot" I would have a separate project in my solution at the very least, if not an entirely separate solution to keep things completely clean.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.