Object Oriented vs Functional Programming with TypeScript

Object Oriented vs Functional Programming with TypeScript

Fireship

5 лет назад

759,845 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Twig Sagan
Twig Sagan - 14.11.2023 20:08

Just saying. I have seen good OOP codebases, I have not seen good funtional codebases. I am open to examples of a big project that is functional.

Also, functional easy to test? Yeah, because you are testing CODE, not businesss rules.

OOP is easier to test, but I must admit, everyone is doing it wrong. We teach TDD wrong. We teach it with simple classes, which makes us think we should test on the level of functions or classes. But instead, we should test modules. That would be the right level to test at. You learn this by actually writing the test FIRST <- no excuses, just do it. So 1) Red 2) Green 3) refactor. Here are two simple question you can ask to see if you are doing it right:

1) Did I touch the production code without a failing test?
2) If I refactor any of my code, do I also need to rewrite the test? (Of course I don't mean adding a parameter to a method signature here, but anything else does count)

If you answer yes to either of these you are doing it wrong.

Ответить
Kevin
Kevin - 10.07.2023 15:29

I'm still spamming Patrick with a thank you message

Ответить
Kevin Vélez
Kevin Vélez - 08.07.2023 00:07

Cool.

Ответить
Saleem VFX
Saleem VFX - 06.06.2023 01:21

we need more vides like this in 2023

Ответить
Nick
Nick - 28.05.2023 00:45

I think a good developer should learn and at least try all of these paradigms. Learning functional programming can make you a better OO programmer. Learning OO concepts will help you know when to break functional rules.

Personally, I like OOP with inheritance so I can make a standard base class that my junior devs can extend, but put some enforcements in place that you'd have to go out of your way to mess them up. I could probably use some practice with composition, I can see sprinkling some mixins on a few classes.

Ответить
Jim Smith
Jim Smith - 01.05.2023 21:47

Thank you for being so clear and easy to understand programming it’s a great series tutorials that you have I don’t watch anyone else anymore

Ответить
Énio Carlos
Énio Carlos - 24.04.2023 02:27

Is this an AI generated video ???

Ответить
soflass1293
soflass1293 - 23.04.2023 18:01

Why everyone is saying "blue print" and not saying what a blue print actually is!

Ответить
John Smith
John Smith - 10.04.2023 01:13

4 years ago you sounded super weird

Ответить
Donia El Fouly
Donia El Fouly - 10.03.2023 00:03

Thanks

Ответить
Theodore Norvell
Theodore Norvell - 08.03.2023 15:54

The advantage of the functional cake is that when you’ve finished making the cake, you still have all the ingredients. The advantage of the OO cake is that you can digest it.

Ответить
a
a - 26.02.2023 18:06

this was pretty hard to follow and i know the basics of both paradigms

Ответить
ragtop63
ragtop63 - 09.02.2023 21:27

The irony here is that some of these concepts could be a bit difficult to understand at first but the one FACT in this video that still brings people to a complete standstill is, It's GIF, not JIF.

Ответить
LeFede
LeFede - 17.01.2023 03:33

will composition like this be natively available on JS or TS without that ugly boilerplate anytime soon?
Great video :D

Ответить
AbleAscent
AbleAscent - 16.01.2023 19:15

Starts with a G-ee it's pronounced jiffff!!!!

Ответить
Tom Fotheringham
Tom Fotheringham - 12.01.2023 10:52

This is not a complete story of functional programming. Currying has not been touched on. Not functional composition. Why anyone would want to do functional TS is beyond me.

Ответить
Johan Suh
Johan Suh - 23.12.2022 04:06

THIS const addEmoji = (val) => val.toString() + " 😀" , NOT const addEmoji = (val) => toString(val) + " 😀"

Ответить
Artamis Bot
Artamis Bot - 08.12.2022 21:27

Why is this video so good 💚 and why are the answers to all of the opening questions just "both".

Ответить
theacp127
theacp127 - 03.12.2022 18:21

I've only ever used OOP with languages like C++ and Python so the functional programming way of doing things was quite interesting to see. I'll have to try some F# code and make some simple stuff to try it out.

Ответить
lico kr
lico kr - 03.12.2022 15:19

Great video

Ответить
Leandro da Silva
Leandro da Silva - 14.11.2022 01:29

What extension did you use to show the “console.log” result on the right side?

Ответить
ahmad ali
ahmad ali - 09.11.2022 19:28

man your videos like fast food.. but one additional thing they are very healthy <3

Ответить
Andrew Liu
Andrew Liu - 15.10.2022 09:14

Nah nah nah sorry bro I learn everything from you but you’re wrong on the GIF vs Jif 😂 It is pronounced exactly the same as the peanut butter brand Jif. The creator of GIF Steve Wilhite HIMself has attested that the name came from Jif’s old slogan “choosy mothers choose Jif”. His catch phrase was “choosy developers choose GIF”, thus the pronunciation is the same. We can’t just go around telling ppl how to pronounce their names just because their name may not fit the conventional linguistic rule. Like I can’t go tell someone who’s name is Lindsay that their name is pronounced Lind-SAY (like day) cuz it’s usually spelled as Lindsey. It’s their goddamn name! At the end, ppl can say it however the hell they want when they talk but there is an absolute answer in the GIF vs JIF debate, and pronouncing it with the strong G like gift is absolutely wrong 😘

Ответить
Ebrelus
Ebrelus - 10.10.2022 23:22

const nextF = R.appendToEmoji(_, "da")
nextF('🐏') // ?
Classes freak me out, every time.

Ответить
Chavez3d
Chavez3d - 20.09.2022 19:21

lol you are trolling people with gif... the creator put this to bed a while agot... its jif

Ответить
jeffhappens1
jeffhappens1 - 30.08.2022 03:33

what is that extension that shows the return type from a line of code?

Ответить
Youshaa Faisal
Youshaa Faisal - 24.08.2022 21:08

Damn, Fireship sounds young! Actually, is this the same guy?

Ответить
Dreckbob Bratpfanne
Dreckbob Bratpfanne - 29.07.2022 00:06

Having started without any OOP in the first language i used (Blitz 3D, old but still cool), theres a lot of sh't you can do quick and simple you'll never get with OOP eg in Java (and even Kotlin), however in some cases this totally turns around and f*s you over. Develop a game with objects without OOP sucks.

Ответить
IDEDARY
IDEDARY - 29.06.2022 00:26

This mostly depends on what you are doing right now. OOP is better for making closed complex systems and FP is better for universal multipurpose code. From my experience It's best to mix them, I believe it works very nice combined.

Ответить
Dev-Siri 🇺🇦
Dev-Siri 🇺🇦 - 17.06.2022 11:02

Today I learned about emojis

Ответить
Daniel Walker
Daniel Walker - 04.06.2022 18:22

prefixEmoji*

Ответить
Florian
Florian - 24.05.2022 05:46

About the composition example... video game coders are particularly skeptical of any kind of class hierarchies. That's why the ECS system is gaining traction so much... because class hierarchies are too rigid and pretty horrible as far as reuse is concerned. They're hard to adapt to changing requirements.

Even hardcore OOP people stopped arguing in favor of classical inheritance.

Ответить
Marcos
Marcos - 19.05.2022 18:08

I dont know nothing about functional programming.
It looks so restrictive. If you cant mutate objects, then isnt it less efficient since you have to always clone the object inside a function?

Ответить
Till Kaiser
Till Kaiser - 13.05.2022 18:16

Thank you so friggin much. I just wanted to pick up typescript and i found your channel. Now i have a broad idea on how typescript works and i finally understood how the idea of Interfaces actually work out. Kudos! :)

