Тёмный

3 Simple Ideas From Functional Programming To Improve Your Code 

ArjanCodes
Подписаться 233 тыс.
Просмотров 96 тыс.
50% 1

Functional programming is a complex topic to dive into. However, there are 3 simple ideas from functional/declarative code that you can apply to your own code today - without becoming a Haskell expert! In this video, I dive into the details and show you a few examples in Python of how you can use these ideas in both object-oriented and functional/procedural code.
The code I worked on in this episode is available here: github.com/ArjanCodes/2022-fu....
💡 Get my FREE 7-step guide to help you consistently design great software: arjancodes.com/designguide.
💻 ArjanCodes Blog: www.arjancodes.com/blog
🎓 Courses:
The Software Designer Mindset: www.arjancodes.com/mindset
The Software Designer Mindset Team Packages: www.arjancodes.com/sas
The Software Architect Mindset: Pre-register now! www.arjancodes.com/architect
Next Level Python: Become a Python Expert: www.arjancodes.com/next-level...
The 30-Day Design Challenge: www.arjancodes.com/30ddc
🛒 GEAR & RECOMMENDED BOOKS: kit.co/arjancodes.
👍 If you enjoyed this content, give this video a like. If you want to watch more of my upcoming videos, consider subscribing to my channel!
💬 Discord: discord.arjan.codes
🐦Twitter: / arjancodes
🌍LinkedIn: / arjancodes
🕵Facebook: / arjancodes
👀 Code reviewers:
- Yoriz
- Ryan Laursen
- James Dooley
- Dale Hagglund
🎥 Video edited by Mark Bacskai: / bacskaimark
🔖 Chapters:
0:00 Intro
0:53 Programming paradigms
2:30 Code example
3:48 #1: Group side effects and use pure functions
5:27 Code example
11:19 #2: Functions are first-class citizens
11:45 Code example
16:53 #3: Use immutability to your advantage
17:46 Code example
#arjancodes #softwaredesign #python
DISCLAIMER - The links in this description might be affiliate links. If you purchase a product or service through one of those links, I may receive a small commission. There is no additional charge to you. Thanks for supporting my channel so I can continue to provide you with free content each week!

Опубликовано:

 

