No video

Should I Create A Minimal API Or Full API?

  Рет қаралды 35,285

IAmTimCorey

IAmTimCorey

Күн бұрын

Пікірлер: 55
@paulgehrman
@paulgehrman 8 ай бұрын
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.
@IAmTimCorey
@IAmTimCorey 8 ай бұрын
Thanks for sharing!
@rendellgood
@rendellgood Жыл бұрын
Wow I am literally in the middle of making this decision. Fantastic timing!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Great!
@RicusNortje
@RicusNortje Жыл бұрын
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
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thanks for sharing!
@CodeToLive-ms4jm
@CodeToLive-ms4jm 4 ай бұрын
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
@IAmTimCorey
@IAmTimCorey 4 ай бұрын
I am glad it was helpful.
@chrisnuk
@chrisnuk 8 ай бұрын
True creativity requires the discipline to harness the chaos of imagination into the simplicity of brilliance
@IAmTimCorey
@IAmTimCorey 8 ай бұрын
👍🏻
@hyxper2989
@hyxper2989 7 ай бұрын
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.
@IAmTimCorey
@IAmTimCorey 7 ай бұрын
I mostly agree with the "it depends", although I've fully moved over to minimal APIs over controller-based APIs now. I don't see the need for controllers and they add a layer of complexity that doesn't seem to be needed. You can do everything you need in a minimal API, including testing, separation of concerns, decorating, and more, but it is in a simpler format with less unnecessary ceremony.
@MayronDev
@MayronDev Жыл бұрын
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.
@ieaatclams
@ieaatclams Жыл бұрын
Mvc is a design pattern. You can do MVC on whatever stack you want. It's about segregation of items
@IAmTimCorey
@IAmTimCorey Жыл бұрын
The situation you are describing sounds like an abuse of MVC. Controllers with lots of actions tend to be really messy and hard to maintain. MVC was developed in a time when the only option for C# on the web was WebForms. MVC provided a more structured, testable, modular approach to web development. It became really popular because of that. Now, we have lots of options for development. Razor Pages works well for single pages (index, error, about us, etc.) where there isn't a lot of interaction. MVC can do more complex code separation for larger server-side sites. We used to use it to provide data to client-side applications such as React, but that's not really the best solution anymore. Now we just use API for that. Server-side in general has fallen out of favor because people want rich, client-side interactivity. That's why we now have Blazor Server and Blazor WebAssembly. Two options to give us that client-side interaction while still using C#.
@AmirHosseinBagheri
@AmirHosseinBagheri Жыл бұрын
@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.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
If you mean the built-in templates, they are almost useless in a large organization. The code of the organization will quickly grow beyond them to the point that the original template had little, if any, impact. In a large organization, it is better to establish coding standards and then apply them to your specific projects. That can include creating your own templates.
@avnishbadoni1393
@avnishbadoni1393 Жыл бұрын
I personally prefer breaking features out into modules (for monoliths). So for example, there's a Loyalty Points feature, just create a new folder... A new module. And have a single point of connection to the rest of the code. Then, there, a developer has freedom to choose any code structure they want to apply. Just for all the routes, controllers, service, models or any combination of these which are created within that module. Faster development with the devs coding style innately being used. And easy switching off and on that module. Also, close to zero merge conflicts. . And architecture could be made as simple or as complex as the requirement of the module. . This approach is something I experimented and created for a startup that started out as monolith, but was soon expected to grow to big scales.... And we needed the code seperation for easily breaking it up into a micro service architecture
@acodersjourney
@acodersjourney 9 ай бұрын
Your passion and dedication shine through.
@IAmTimCorey
@IAmTimCorey 9 ай бұрын
Thanks!
@monirahmad133
@monirahmad133 Жыл бұрын
You are answer my internal myself question, really thanks 🎉
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Excellent!
@dasfahrer8187
@dasfahrer8187 Жыл бұрын
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.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
They are really great.
@blackpaw29
@blackpaw29 Жыл бұрын
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.
@IAmTimCorey
@IAmTimCorey 11 ай бұрын
Thanks for sharing!
@dennisvandermeer8238
@dennisvandermeer8238 Жыл бұрын
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.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
That difference is negligible, I believe, though.
@torrvic1156
@torrvic1156 8 ай бұрын
Thanks a lot for the insight, Tim! This clarifies a lot.
@IAmTimCorey
@IAmTimCorey 8 ай бұрын
You are welcome.
@rikudouensof
@rikudouensof Жыл бұрын
Thanks for the video. Most videos you keep saying it. Avoid the complexity if it is not necessary.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@ionutb123
@ionutb123 9 ай бұрын
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
@IAmTimCorey
@IAmTimCorey 9 ай бұрын
There is still a need for an API. It is just often hidden. For example, with the new Blazor (they've dropped the "united" word even though it was the best way to describe it), if you use Auto or WebAssembly, you get two projects. One is the front-end project and the other is the back-end project. The back-end acts as an API for the front-end.
@timrobertson8242
@timrobertson8242 9 ай бұрын
@@IAmTimCorey That's my current confusion. With WebAssembly deployment, how does the interaction with a Server Side resources happen if one doesn't also build an API layer over the Data Source and to avoid repeating myself, do I use the API for my Blazor Server components. My hope is that by digging into your latest Blazor course (with .NET8), I'll see how this unlocks. Thanks for the insight on end-points vs. MVC!
@patrickizekor6463
@patrickizekor6463 11 ай бұрын
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.
@DannyHodge95
@DannyHodge95 11 ай бұрын
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...
@IAmTimCorey
@IAmTimCorey 11 ай бұрын
Interesting. I haven't found full APIs to be any easier to debug. I've found that it is just a different way to do the same thing.
@cissemy
@cissemy Жыл бұрын
Does minimal api gives better performance vs controller api?
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Technically maybe, but it is more preference.
@blackpaw29
@blackpaw29 Жыл бұрын
@@IAmTimCorey I always get suspect on questions of performance when it comes down to fractional differences with function calls. Unless they are being invoked 1000's of times a second, it rarely matters, but its a honey trap for the ocd tendencies of the coder psyche 😁. 99.99% of the time, performance is impacted by algorithms, i/o and app design.
@reynaldoruizflores
@reynaldoruizflores 11 ай бұрын
How many types of API's exist, and which ones are the modern ones? And which can be handled by Microsoft Technology?
@IAmTimCorey
@IAmTimCorey 11 ай бұрын
Microsoft provides the full API project type (with controllers) for both .NET Framework and .NET. They also provide the Minimal API project type for .NET. Finally, an Azure Function can be a very small API (single endpoint). But that's just the project types from Microsoft. Practically every programming language provides a way to create an API. APIs power a lot of the web and mobile applications out there, plus some desktop applications. If you build an API in C#, the best choice for a new project would be either a full API or Minimal API in .NET 6+ As for your question about which ones can be handled by "Microsoft Technology" (I'm assuming you mean a C# application), the answer is any of them. An API is designed to be processed by anyone. That means you can write an API in Java and call it from C#. The same is true in reverse.
@Anton-Os
@Anton-Os Жыл бұрын
Thank you!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You're welcome!
@lkarabeg
@lkarabeg 6 ай бұрын
While this is good general advice, I feel like it doesn't address the question in the title. I expected more concrete advice, e.g. "If you need action filters, you should use controllers" (true at the time the video was made).
@IAmTimCorey
@IAmTimCorey 6 ай бұрын
The problem is that concrete advice on which to choose is almost always wrong. You need to make the right call based upon your specific situation.
@lkarabeg
@lkarabeg 6 ай бұрын
@@IAmTimCorey If only someone had advice on which things to take into account, though. /s
@IAmTimCorey
@IAmTimCorey 5 ай бұрын
That list includes: * your team's skills * how well your team can train up in minimal APIs * your existing code * the versioning of the libraries you depend on * the features you need to rely on in C# (more preference than prescriptive) * greenfield or brownfield API * any existing conventions or practices that would weight a choice * your preferences And this is a simpler issue, since both can do similar things.
@user-vp1tg4jj3n
@user-vp1tg4jj3n Жыл бұрын
Sir ❤❤
@IAmTimCorey
@IAmTimCorey Жыл бұрын
👍🏻
@SayWhaaaaaaaaaaaaaaaaaaaaaaat
@SayWhaaaaaaaaaaaaaaaaaaaaaaat Ай бұрын
AUDIO ASYNC IS SOO HORIBLE IN THIS VIDEO
@IAmTimCorey
@IAmTimCorey Ай бұрын
If you close your eyes, the problem goes away. 😉 Sorry we can’t fix it any other way.
@kandycan
@kandycan 11 ай бұрын
I think u should never go from controller based structure to minimal API structure. Reason is, codebase will surely get more and more complex even if it's not complex right now. Controllers provide separation of concerns. Now sometimes you may go for minimal API approach especially when you are breaking down monolithic architecture into microservices. But then in case of microservices and API code that won't expand or have more APIs or endpoints for different entities, then go for it. Make minimal API and let it run for years.
@IAmTimCorey
@IAmTimCorey 11 ай бұрын
How does a controller add more of a separation of concerns compared to an endpoint? I can put endpoints in their own class(es) easily enough. They aren't any more coupled than controllers are.
Goodbye controllers, hello Minimal APIs - Nick Chapsas - NDC London 2023
54:28
What Are Your Thoughts on Entity Framework Core vs. Dapper?
21:49
I'm Excited To see If Kelly Can Meet This Challenge!
00:16
Mini Katana
Рет қаралды 34 МЛН
Kind Waiter's Gesture to Homeless Boy #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 5 МЛН
Идеально повторил? Хотите вторую часть?
00:13
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 17 МЛН
ROLLING DOWN
00:20
Natan por Aí
Рет қаралды 7 МЛН
How Do I Structure My Application?
12:25
IAmTimCorey
Рет қаралды 18 М.
Turns out REST APIs weren't the answer (and that's OK!)
10:38
Dylan Beattie
Рет қаралды 138 М.
"I Hate Agile!" | Allen Holub On Why He Thinks Agile And Scrum Are Broken
8:33
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 136 М.
The Magical Pattern to Organize .NET Minimal APIs
9:06
Gui Ferreira
Рет қаралды 8 М.
Making Your APIs Blazingly Fast in .NET 8!
11:45
Nick Chapsas
Рет қаралды 68 М.
Getting Started with OpenTelemetry in .NET
19:56
Nick Chapsas
Рет қаралды 55 М.
Forget Controllers and Minimal APIs in .NET!
14:07
Nick Chapsas
Рет қаралды 64 М.
I'm Excited To see If Kelly Can Meet This Challenge!
00:16
Mini Katana
Рет қаралды 34 МЛН