Should I Create A Minimal API Or Full API?

preview_player
Показать описание
When should I use a Minimal API? When should I use a Controller-based API? Is one better than the other? Is there a tipping point where one is better than the other? Should I convert my controller-based APIs into Minimal APIs? We will answer these questions in today's Dev Questions episode.


Рекомендации по теме
Комментарии
Автор

Wow I am literally in the middle of making this decision. Fantastic timing!

rendellgood
Автор

Hi Tim, I love your comments about design patterns. I've been involved in software development for over 25 years and I've seen a lot of code bases. The single biggest issue by far in almost all bad code bases (with no close second) is the overuse of design patterns. Most of the time, code that is heavy with design patterns is nearly impossible to maintain, hard to read, , brittle etc. It is sad that design patterns are still pushed as much as they are, especially when there are often much simpler and robust alternatives. I appreciate you cautionary view, which is, for the most part, sorely missing in our community.

paulgehrman
Автор

I ran tests and also found that minimal API's are faster than MVC as you don't automatically get all the middleware (you have to explicitly opt into them). So I use that for bespoke gateway with YARP for rewriting but endpoint when I need extra logic but then back end services still use MVC as they are more complex and benifit form the structure

RicusNortje
Автор

Your passion and dedication shine through.

acodersjourney
Автор

Thanks a lot for the insight, Tim! This clarifies a lot.

torrvic
Автор

True creativity requires the discipline to harness the chaos of imagination into the simplicity of brilliance

chrisnuk
Автор

thank you a lot for the explaniation!! I used to use design pattern all the time even if it 's simple project, but after this video I guess I will reduce using it

CodeToLive-msjm
Автор

You are answer my internal myself question, really thanks 🎉

monirahmad
Автор

Not sure if you already have a video but I'd like to see a "Should I use Razor Pages or MVC Controller/Views) video. I personally thought you can use both and to use Razor Pages for page-based scenarios but anything too complex then use or refactor to MVC controller/views.

I see a lot of people saying "so glad I changed to Razor Pages and I've never looked back" and "MVC is dead" and I don't understand this.

I've seen projects with a large collection of actions on 1 MVC controller. The view may have a lot of forms embedded on it with an action for each Post request that accepts all different Form Input Models, or the controller returns several different views and may, or may not, share the same view model (usually not a good idea to share view models but maybe there's a technical constraint). In this scenario, Razor Pages sounds like the wrong tool.

MayronDev
Автор

Hi Mr Corey, Many thanks for your great videos that supports the developer community. Please i was wondering what project template in Visual studio is used for the development of minimal api's.

patrickizekor
Автор

I think the real answer here is like what Tim said "it depends on your situation". I think my time in this space has taught me that most people try and denote solutions as "go to" or "old". I think a similar issue has spawned in the API space where developers who are trying to be cutting edge have heard that "Minimal APIs are the go to" and wont even consider looking at controller derived solutions. I think you just need to consider what is best for your solution. Need a micro service or simple API? great use a minimal solution and spin something up really quick. Need something with a little more control? Awesome then spin up a controller based solution and add some unit tests. I think if you can justify your decision, and it makes sense in terms of the business case, both solutions are equally as worthy. I just always try to not consider anything to be black or white, but what is going to work for me/my team.

hyxper
Автор

@IAmTimCorey
I would argue against it in large organizations. I believe in templates more than simplicity. This gives the leverage of getting people onboard easily in an agile teams with turnovers.

AmirHosseinBagheri
Автор

Controllers really aren't necessary anymore as the minimal API can be built out to be as exactly complex as necessary. They're so good.

dasfahrer
Автор

Thanks for the video. Most videos you keep saying it. Avoid the complexity if it is not necessary.

rikudouensof
Автор

hi Tim, love your videos, I’m new to programming and I noticed that with Next.js, Blazor “United” and so on, you don’t need an API anymore, is that a trend? Thanks

ionutb
Автор

Do note that Controller-based API have some overhead that Minimal API does not have. For example Minimal API is missing Content Negotiation. As most (if not all) APIs only communicate in JSON this does not have a big impact and otherwise you'll have to add it manually (haven't figured out how to do this. Filters?). So Minimal APIs are faster.

dennisvandermeer
Автор

Basically... it depends lol :), not disagreeing.

A lot of my formative experience predates MVC and I never really got into it. Most of my work is backend services for data processing, which suit minimal apis well. My impression of MVC, is that its best used with User GUI's with a solid focus on standard CRUD.

blackpaw
Автор

Does minimal api gives better performance vs controller api?

cissemy
Автор

Maybe I'm old school, but I'm very hesitant to pick up minimal API's in most scenario's. I do find that the fully structured API's are much easier to read/debug once they hit a certain size, and lets be honest, how many times does a "Small API" turn into a behemoth in industry?
Perhaps this is just my experience though, curious if anybody else has experienced anything similar...

DannyHodge
Автор

How many types of API's exist, and which ones are the modern ones? And which can be handled by Microsoft Technology?

reynaldoruizflores