Binary Search Algorithm in C#
17:06
Пікірлер
@nahiandev
@nahiandev Сағат бұрын
I was doing CQRS with MediatR, but didn’t get the underlying magic well. This video made me understand how MediatR works under the hood. Nice conceptual explanation! ❤❤
@nahiandev
@nahiandev 2 сағат бұрын
Just got into validation and found a `Milan` video. What could be better than this!
@ciekawki6574
@ciekawki6574 5 сағат бұрын
I don't get it. What if I need to have multiple versions of the same package across different projects? Wouldn't that complicate things even further?
@Anno_Nymous
@Anno_Nymous 4 сағат бұрын
yes it will, however so will using different version of the same package, especially if the projects have relations with each-other. you should fix version mismatches it can give headaches later on.
@davidmataviejo3313
@davidmataviejo3313 6 сағат бұрын
For those wondering why this is useful, it's likely they haven't worked on large projects. In such projects, it's common for different components to use varying versions of the same library, leading to compatibility issues and errors.
@Anno_Nymous
@Anno_Nymous 4 сағат бұрын
nuget package manager, at solution level gives warnings when you have mismatches which is enough for me tbh, nevertheless this can be helpfull in keeping things clean. downside is when adding a new package you will need to manually add it to the buildprops file.
@timmkrause6684
@timmkrause6684 2 сағат бұрын
@@Anno_NymousI think VS as well as Rider do detect/support central package management and they will add it accordingly.
@thomasvlima
@thomasvlima 6 сағат бұрын
Is there any way to do that from the Visual Studio GUI already?
@sweeperq
@sweeperq 6 сағат бұрын
Kind of. You can manage nuget packages at the solution level. It will tell you which version is installed in each project and allow you to install/update accordingly.
@thomasvlima
@thomasvlima 6 сағат бұрын
@sweeperq yes, but its another feature. I was asking about the feature presented in the vídeo.
@Anno_Nymous
@Anno_Nymous 4 сағат бұрын
Yes, go to tools > nuget package manager > manage package for solution. here you have your central package managment. you can see all your packages, see what is the latest version, see if there are updates, see if packages are deprecated, etc etc. It's the industry standard, and yes also for large projects. it warns you for if you have different versions for the same package across projects, the managepackeversioncentrally just uses 1 file with the version and packages for all files (so you wont get version mismatches)
@Anno_Nymous
@Anno_Nymous 4 сағат бұрын
@@thomasvlima no, you have to add the new file, name it add the projects. end edit all project files.after that you can use nuget package managment as normal, however adding a new package need manual editing again. so it does add complexity.
@chenz2584
@chenz2584 6 сағат бұрын
Is it ready for using in production?
@MilanJovanovicTech
@MilanJovanovicTech 6 сағат бұрын
@@chenz2584 Yes
@decisivepro1961
@decisivepro1961 7 сағат бұрын
In the nuget package manager, you can already install/update packages for all projects. I don't see any advantage here
@Code_Bits
@Code_Bits 7 сағат бұрын
Thats not the same
@Anno_Nymous
@Anno_Nymous 4 сағат бұрын
@@Code_Bits sometimes you need the same package in multiple project of the solution, this will prevent have for instance version 2.1.1 of a package in project A, while having 2.1.3 in project B for example.
@icold68
@icold68 7 сағат бұрын
Obrigado! Agora possui áudio em PTBR
@Piyush-mg4zq
@Piyush-mg4zq 7 сағат бұрын
How will it benefit?
@pderuiter77
@pderuiter77 7 сағат бұрын
If you have 5 projects, you can make sure all those projects have the same version of a package.
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
Managing package versions in one place - works really nice for large projects
@edgarskurpnieks476
@edgarskurpnieks476 7 сағат бұрын
Does that props file have to be located in the same solution? If i have multiple repos with multiple solutions, what then?
@notXarv
@notXarv 7 сағат бұрын
No more consolidating packages
@MilanJovanovicTech
@MilanJovanovicTech 6 сағат бұрын
@@edgarskurpnieks476 Can be solution level, or folder level. I think this is meant for a single solution, but you could share it if you import the same props file in all solutions.
@DelRiode
@DelRiode 8 сағат бұрын
Thanks for the great video! Suppose my command handler becomes more complex and I need to call another command from a command handler. Is it appropriate approach in CQRS? If not, what should be used instead of command in command?
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
I tend not to compose commands. Rather, I publish an event and handle the second command in the background
@RMarjanovic
@RMarjanovic 9 сағат бұрын
In a DDD setting using the result pattern with static errors, whats your take on moving validation to the domain in i.e an create method and skipping input validation in the app/presentation layer? In recent projects I have totally omitted using FluentValidation just by following the patterns. I can see some benefit like some built in validations i.e email or credit card, but other than that most could be easily implemented using the patterns you suggested in previous videos.
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
I think your approach is pretty sane. The difference is failing fast, I guess. When doing some validation in the use case, we may end up performing some network trips before realizing we have invalid data (unless all preconditions can be checked first, in which case it's equal).
@casperhansen826
@casperhansen826 10 сағат бұрын
I prefer var variablename = new T()11 The keyword var is very helpful with linq since those types are often very complicated and virtually unreadable anyway
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
Good point!
@antonmartyniuk
@antonmartyniuk 10 сағат бұрын
Interesting that you started using HTTP request files in your videos
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
Mhm, exploring this some more
@antonmartyniuk
@antonmartyniuk 11 сағат бұрын
Have you compared performance of HybridCache vs IMemoryCache and IDistributedCache. Interesting how much overhead we get with locking in HybridCache. Also a FusionCache is a much better option atm, has much more features and is stable for years. At least atm
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
I think you're right about FusionCache. Didn't do a performance comparison
@manya.korolevskaya
@manya.korolevskaya 11 сағат бұрын
Hi Milan, how FluentValidator deals with DDD? I struggle with using both concepts. From one hand, we need to keep always valid domain models by using value objects with the rules defined inside. From the other hand, it produces so many lines of code, that there is a high temptation to put all rules indide a fluent validator and left only business rules implemented inside the domain, making it vulnerable for null values, invalid email, etc. What do you think?
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
I think they solve different problems. So the question is which problem are you trying to solve?
@manya.korolevskaya
@manya.korolevskaya 2 сағат бұрын
@MilanJovanovicTech if I want to stick to DDD, how to incorporate FluentValidator?
@gencaysayin556
@gencaysayin556 11 сағат бұрын
Constantly calling the IsValid property, checking it, and returning an error result feels repetitive. Could we use middleware to handle this instead? Was there a specific reason you didn't cover this in the video? Is it considered bad practice? It would be great if you could make a video about it.
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
I'd have to do some reflection magic to make this work in a middleware, so I decided not to explore this approach
@juancarlosrodriguez4969
@juancarlosrodriguez4969 18 сағат бұрын
Yo usualmente uso: if (!ModelState.IsValid) return BadRequest(Result<string>.Failure("Msg error.", 400)); Pero me parece interesante y más ordenada la propuesta que compartes :)
@turbdonkey
@turbdonkey 18 сағат бұрын
Do you have to include the NotNull check when you're using SetValidator?
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
Don't think so. Up to you. But where will you check for null?
@اسيرالعلم-ك9ظ
@اسيرالعلم-ك9ظ 22 сағат бұрын
what about users of same role has deffernt permissions, because know u get the permission of the role insted of permission of spicific user
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
The relation is between role and permissions, not users and permissions. We'd need a different data model for what you're describing.
@perelium-x
@perelium-x 22 сағат бұрын
12:07 lmaoo 😂 you got me
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
Had us in the first half
@heikenem
@heikenem 22 сағат бұрын
Nice video. Where can we get the code base?
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
Currently, all code is shared here: www.patreon.com/milanjovanovic
@antonmartyniuk
@antonmartyniuk 22 сағат бұрын
Never heard about Inline Validator. Thanks for mentioning this option. I am glad that I haven't skipped this video, despite me using Fluent Validation for years (what I could haven't known 😅 ?)
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
Glad to be of service
@basselalnabhan1762
@basselalnabhan1762 Күн бұрын
Greate video! Thanks Milan, your channel is one of my favourites 🌷 what is the plugin/extention that displays the content of the variables when debugging in the video?
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
ReSharper
@basselalnabhan1762
@basselalnabhan1762 6 сағат бұрын
@ Thanks
@parkerwarner8688
@parkerwarner8688 Күн бұрын
Never been the service provider but more the client (sending urls and consuming). Great video! Ngrok is also a great tool!
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
Is Ngrok a cloud service now only?
@emfi8744
@emfi8744 Күн бұрын
This example seems to me a simple example of layered architecture. In onion/hexagonal you have a pure class without dependences
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
Onion/hexagonal are just as "layered" as anything else. What do you mean by "pure class" in the context of your last sentence? What can a class with no dependencies do within the scope of the system?
@emfi8744
@emfi8744 6 сағат бұрын
@MilanJovanovicTech I mean a class without side-effects: no input/output what-so-ever, only pure logic. Eg: service reads a list of transactions from repository, passes it to the pure class, that in turns return the tax amount for each of them. The service may enrich this tax list with more details from another repository and then pass it to the controller, that will wrap it into an http response
@ivanbanov8939
@ivanbanov8939 Күн бұрын
Great video, Milan. Did you know that the EmailAdress() method just checks if there is an @ in the string that it is not in the beginning or the end? I recently found out and was surprised about how shaky this particular validation is.
@omerabay
@omerabay Күн бұрын
I have your free clean arch template. I noticed that Web.API (Presentation) layer can access to the dbcontext object directly, Wouldn't be a problem to access DbContext object directly?
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
They're on the same level, so it's fine. Plus, you need to wire up DI somehow.
@Anas_Chahid
@Anas_Chahid Күн бұрын
Hey, nice video, Can you try Zitadel someday? It is a good opensource Identity provider and It also has a dotnet SDK, I've been using it and so far it is good, especially multi tenancy.
@KingOfBlades27
@KingOfBlades27 Күн бұрын
Great points as always. Have been using fluent validation in couple of projects and it has been nice. Some points here were still new to me, so I have to check this video again later for reference 💪
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
Yeah, I guess lots of folks didn't know about InlineValidator
@nguyendavid4285
@nguyendavid4285 Күн бұрын
How to get this source of video?
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
Currently, all code is shared here: www.patreon.com/milanjovanovic
@vadym5581
@vadym5581 Күн бұрын
So interfaces for services and repositories aren't mandatory? Didn't know that! Thank you!
@MilanJovanovicTech
@MilanJovanovicTech Күн бұрын
The disadvantage with that is you need your team to know what they're doing (go figure). Otherwise, it tends to become a mess over time.
@developmentroselino
@developmentroselino Күн бұрын
why is this isnt a default
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
No idea
@ZubriQue
@ZubriQue Күн бұрын
Not sure if it's sad or not, but we write our own validator classes instead of using Fluent validation because of performance. Yes, the syntax is less functional :) But I still feel like Fluent validation _is_ the right way.
@svorskemattias
@svorskemattias Күн бұрын
@@ZubriQue I think you're better of without fluent validation. You have more power the way you do it. The declarative style of fluent validation is a weakness imo.
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
How much more performant is your solution? This would fall under micro-optimizations
@tsheponnene457
@tsheponnene457 Күн бұрын
Lmao doesnt it mean you are even more lazier
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
Nah
@dzoniaero
@dzoniaero Күн бұрын
Mislim da 90% programera koristi interpolaciju , jer konkatanacija je zastarela :D
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
Još uvek naiđem na konkatenciju tu i tamo
@ChandanSomani
@ChandanSomani Күн бұрын
hi @Milan, can you elobrate more the use case about Utilizing Refresh Token if current Access Token is expired, becuase when access token is expired, UI doesnt know that token is expired, what mechcanism is required to implement this refresh token endpoint
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
You check if the server returns a 401 response
@logantcooper6
@logantcooper6 Күн бұрын
var score = 5; var name = "compiler" var colorMap = new Dictionary<int, int>(); Is more readable (to me) than int score = 5; string name = "compiler"; Dictionary<int, int> colorMap = new() especially in cases where your variable names make it clear what your variable is. That way you can scan down your code and grok it faster.
@ronaldlantigua5336
@ronaldlantigua5336 7 сағат бұрын
Agree
@MilanJovanovicTech
@MilanJovanovicTech 7 сағат бұрын
I see. Makes sense. I rarely have a big block of variables next to each other, so it never really bothered me.
@svorskemattias
@svorskemattias Күн бұрын
I think fluent validation and mediator are the two worst contributions to the .net ecosystem.
@MilanJovanovicTech
@MilanJovanovicTech Күн бұрын
You're free not to use them. What have you contributed to the .NET ecosystem?
@svorskemattias
@svorskemattias Күн бұрын
@MilanJovanovicTech They are dragged into many projects that I work on. I don't always have a say. I've not contributed much at all, and what I have contributed is not much appreciated! 😅 That doesn't make fluent validation any better though! I think validation of input (that is mostly made up of primitive values) should output strongly typed value objects. I've made my own system for this, but of course, only I myself is using it. :)
@weisong3593
@weisong3593 Күн бұрын
Do you have repo for this video? So that I can learn detailly.
@MilanJovanovicTech
@MilanJovanovicTech Күн бұрын
I share all the code here: www.patreon.com/milanjovanovic
@ayzack2361
@ayzack2361 Күн бұрын
Really good video, I like how you explained all of these features as well as your demo. Thanks!
@MilanJovanovicTech
@MilanJovanovicTech Күн бұрын
You're welcome!