Functional vs Object Oriented Programming in Python

preview_player
Показать описание

If you found this content helpful please do consider subscribing to the channel, it's a huge help. And let me know what else within your programming journey you'd like to learn about in the comments!

Answering some common questions on functional vs objected oriented in programming and then showing a few code examples to demonstrate a pure function and an object that stores state with a function that modifies the internal data.

Timestamps:
0:00 - Introduction
0:05 - Is Python an object oriented programming language
0:33 - Can you do functional programming in Python?
0:53 - Common object oriented languages used in a company
1:10 - Differences between functional and objected oriented programming
2:15 - How to make good classes in Python
4:05 - Unit testability of functional code compared to classes
4:35 - Writing a functional math module
7:18 - Why functional programming is good for concurrency
8:01 - Using list comprehensions for functional transformations
9:35 - Converting our functional code to a do_math class (should be DoMath)
11:40 - Altering the state of our class data
13:35 - Outro

Object oriented code:

Article:
Рекомендации по теме
Комментарии
Автор

One of the best videos explaining this OO vs Functional programming. Concise, with clear examples and a coding demo which is the best way to understand the concepts imo. This deserves more views. Great work.

pcl
Автор

Thanks for the video, just getting back in to coding after a LONG break. C++ was what I used to program in, now everything at work is using Python. Fun times learning it.

TheFirearmada
Автор

Cool video. I have zero experience with Python (unless you read my resume) this is a great intro.

RealCaptainAwesome
Автор

man... this is very much an unresearched video. Why you want to pass functions to functions? -> dependency injection. Also functional programming is about immutable data structures, types, and composition everywhere. We didn't even see a hint of composition, no currying, no map, filter, reduce. We didn't even see the tip of the iceberg. Every time you say "I'm not sure why you'd wanna do this" -> that is an indicator of needing more research. Recommentdation: /watch?v=srQt1NAHYC0

TastyTales
Автор

I love the war between Object Oriented and Functional. Can't we all just get along!!!

romangeneral
Автор

Could you call the functional commands in your class methods? I realize here it would just be extra work. Extract variables from self and input to external function from method. However, let’s say you have a bunch of existing complex functions that you don’t want to have to rewrite as methods. Is it had practice to strip the properties of a class as inputs for a function to prevent having similar methods and classes existing in your code library?

bend.
Автор

So functional language is just an OO language but you don't use objects or classes? Or to put it another way, just use a OO language poorly?

xpkareem
Автор

you speak very well, but you don't magnify the code so the video is very hard to follow. Please magnify.

jesuisravi