Комментарии:
¡Gracias!
ОтветитьMr.Milan, do you have this project on Gidhab?
ОтветитьHey Milan, fantastic introduction to FP. I started watching your DDD serious and then stumbled upon this one. To be honest, I am not yet deeply into C#, am rather programming in Dart for mobile. However, I use FP there to stream line exception handling. There is a well documented package called fpdart, accompanied by some blogs on functional programming. Looks like the Result type in your project corrresponds to the Either<Left, Right> type in fpdart, where Left is by convention the Failure, and Right is the Success, whereby only one state is possible. Method chaining can also be done easily.
Really enjoy your videos, as you explain the topic in a great way!
Two chars: Rx
ОтветитьI actually have a similar solution to this in my own projects, although I didn't know it actually had a name already, I just dubbed it chain validation.
I quite like this approach personally as you can just chain call validations and it is neater. I also like the result wrapper and will definitely include this, mine doesn't have this and instead throws an exception when a condition fails (I suppose in this context you would say it gets derailed), but your solution is better.
Milan, I would appreciate if you clear one point for me. As far as I understand, we write extension methods for classes we can not change. And here you write an extension method for Email class and then edit this class. What about O from SOLID? Isn't it easier to write the method inside this Email class? I am a newbie if anything :)
ОтветитьA switch would be easier to write and debug.
ОтветитьLove the railway approach here. Tho I find these fluent statements hard to debug. Is there a way to step thru each step?
ОтветитьHi Milan, I've watched many of your videos and I do enjoy them. I would like to point out that you said you finished with less lines of code when in fact, you finished using more than 3 times as much code. (The original method had, effectively, 7 lines of code if you removed the blank lines and the superfluous braces). I am not a fan of using functional styles in an OO language (I don't include LINQ as it is effectively a separate language within a language). I admit that your code is more resuable though, but it's arguable as to how much reuse you will achieve. Reuse could be achieved in an imperative style too.
I worked for a company where they had taken this style of programming to the nth degree and it was a mess of functions the all did similar things but were meant to be used in differnt situations, everything had similar names wrote bucket loads of code to effectively do null checks and turned the whole thing into a framework. It was difficult to follow and there was no documentation. I know what you may be thinking, that was an example of bad coding style functional or not, well maybe, but these things tend to get abused.
IMHO if one wants to use a functional style of programming, then I would recommend F# not force an OO language to be Functional. Just my opinion Milan, please do keep up the great work that you are doing.
What keyboard are you using ?
ОтветитьStill waiting for more videos in this series
ОтветитьWell, other than the cons you listed, I disagree with everything you've said. However, I don't have the wherewhithall to discuss the finer points right now. I just want to say that if one is truely committed to writing Functional code in .NET, one should probably switch to using F# so they don't have to constantly write the boiler plate backing needed in C#
ОтветитьGreat video. I like the approach. It looks much cleaner and self-documenting. This is especially true when coupled with the Result and static Error approach. Thanks for sharing!
ОтветитьGood class,tks!
ОтветитьGood video. These functional programming concepts are difficult to get other team members to embrace though. Some appreciate them, others simply don't understand.
ОтветитьGreat video.
ОтветитьF# video?
ОтветитьInteresting and straightforward as always, keep going! 👍🏼
ОтветитьIt's clever code but I'm not sure it's less code always. Depends on where you apply it. Also, as you said, it quite reduces the understanding of the code.
You could probably have written the original code with pattern matching, made it a single expression and it would be just as readable and understandable as well as made into an expression.
Also, small niggle.
Linq is not pronounced 'Lin Queue' with two syllables it is pronounced with one syllable like the word LINK. Like the character's name in Legend of Zelda. :)
Keep up the fun videos.
Is it thread-safe?
ОтветитьHello, Milan. Great example, i like it. But i have some thoughts:
That example works with primitive conditions. So what if we need to process some async assertions that works with db(for example)? I heard about fluent validation, it allows you to inject you service in ctor, write your rule and call MustAsync or CustomAsync.
What you need to do (or change)in that scenario with extensions to archive that goals?
Is it possible to do with async/await in ROP ?
ОтветитьGood stuff. Have you ever used the FluentResult library?
ОтветитьWhy don't just use Haskell. Where all of this is mandatory.
ОтветитьThis feels like what you must do in a common Haskell program.
ОтветитьNice video, like every time ! Keep up
ОтветитьThank you for your videos :)
ОтветитьEnrico Buonanno makes the best case for functional programming in C# that I've seen. Hopefully the language will support it in a way that makes code more readable when it comes to handing multiple return types (discriminated unions).
ОтветитьGood one...liked to learn more about c# functional programming...will you please share some more insight into this?....liked your work....love to learn more from you....thanks 👍
ОтветитьNiiiiiiiiooccccccccccccce.... Thank you
ОтветитьFunctional programming, yes! Very excited to see more on this topic!
ОтветитьHi Milan, thanks for your efforts on this. It would have been nice however to give credit to Scott Wlaschin (F# for fun and profit). He invented the ROP term for this kind of functional composition. Also, it would have been better to take a different example than validation. Chaining functions which can fail would have been a good example.
Validation however, requires a different composition, because you don't want to stop validating after the first failure, but instead return info on all failures.
As you indicate, it indeed complicates the consuming code and this should not be underestimated. You did not touch the topic of composing the results, which is pretty important. Especially if some results arrive asynchronously ;-)
But my main remark is that Scott really should have been given credit in this video. Thanks.
Thank you for the video Milan! ROP looks great with linear workflows. Could you elaborate on more complex cases where an object requires to validate multiple parameters on creation?
ОтветитьA benchmark on this approach would also be very interesting. Which of the two implementations has the greater impact on performance?
Ответитьseems similar to fluent validation?
ОтветитьGreat One Milan Keep It Up
and can we use something like this to create automated workflows
Hi, nice video, do we have github repository? To follow your videos, specifically interested in Result class, and Domain Error implementations, thank you again.
ОтветитьGreat intro to ROP!
Thanks!
That reminds me of the Option module from F# which is just a bit more enhanced as it applies full set of "filter-map-reduce" (LinQ style) functions to the Option type which is modeling existence and absence of values ...
ОтветитьAmazing, any idea on whether the code will be published on Github or not, i would love to dig into it. Thank you
ОтветитьFantastic video in such an interesting topic.
Looking forward to your advanced videos on this - there is not a lot of content out there (even paid content) on functional programming in C#, and I think the benefits of using it are huge. There is the amazing book Functional Programming in C# by Enrico Buonanno (now with a 2nd edition), and a nice blog from Mark Seemann.
However, at the end of the day, C# is not a functional-first programming language, and I have realised that either I move to another language, or I acept those imperative if statements.
Your video shows a practical and clean way to turn an imperative method to a declarative one. Railway-oriented programming looks very interesting and practical. Thank you for sharing, Milan - another excellent video!
Wow! Interesting concept. Thanks Milan
ОтветитьThanks for the demo. Waiting for new videos. Could you share how can do xunit for this railway programming please. Could you please share an intro about what version of c# and the core.
Ответить