1 май 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 147   
@ArjanCodes
@ArjanCodes 6 месяцев назад
💡 Get my FREE 7-step guide to help you consistently design great software: arjancodes.com/designguide.
@MTT818
@MTT818 Год назад
I encourage you to come up with a full production series, which could be couple of dozen of videos but would be extremely useful. Considering a simple application deployment and put it in production with all software design consideration, such as how to put together all pieces of a software in production such as dockerization, traffic balance, and maintenance, CI/CD all on cloud of course, I offer my help if needed. Thank you!
@aflous
@aflous Год назад
That would indeed be amazing. Happy to help too if needed
@ArjanCodes
@ArjanCodes Год назад
In principle, that’s a good idea. Unfortunately, it’s really not suitable for RU-vid as the algorithm favors videos that stand on their own (even the 2 or 3 part miniseries I post from time to time do less well than my standalone videos). I am thinking of offering something like this as an online program though.
@ndiegow1
@ndiegow1 Год назад
@@ArjanCodes I would love to buy a complete course.
@digiryde
@digiryde Год назад
@@ArjanCodes In the Python World, Using Django, it would be possible to build several stand alone apps that could be tied together. Though, that might still be too niche. Whatever you do or not, you are doing a great job. Thank you.
@muhammadiqbalbazmi9275
@muhammadiqbalbazmi9275 Год назад
@@ArjanCodes yeah this would be a better option to have a complete course end to end.
@nathanrasmussen931
@nathanrasmussen931 Год назад
You have one of the best RU-vid channels for Python programming. You always provide clear explanations and show code examples of why you are changing anything. I am always happy to see new videos from your channel. Thank you for making videos!
@ArjanCodes
@ArjanCodes Год назад
Thanks so much Nathan, glad it was helpful!
@ddctechinstitute6861
@ddctechinstitute6861 Год назад
Not just for python programming but software engineering as a whole. You can apply this principles to any language all you need do is learn with an open heart not a syntax or language oriented.
@jindy94
@jindy94 Год назад
Just wanted to say that you really have inspired me to write much much better code now as a machine learning engineer and really elevated not just my capability but my passion in coding design. It is really so satisfying to produce lean and efficient code!!!
@asif.haswarey
@asif.haswarey 9 месяцев назад
The 3 ideas: *#1* 4:54 : Group side effects and use pure functions. 8:46 : Functions or methods should have return values that only depend on the input parameters. 9:23 : Functions or methods should return consistent results for their respective input parameters. For example, for function F, input I and output O, i.e. if I = 3 and O = 5, every call to F(3) should produce the output of 5. *#2* 11:18 : Functions are first-class citizens. What can you do with functions? You can compose them, deconstruct them, pass them to other functions (as parameters), and return them as "values" from other functions. Higher-order functions take input parameters as functions and return functions. 14:32 : Partial functional application. Create a new function from an original function with some of the input parameters already applied. Frequent use of this will make the code less readable. *#3* 16:52 : Use immutability to your advantage. In imperative languages (Python), variables can be accessed/changed anytime. Where as, in declarative languages (Excel), variables are generally bound to expressions and keep their value for the entire life of program execution. Immutability helps with resource sharing in use cases which employ concurrency and parallelization. Ref: Concurrency is not Parallelism by Rob Pike. Immutability eases unit testing.
@user-hf5be1zu7s
@user-hf5be1zu7s Год назад
I could have gone out with my friends, but seen you have uploaded so I had to stay and watch. I am so happy I stayed for the video, your content is just golden and your advice is solid. Truly a diamond, I am so happy I came across your channel, It means a lot for me. thank you!
@MrBachianas
@MrBachianas Год назад
Yes! Great stuff. Keep the FP in Python content going, it's almost impossible to find (:
@ArjanCodes
@ArjanCodes Год назад
Thank you MrBachianas, will do!
@JosephLeeHS
@JosephLeeHS Год назад
The `greet_list` method/function can be improved using lazy evaluation, turning it into a generator function with the `names` argument as an Iterable. This is particularly useful if you need to read your names from a large file or database table.
@codewithray
@codewithray Год назад
You are a legend man. Very informative tips. Keep it going !!!
@Celestialzzz
@Celestialzzz Год назад
Another amazing video. Thank you so much for this!
@memsb1
@memsb1 Год назад
Don't let your view count determine your worth. These videos are really valuable to all that watch
@ArjanCodes
@ArjanCodes Год назад
Thanks Marty, happy you’re enjoying the content!
@yeetdeets
@yeetdeets Год назад
F2 allows you to rename all occurrences of a variable within a scope at once. Thus you don't need to rename the uses of the parameter when you rename it.
@golammuhaimeen2825
@golammuhaimeen2825 Год назад
this was such a great demonstration Arjan! Thanks so much! Loved it.
@ArjanCodes
@ArjanCodes Год назад
Thank you Golam, glad you liked the video!
@esteenbrink
@esteenbrink Год назад
Maybe it's just a detail, but when you said using the callable Greeting reader in the greet_list list comprehension, it will call the callable for each instance of the result list which will use different datetime instances.
@tommybrecher7742
@tommybrecher7742 Год назад
Thanks @ArjanCodes, great content as usual.
@ArjanCodes
@ArjanCodes Год назад
Thanks Tommy, happy you’re enjoying the content!
@brothercaleb
@brothercaleb Год назад
Top level stuff. Thanks Arjan! 👏🏽👏🏽👏🏽👏🏽👏🏽
@ArjanCodes
@ArjanCodes Год назад
Thanks so much, Caleb glad the content is helpful!
@molomono9481
@molomono9481 Год назад
First video i watched of yours i had to quit because it was to advanced for me at the time. But still needed to refactor my code so i watched the Code Smells series and it changed the way i program python. After just 2 weeks time my code has had immense progress, in development, maintainability and reusability and that speeds up my overal production time. Huge thanks for all your material, now i am able to follow the more complicated videos as well. I love that the material covered is Theory in Practice, because i've read about polymorphism and hashtables and all kind of datastructures and coding principles. But you just say what it is you are going to do, then show it and explain why with just the right amount of jargon involved for me to go read more about it if i want, but not get distracted or confused. Thank you so much!
@ArjanCodes
@ArjanCodes Год назад
Thank you so much for sharing this! I'm glad that my videos are helpful :)
@Mutual_Information
@Mutual_Information Год назад
Love the topic! If anyone needs evidence that functional programming is a powerful paradigm, consider JAX. JAX is Google’s most recent bet on a neural network framework. It’s their contended with PyTorch and, beyond that, it’s designed to major shortcoming of frameworks in general: speed and reproducibility. And JAX (written in Python) is a effectively all functional programming tool. Everything is a function.
@pro100tom
@pro100tom Год назад
Thank you for the demo, ideas behind functional programming and scenarios when it is feasible to apply it. I have noticed you example about shuffling cards and I still believe mutable approach can be better due to the fact that it is more intuitive for humans - we don't end up with another deck after shuffling. I, myself, try to carefully pick the right tool for the right task. I guess, a good advice for new developers would be not to perceive every problem as nails, when they've discovered a hammer. Great video!
@v0id_d3m0n
@v0id_d3m0n Год назад
Good quote haha
@esiarpze7908
@esiarpze7908 11 месяцев назад
Great video! Just a suggestion - It’d have been nice if you could have run a profiler after every version of code change you made. Maybe in the future ones you can do a performance analysis also side by side.
@kopytko998
@kopytko998 Год назад
Thanks for this video. You are a fantastic teacher.
@ArjanCodes
@ArjanCodes Год назад
Thanks Andrzej, happy you’re enjoying the content!
@cetilly
@cetilly Год назад
This video is SO so so good!!! Thanks Arjan
@ArjanCodes
@ArjanCodes Год назад
Thanks so much Chuck!
@williamduvall3167
@williamduvall3167 Год назад
I am a lone python programmer/environmental engineer with all types of python tools I use day to day. These videos have been the sweet spot to make these tools better. I just became a member, thanks!
@ArjanCodes
@ArjanCodes Год назад
Glad you like the content and thanks for becoming a member!
@rcc420
@rcc420 9 месяцев назад
Hey dude. Thank you very much for the knowledge you drop in this channel. I work as a DevOps engineer and I find your channel super useful in my quest to improve my python skills. You're the best !! Thanks. Keep up the good work and spread the knowledge, so we can all become better engineers. Cheers!
@ArjanCodes
@ArjanCodes 9 месяцев назад
Thank you so much!
@ethanholz3733
@ethanholz3733 Год назад
This is a really cool video, thanks!!!
@jessexing3456
@jessexing3456 Месяц назад
thank you, always learning a lot here
@ArjanCodes
@ArjanCodes Месяц назад
Glad to hear! I'm always happy to be part of people's learning journeys.
@MTT818
@MTT818 Год назад
Thanks Arjan, your videos are very useful.
@ArjanCodes
@ArjanCodes Год назад
Thank you - glad you find the videos useful!
@asdrubalivan18
@asdrubalivan18 Год назад
I'm currently learning Haskell as a way to learn functional programming to apply it to Python and Typescript! This is very useful!
@scotttang6229
@scotttang6229 Год назад
You can use Ramda for JS or Lodash/FP. Those are very good to use with functional pattern with JS/TS. It's a bit more work using those libraries with TS though. But it's very doable.
@ArjanCodes
@ArjanCodes Год назад
Thanks so much, glad it was helpful!
@presstv
@presstv Год назад
this functional programming video is so informative. thanks Arjan
@ArjanCodes
@ArjanCodes Год назад
Thanks so much, glad it was helpful!
@2010edward1978
@2010edward1978 Год назад
Thank you, it was very interesting! Another related topic could be about balancing OOP and FP in Python.
@ArjanCodes
@ArjanCodes Год назад
Thank you Eduard, and great suggestion ;).
@chuxmyk
@chuxmyk Год назад
It’s the Vim extension for me. I love VSCode and Vim and extension gives you the best of both worlds 🔥🔥
@ArjanCodes
@ArjanCodes Год назад
Thanks Chuks, happy you’re enjoying the content!
@marcosdiez7263
@marcosdiez7263 Год назад
Nice explanation. I'm new to Phyton yet experienced in other languages and paradigms (in 35 years or experience I took pride of studying paradigms and trying to combine them). I believe the word you wanted to describe the lack of side effect as a feature is "deterministic", which implies that a function produce the same outcome when given the same parameters. This is used in many declarative and functional languages behind the scene to cache responses and eventually choose between the cost of calling a function again with the same parameters and the cost of storing the response to return it again instead. For instance, Most SQL servers attempt (but may fail) to tell appart deterministic from non deterministic functions to do this and cache functions responses, and in some scenaries involving grouping data and aggregate functions this may lead to unexpected outcomes and to solve them, anti intuitively you need to pass as parameters the colums making an unike key to each row even if the function doesn't use them internally to "couple" your function determinism to the rows for which you expect it to be executed and cached. In the other hand, I believe someone surely implemented the idea of caching function responses in Phyton for high cost algorithms like telling when a number is prime or calculating large factorials, and if not, it'd be a great programming excercise for an application of deferring a function with Callable or another better mean that I suspect may exist and I am still unaware of.
@clementdato6328
@clementdato6328 Год назад
I think side effect also includes cases of mutating states outside of its inputs and outputs and local variables. For example, Python list append always returns None except exceptions. It is “deterministic”, but it is not side-effect-free.
@zl4518
@zl4518 Год назад
I believe there's a cache decorator under the functools module
@fa11en1ce
@fa11en1ce Год назад
Thanks for the great content Arjan. I am kind of appalled at the lack of manners some of the commenters have here. Don't worry about them, and keep up the good work!
@UNgineering
@UNgineering Год назад
Functional programming is not given appropriate attention in schools these days. It is huge for code test-ability. Excellent video as always.
@miniappletheapple
@miniappletheapple Год назад
Great vid, it would be nice if most of OOP programmers know
@AnthonySherritt
@AnthonySherritt Год назад
Love this!
@ArjanCodes
@ArjanCodes Год назад
Thanks Anthony, happy you’re enjoying the content!
@paulbird2772
@paulbird2772 Год назад
The partial function is interesting, would be great to show how using would make some existing code easier to read and or more concise. (probably needs a more complicated example). I can understand what it is doing from your clear explanation, but can't really see why I would need it.
@ian4175
@ian4175 Год назад
I don’t know if this is exactly the same, but I’ve found that partial functions is nice for having a single source of truth (or functionality in this case I guess). I’m my case it was in JS and went something like this: // NOTE: simplified for example (also copying into an IDE will make it easier to read) // most general form of fetching data function runFetch(baseUrl, endpoint, method, params, data) { // makes request to api using inputs } // Used specifically for user data function runUserFetch(endpoint, method, params, data) { return runFetch('userDataApi.com', endpoint , method, params, data) } // Specifically for GETting user data function getUser(endpoint, params) { return runUserFetch(endpoint, 'GET', params, {}) } // Specifically for GETting a users friends function getUserFriends(params) { return getUser('/friends', params) } // Specifically for POSTing user data function postUser(endpoint, params, data) { return runUserFetch(endpoint, 'POST', params, data) } // Specifically for POSTing a users login time function postUserLoginTime(endpoint, params) { return postUser(endpoint, params, { loginTime: Date.now() }) } As you can see with each new, more specific, function we make we reuse the more general form and set some input to a static value. This to me has one major upside, and that is EVERY time we fetch data we end up calling the same function (runFetch) and so now if we want to add something, (like maybe a cache or something), all we have to do is modify that single function to add that new feature. Or if we wanted to debug an issue with data fetching we only have to print out data in one place. TLDR: Starting with a general function, with lots of input options, we create more and more specific functions by calling the general form with some function specific input options. This allows us to have a single source of functionality so that if we ever want to modify that we only have to change one function. PS: This is just what Ive picked up along the way, not saying this is best practice or anything.
@markhathaway9456
@markhathaway9456 Год назад
Excellent example(s). I'd like to see it in Scala too.
@davidsyengo1893
@davidsyengo1893 Год назад
True python guru!
@dmytrokorbanytskyi1586
@dmytrokorbanytskyi1586 Год назад
I really like it, thanks!
@ArjanCodes
@ArjanCodes Год назад
Thanks so much, glad you liked it!
@Han-ve8uh
@Han-ve8uh Год назад
9:24, "functions/methods should return same if parameter values are same". For class methods, what does it mean for self to be the same? Self is something automatically created when we instantiate a class so how to control it repeatably during tests? If i remember right, self causes problems during functools lru_cache too since the user may not be aware self (being part of the cached tuple key) is changing.
@ianbdb7686
@ianbdb7686 Год назад
Question: So if i was making a commercial software where i use the IO package should i override the class and make the output native to the prospective client machine.
@albertjose9654
@albertjose9654 Год назад
Thanks man Great stuff, will you make a video on microservice architechure in python
@ArjanCodes
@ArjanCodes Год назад
Thank you Albert, will do!
@mikec64
@mikec64 Год назад
I really appreciate your videos but I lost the thread here on the value of higher order functions. For me, your example made the syntax clear but the example code became harder to read without any clear advantage. I'm going to watch this a few more times because it feels like an important step for me to learn, but I hope you'll give more time to use cases in the future.
@georgytoporkov2041
@georgytoporkov2041 11 месяцев назад
Great video! I wander whether there's also function composition in Python :D
@oreychandan9229
@oreychandan9229 Год назад
Yo you did it!
@kishorecharandhuli9137
@kishorecharandhuli9137 10 месяцев назад
Excellent….!!!!!!
@ArjanCodes
@ArjanCodes 10 месяцев назад
Thank you! Cheers!
@deepakpune1
@deepakpune1 Год назад
is this similar to separation of concern ?
@abdelghafourfid8216
@abdelghafourfid8216 Год назад
while I do agree that doing immutable operation might simplify the code desing and testing. But in some contexts it may impact the performance, for instance in pandas usually the immutable operations take more time as they require making copies of the dataframe each time. So one sould keep this also in mind.
@user-lk1fw1lp8b
@user-lk1fw1lp8b Год назад
It is not our problem to solve. Languages should be optimised for these scenarios.
@karserasl
@karserasl Год назад
Thats pandas problem. In functional programming, these data structures were rewritten to be efficient, they just keep a copy of things that modified, not the whole structure.
@user-lk1fw1lp8b
@user-lk1fw1lp8b Год назад
@@karserasl object-oriented languages were initially designed for people who coded in C with all of its beatiful features. OO languages came, but the thinking remained imperative.
@pieter5466
@pieter5466 Год назад
What's going on in line 12 `greetings: list[str] = []`, not sure I've seen that before?
@Terroid
@Terroid Год назад
What linter/language server plugin do you use In VSC? It seems to be really strict, I use the Python plugin and pylance, and those 2 aren't so strict like yours What other tools do you use?? Thanks in advance :D
@chinin97
@chinin97 Год назад
Pylance as you but has it on strict mode. He has a video about vs code extensions
@NostraDavid2
@NostraDavid2 Год назад
Can confirm there's a strict mode. Use ctrl-, to open setting and search for "pylance strict" and it should pop up.
@NicholasShanks
@NicholasShanks Год назад
I learnt more about Python than FP from this video. However, I suggest you re-upload this with two edits: only move the current timestamp out of the class; leave the greeting string in there. By moving the greeting string to main() you pollute what should be the 'dirty' function with otherwise pure code. Keep the string code in the lower level functions where they can be easily tested too! Secondly, put your data argument last. You had a function to which you passed a list of names and a greeting or greet_fn - swap the argument order. By having data last, you follow the standard function layout of other languages and codebases which don't have variable argument order.
@DrGreenGiant
@DrGreenGiant Год назад
I feel like you didn't give a fair argument in favour of mutable, only against. Mutable uses much less memory and is much more cache efficient (so faster) than immutable. Which one you choose is of course down to the application constraints. But it's very much worth understanding the disadvantages of immutability. Especially with micropython now being a thing on low memory bare metal processors
@ArjanCodes
@ArjanCodes Год назад
Good point, Simon!
@MMarcuzzo
@MMarcuzzo Год назад
What keyboard shortcuts do you use when typing and editing code?
@NostraDavid2
@NostraDavid2 Год назад
I remember he said that he used the vim extension, but vim is fucking wild compared to most standardized editors (probably because the origins of vim is from before ctrl-c ctrl-v were a thing - in 1969 the Ed editor was created, which spawned Ex, which spawned vi, which spawned vim, which spawned Neovim and the vscode extension)
@NostraDavid2
@NostraDavid2 Год назад
I like using ctrl + left/right arrow to jump over words, which I can combine with shift to make selections. End and Home are nice too.
@MMarcuzzo
@MMarcuzzo Год назад
@@NostraDavid2 I do that a lot. But I want to powerup even more my editing, if possible. If I notice that's not possible on conventional editors, I'll try different ones
@againstthegrain5914
@againstthegrain5914 Год назад
I like this way of coding better.. do you mentor folks?
@dietermenne
@dietermenne 6 месяцев назад
Great content - and I could concentrate much better if there was no background music. So I have to "listen" to the subtitles
@mauisam1
@mauisam1 Год назад
Sorry, I got lost with the Callable decoration and how it works. I looked in you YT for a video on this didn't see one.
@slhcn8609
@slhcn8609 Год назад
Is that a kind of complaint? Who said "Bugger off" to you :) thanks for your efforts!
@gmarcosoldo
@gmarcosoldo Год назад
Great video, but the functions names (greeting_reader, greet, etc) got a bit confusing at time tbh
@v0id_d3m0n
@v0id_d3m0n Год назад
Greet doesn't feel like a word anymore. Greet groot.
@Jedimaster36091
@Jedimaster36091 6 месяцев назад
Somehow, I don't see what the purpose of the Greetings class is, after the changes. It doesn't really do anything useful, just returns the provided greeting_intro. As far as I understand, the whole value of the program was to greet the name based on the time of day.
@edgeeffect
@edgeeffect Год назад
I have to be VERY careful not to commit code with strings like "Bugger off!" in them... every time I push my branch there's a little tingle of fear that I might have "said" something I shouldn't.
@ewerybody
@ewerybody Год назад
Hej Arjan! I generally really like your style and enjoy your videos. But the greeting code example seemed rather artificial. I could see that it all works but the benefits were not clear. I mean it seemed it makes everything much more complicated but for what reason? 😐
@ewerybody
@ewerybody Год назад
Sure testability is most obvious: Maybe show a tiny unittest to make clear that its cumbersome to test for expected output.
@szeredaiakos
@szeredaiakos Год назад
And what are the downsides of working with immutable data?
@weihu-ai
@weihu-ai Год назад
Another takeaway I get from this video is that use meaningful aliases for types in type hints to make the codes more readable.
@weihu-ai
@weihu-ai Год назад
that actually depends. in examples in this video, the argument names already contain information as suggested by the type alias. It might be better to just have the real type in the hint to provide the real signature
@rianderous8761
@rianderous8761 Год назад
But now, when you put the if elif else statement to define the correct greeting in your main or somewhere else outside the class, essential logic that was inside the class is now spread across the application. I can imagine that this is also something to consider? Would a class method be a good option here? Then you know the code belongs to the greeting class
@joansparky4439
@joansparky4439 Год назад
Been programming functional in Python since I started with it in 2008. I preface my variables with their expected types, so I know what I'm dealing with.. str_ , int_ , lst_, los_ (list of strings), lol_ (list of lists), dct_ (dict), FLG_, CNT_, dto_ (datetime object), dts_ (datetime string) The class stuff that comes with python most often is useful. But I myself seem somewhat incapable to create/use it for what I do.. which pretty much boils down to run csv like data conversion/modification and displaying. Nice content.
@ArjanCodes
@ArjanCodes Год назад
Thanks so much, glad you liked it!
@raphaels2103
@raphaels2103 Год назад
Do you continue to do that with type hints?
@joansparky4439
@joansparky4439 Год назад
@@raphaels2103 you mean do I stick with the practice? Yes. It's helpful to me.. so I keep doing it.
@tir0__
@tir0__ Год назад
❤️👌🏻👌🏻👌🏻
@ArjanCodes
@ArjanCodes Год назад
Thanks Priye, happy you’re enjoying the content!
@basedmuslimbooks
@basedmuslimbooks Год назад
@ArjanCodes, do you have a twin who knows rust? 🤭
@avidrucker
@avidrucker Год назад
I'm also interested to know about this "twin" 😂
@edgeeffect
@edgeeffect Год назад
I wouldn't go so far as to say functional is declarative... I'd say it was "closer to" declarative but still imperative.
@johncarlo4028
@johncarlo4028 Год назад
Is it just me or is it true to everyone else that you look like hopper from Stranger Things.
@sparrowhawkguitarboy
@sparrowhawkguitarboy Год назад
I can’t see the video for the most part 😔
@deemon710
@deemon710 Год назад
I tried but I definitely wasn't following along by two thirds of the video.
@ArjanCodes
@ArjanCodes Год назад
Until what part were you able to follow the video? When did things start to get fuzzy? Please let me know as this is very useful feedback for me and I can incorporate that in future videos.
@halfsourlizard9319
@halfsourlizard9319 5 месяцев назад
FP is a way of thinking, not some 'neat tricks'. You can't just add random ideas from FP to imperative code -- that's like adding vegetables to a meat stew and pretending that you're doing anything like cooking vegetarian food.
@epgui
@epgui 9 дней назад
The best thing you can do to improve your python code is to throw it away and try a language that is actually elegant, something like Clojure or Haskell. Yes, there is such a thing as a better language.
@seventeeen29
@seventeeen29 Год назад
Why are you telling people to move complex functionality out of classes? The motivations behind why you're doing this are completely sound but the place where you handle that complex state is a class. That way any dependencies of this functionality can test their own implementations independently to how the shared logic is implemented by replacing the dependency at runtime
@Klej0aka0Klej
@Klej0aka0Klej Год назад
Great video, terrible shirt :)
@ArjanCodes
@ArjanCodes Год назад
In the Star Trek mirror universe, I run a successful fashion channel but I write terrible code.
@cetilly
@cetilly Год назад
The shirt is good 👍🏻
@user-lk1fw1lp8b
@user-lk1fw1lp8b Год назад
After he said "OOP is a subset of imperative programming" I stopped watching immediately. This dude does not even understand what he is talking about. If you can't write declarative OO code it doesn't mean that it is not declarative. What a nonsense.
@muhammadyusoffjamaluddin
@muhammadyusoffjamaluddin Год назад
2:18 Seriously you use Wikipedia?? Sir? Hello?
@ArjanCodes
@ArjanCodes Год назад
Normally the knowledge is injected into my brain via a neural link, but unfortunately the data was corrupt, so I had to use another resource.
@nowyouknow2249
@nowyouknow2249 Год назад
@@ArjanCodes 😆 🤣
@RatafakRatafak
@RatafakRatafak Год назад
Whats wrong with wikipedia?
@MTT818
@MTT818 Год назад
It would be good to stop using print and start using log since we don't use print almost never in production and I guess everyone needs to learn what is used in real world than just practising things they would never/shouldn't use. Please avoid distributing bad practices.
@ArjanCodes
@ArjanCodes Год назад
I have experimented with using logging instead of print and it was confusing to the audience since extra boilerplate is needed to setup logging. I get that using printing as a logging solution is bad practice. But I’d argue that the way I use print is not logging: it’s what the example application actually does.
@avidrucker
@avidrucker Год назад
How about a video just on logging best practices? 👍😁
@Jebusankel
@Jebusankel Год назад
Yet another video that creates a straw man of bad code and calls it OOP and then calls the fixed version functional.
@stevenhe3462
@stevenhe3462 Год назад
This feels like squeezing in functional programming to Python's object oriented environment… The benefits are obvious. But, it feels unnatural. Also, the effort does not produce as elegant code as you get in more functional languages. I'm not saying that this is not good. It is. It is Python itself that is very limiting in this regard. Try to add monads and you'll see…
@ymarinho
@ymarinho Год назад
Arjan I really like your videos for their teaching skills and competence. Congratulations.
@ArjanCodes
@ArjanCodes Год назад
Thanks so much Yves, glad it was helpful!
Далее
This Is Why Python Data Classes Are Awesome
22:19
Просмотров 781 тыс.
Functions vs Classes: When to Use Which and Why?
10:49
Просмотров 133 тыс.
Functional Design Patterns - Scott Wlaschin
1:05:50
Просмотров 288 тыс.
15 Python Libraries You Should Know About
14:54
Просмотров 345 тыс.
Python 3.12 Generics in a Nutshell
6:22
Просмотров 43 тыс.
Protocol Or ABC In Python - When to Use Which One?
23:45
5 Tips for Building Powerful Data Dashboards in Python
19:05