Want to master Clean Architecture? Go here: bit.ly/3PupkOJ Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt
@soverain Жыл бұрын
The second approach is super clean, removes all the boilerplate that comes from static methods. I very much appreciate your videos about functional programming in C#, keep up the good work.
@MilanJovanovicTech Жыл бұрын
Thank you very much!
@adiazwise Жыл бұрын
Great Milan , you explanation was very clear.
@MilanJovanovicTech Жыл бұрын
Glad it was helpful!
@birukayalew3862 Жыл бұрын
Thank you Milan. I prefer the second one because it's more readable and we can passed many validations at once.
@MilanJovanovicTech Жыл бұрын
They both end up doing the same thing though
@andreibicu55928 ай бұрын
Hi Milan. Another great video. I have one additional suggestion. If the email is null or empty, we need to check on all predicates against it, otherwise we get null reference error. Instead of repeating the check, I would advise to add the check in the Ensure method like this, and the call stays the same as you showed. public static Result Ensure( T value, (Func Predicate, Error Error) hasValue, params (Func Predicate, Error Error)[] functions) { if (!hasValue.Predicate(value)) { return Failure(hasValue.Error); } ... } What do you think?
@MilanJovanovicTech8 ай бұрын
How would that change the overall API usage?
@andreibicu55928 ай бұрын
@@MilanJovanovicTech The usage remains the same. But in your case, you did not test for a nullable email. In such case, everything will crash.
@ksofficerofficer78585 ай бұрын
@@andreibicu5592 I just started programming when tf I'm gonna understand what ya'll talking about !
@krzysztofhandzlik9273 Жыл бұрын
Very nice and clean. That would be usefull in many cases, thanks.
@MilanJovanovicTech Жыл бұрын
Thanm you!
@Tamer_Ali Жыл бұрын
Thanks Milan, you awesome I hope you talk about Vertical Slice Architecture and compare it with Clean Architecture.
@AboutCleanCode Жыл бұрын
these are not mutable exclusive - i always organize my code base "vertically" and inside each "slice" i use clean architecture setup ;-)
@MilanJovanovicTech Жыл бұрын
I still need to do more research on VSA to be able to deliver on this, but it will happen
@AndriyBezkorovayny Жыл бұрын
@@MilanJovanovicTech, great explanation, thanks! What do you think about complexity? I am using this approach in my private projects, but I have been banned from using them at work due to their complexity. Can you suggest how to cope with that?
@mrvastayan Жыл бұрын
Great video mate, thank you!
@MilanJovanovicTech Жыл бұрын
Glad you liked it!
@angelldark6426 Жыл бұрын
I like both options, but would like more examples using class Rusults. I want more practice. Thanks
@MilanJovanovicTech Жыл бұрын
Look for some Railway-oriented programming videos
@dusrdev Жыл бұрын
About the second approach, it is rather unoptimized, firstly because the parameter is a params array object, in the function you can check the length of it and create an array of results to match the length, and use a for loop instead of the foreach, then pass the array to the combine method. This will entirely eliminate the List allocation, because you are already allocating a new array with the ToArray method which you could then remove. Or even more simple, without using the loop, run over the params object with a .Where method, and pass the Enumerable to the combine. For even more efficiency, you could modify the check to add an object only if an error occurred, and combine that with a .Where method.
@MilanJovanovicTech Жыл бұрын
You're welcome to optimize it as much as you want. Great suggestions. 😁
@TT-nh3qt Жыл бұрын
The title is "How Function Composition Can Make Your Code Better | Functional Programming" ...
@dusrdev Жыл бұрын
@@TT-nh3qt the suggestions I made don't make it any less functional, most don't even require changing the API.
@greyshopleskin2315 Жыл бұрын
This sounds like an obsession with premature optimization. Indeed, great suggestions about performance.
@gardnerjens Жыл бұрын
i like the idea of having an array of tuples one question, would it not be more functional had you use Aggregate instead of foreach? since you are creating a new type, then folding over the array of tuples you could then pass in the value t, to each function?
@MilanJovanovicTech Жыл бұрын
Yes it would :)
@microtech2448 Жыл бұрын
Great video
@MilanJovanovicTech Жыл бұрын
Thank you! I see you're brushing up your FP skills 👌
@AmirHashemZadeh Жыл бұрын
it was perfect thanks
@MilanJovanovicTech Жыл бұрын
Glad you liked it!
@darwish13375 ай бұрын
hello thank you its was useful , can i ask you how i can learn how i create my own extenision result ? and Function Composition?
@MilanJovanovicTech5 ай бұрын
Copy my code and iterate?
@andrewseaton5727 Жыл бұрын
Another great video! Thanks
@MilanJovanovicTech Жыл бұрын
Glad you enjoyed it!
@antonmartyniuk Жыл бұрын
I like the 2nd approach more. Looks much cleaner and has less code
@MilanJovanovicTech Жыл бұрын
I also like it more
@mahmmoudkinawy2783 Жыл бұрын
Hello Milan, where to get resources to write a FP code such you.
@MilanJovanovicTech Жыл бұрын
Functional Programming in C#: How to write better C# code 1st Edition by Enrico Buonanno
@alberthalbert1153 Жыл бұрын
Thoughts on making videos showing how to build good WPF applications?
@MilanJovanovicTech Жыл бұрын
I have no idea how to build a good WPF application 😅
@tienbui2814 Жыл бұрын
What’s the Result library you used?
@MilanJovanovicTech Жыл бұрын
Not a library, it's something I created on my own
@tienbui2814 Жыл бұрын
As you said. I had seen full the video and see the Class Result. I think it very helpful to handle exceptions. ❤
@alexlo5655 Жыл бұрын
There is a very popular lib which has everything github.com/vkhorikov/CSharpFunctionalExtensions
@AmirHashemZadeh Жыл бұрын
@@MilanJovanovicTech please share it on github or other repos.