This is How FP Made Me Understand Design Patterns Better

preview_player
Показать описание
The best-kept secret of object-oriented design patterns is that they do not require objects. Except for the functions, which are also objects. Big time.

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
👨 About Me 👨
Hi, I’m Zoran, I have more than 20 years of experience as a software developer, architect, team lead, and more. I have been programming in C# since its inception in the early 2000s. Since 2017 I have started publishing professional video courses at Pluralsight and Udemy and by this point, there are over 100 hours of the highest-quality videos you can watch on those platforms. On my YouTube channel, you can find shorter video forms focused on clarifying practical issues in coding, design, and architecture of .NET applications.❤️
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
⚡️COPYRIGHT NOTICE:
The Copyright Laws of the United States recognize a “fair use” of copyrighted content. Section 107 of the U.S. Copyright Act states: “Notwithstanding the provisions of sections 106 and 106A, the fair use of a copyrighted work, including such use by reproduction in copies or phono records or by any other means specified by that section, for purposes such as criticism, comment, news reporting, teaching (including multiple copies for classroom use), scholarship, or research, is not an infringement of copyright." This video and our youtube channel, in general, may contain certain copyrighted works that were not specifically authorized to be used by the copyright holder(s), but which we believe in good faith are protected by federal law and the Fair use doctrine for one or more of the reasons noted above.
Рекомендации по теме
Комментарии
Автор

This is also a perfect example to show why use a delegate instead of explicit "Func<string, bool>"

nanny
Автор

Zorane, hvala na ovome videu. Nisam znao da FP implementira design patterns, ovo je totalno novo za mene. Svakako FP je bio na mom radaru vec poodavno, nazalost nisam imao puno raditi stime. LP iz 🇩🇰

TankaNafaka
Автор

It would be nice if you went through a series of showcasing a comparison between most popular OOP pattern and the corresponding FP pattern. I can already think of a few, but this would probably encourage more people to adopt FP. Also I believe a combination of both is the best approach in most situations.

damianradinoiu
Автор

Cool. Thank you. Observation: in both FP and OOP encapsulation is an important topic. One should refrain from using public visibility when not needed.

arialdomartini
Автор

8:15 You got me with the Haskell style pattern matching for lists. I did not know C# had that one. Thank you!

anibaldk
Автор

Zoran, I just love watching you code, it is always a sheer pleasure.
I especially like this kind of examples, choosing the right use-case for a programming style can really showcase it's benefits
This demo of using functional programming was top class.

shmupful
Автор

This actually wrapped my head around some FP concepts, 10/10

alexsherzhukov
Автор

Congrats. One of the very very few videos of live coding which is not using the mouse. Really appreciated.

arialdomartini
Автор

I think one power that is underestimated by functional programming is less naming of things that are just anonymous actions anyways. But reusable things should have names that qualify the usage but one reason naming is so hard is somethings just don't need to be labeled, not everything should be a reusable reference

camoman
Автор

For the strategy pattern, there’s a benefit of going with object oriented style: it’s easier to find all possible implementations. Func<char, char> doesn’t really say that much about all the possible implementations. All I know is that it’s a function accepting a char and returning char, which can be any function in the program. The IDE won’t necessarily help much either.

ICharacterTransform can be more descriptive in its restriction. With an IDE, I can easily find all possible variations of this interface.

Either way, it all depends. Go for either functional or object oriented where it makes sense. It’s a common misunderstanding that functional programming and object oriented are mutually exclusive. They go great together!

oscarfriberg
Автор

I'm not a professional programmer, I do write some personal applications in C#, this 10 min. video made me learn many things that took me hours. I know I could do it with basic statements, but it is nice to learn his amazing use of many features that I never used.

_-Skeptic-_
Автор

Really liked the passwordpolicy specification example.
Im sure Ive seen the 200 line if else statement it replaces a million times for similar code.

jonobaker
Автор

Listening to your soothing voice, I only just now realized I need someone to narrate my life. Are you available?

EmperorFool
Автор

This is assuming the strategy does not need any dependency. It is pretty common for strategies to need dependencies (logging, configuration, external data access to make the decision, etc). Would be nice to see the full picture with examples on how to setup the DI in this case. Still very good intro video as always which keeps pushing me more and more to FP.

AndreMantas
Автор

Mama Mia, so delicious 😋 FP - is another world, It's straightforward, simple to read and minimum boilerplate. I really enjoy writing code In FP style every day. Thank, Zoran, for another great video🔥Looking forward for more content about FP 🤩

rustamhajiyev
Автор

C# has Predicate<T> so can we think the specification pattern is supported at the language level?

okcharles
Автор

The problem with classes is that someone thought they need to be in separate files in order to operate. The world will be a better place if you remove those 4 primitives and introduce a type, even if it is within the same file. In TS and F# they usually keep all definitions for a certain scope inside a single file, and it is encouraged to make new types that fit you and most importantly, name them as you need, not to avoid the complications of clashing type names. When you ask for specific things, then you can delegate the work onto the callers. This also kinda resembles dep. inversion in a way by demanding instead of receiving and wondering how to handle the parameters.

dczoekj
Автор

Nice work Zoran.

I particularly like the creation of a list of succinct rules, say password verification, in a chain of functions. I'd be interested to see how a chain of responsibility is implemented with it.

I've been injecting func lambdas with delegate for years. Turns out that I'm a functional style programmer and I didn't know it !

It's not always appropriate to use func, especially when the is many of them. An Interface is the right thing in this case, otherwise the number of parameters gets out-of-hand.

nickbarton
Автор

Specifications can be injected in the composition root either manually or through reflection and using DI, you'll have full blown centralized specifications to be used across your whole system. Am I correct in assuming this?

Olaff_
Автор

Hello, I've been looking for something like this because I use a log of strategy pattern. I used because II will have a piece of code that will process something and the caller don't know who it is. Could even be a add-in that is loaded dynamic. That invalidate the array that you create with all the strategies (that for you are functions). In my Workflow, only one strategy process one ObjectType and let's define each object with the correspond ObjectType.
After all my DLLs are loaded (inclusive the add-ins) I will have the full list of strategies available in instance, therefore, How can I inject these methods when I have the list of objects and I want to process them by the correct strategy?
Thanks

aboimpinto