Ответить
TheShermanTanker
TheShermanTanker - 07.04.2022 11:19

I'm pretty sure jif isn't wrong either, since G by itself sounds like "jee" instead of Geek without the K

Ответить
Manmohan Krishna
Manmohan Krishna - 06.04.2022 20:49

Can you please compare scala.js and typescript compilers? Thanks.

Ответить
Nicetomeetu Gaming
Nicetomeetu Gaming - 04.04.2022 15:33

Thanks sir!

Ответить
ahmed zedan
ahmed zedan - 02.04.2022 16:25

I never knew you had a soul.
what happened after 2 years to change you so much

Ответить
Michael McMasters
Michael McMasters - 27.03.2022 01:51

Coming from Spring, these composition examples look a little convoluted.

Ответить
Henrique Finger
Henrique Finger - 18.03.2022 22:19

Functional is so elegant.

Ответить
Ion
Ion - 16.03.2022 10:39

song name please!))

Ответить
Anirban Chatterjee
Anirban Chatterjee - 12.03.2022 14:16

suoercool hotdog example

Ответить
Niccster10
Niccster10 - 10.03.2022 13:57

Its jif. The creator literally said its jif. Scuba isnt pronounced scuh bah just because the u stands for "underwater", so saying "it is graphics not jraphics" is dumb.

letters I E and Y generally follow soft g. This is true for literally 19439 of the 19500 words that start with a g

Ответить
flick
flick - 05.03.2022 00:31

Congrats i thought you was one of those who say oop is trash and fp is better well thx fireship

Ответить
Andre Kuzmicheff
Andre Kuzmicheff - 02.03.2022 19:18

I watched quite a few of your episodes by now, and I really like your style! Thanks a ton for making these videos!

Ответить
Sanjith Kumar
Sanjith Kumar - 02.03.2022 07:10

Which extensions r u using?

Ответить