Ep13 - OOP vs Functional vs Procedural Programming Explained!

Поделиться
HTML-код
  • Опубликовано: 10 дек 2024

Комментарии • 73

  • @angurishudesu
    @angurishudesu 2 года назад +34

    Notes for myself:
    Procedura Programmingl:
    - Step by step instructions for tasks in sequential order.
    - Simple but has shortcomings; verbose, illegible, lengthy.
    - Hard to re-use the same code since you'd have to copy and paste.
    Object Oriented Programming:
    - Everything is based on objects, it delegates tasks into smaller chunks and put them into entities known as objects (this hides the logic in the objects); this concept known as encapsulation.
    - Easily reusable & maintainable since if something breaks, it's easier to find which object is breaking the program, as opposed to procedural where you'd have to find which line of code is breaking the program.
    - By hiding logic, we can abstract the complicated logic and only worry about how you interact with the objects, increasing readability.
    Functional Programming:
    - Functional programming DESCRIBES the logic using functions. To my understanding, the difference between OOP & FP is that OOP can abstract (hide) the logic, whereas FP presents the logic laid out as functions.
    - Everything relies on functions. It creates meaningful functions so that the code would be succinct, clearer and cleaner.
    - It's a very declaritive paradigm since it writes in pure functions; thus by reading the code you'll relatively easily understand the programmers intention
    Important notes:
    - An object is a collection of functions and data. A function is a collection of commands and data.
    - When a bunch of functions work together to perform a certain task we can call it an object.

    • @MaipuruSyrup
      @MaipuruSyrup 2 года назад +3

      Do you write all of your notes as video comments?

    • @angurishudesu
      @angurishudesu 2 года назад +13

      @@MaipuruSyrup No no I use notion, but I put it here because I thought it might be useful for others

    • @passportbro904
      @passportbro904 2 года назад +2

      Shane, as a newbie I wanna say thank you and I hope we all become bad asses at this 👊🏾

    • @tropicarls
      @tropicarls Год назад +1

      @@angurishudesu based

    • @williammbollombassy1778
      @williammbollombassy1778 Год назад

      So what difference between procedural and imperative programming

  • @herseem
    @herseem 2 года назад +28

    At first I thought, "Hallelujah! He's actually going to give us some code examples of the differences". But then you spoiled it by not doing equivalents of exactly the same thing. It would have been much more helpful if you'd given the same real-world practical example in both procedural and object-oriented code, such as how to input the record of a new gym membership, for example

    • @redpiller1099
      @redpiller1099 Год назад +3

      Exactly my thoughts he complicated it by using different examples. Also it would have been nice to explain what a paradigm is.

    • @insidiousmaximus
      @insidiousmaximus 6 месяцев назад +2

      @@redpiller1099 not all content is for beginners, this video is for programmers we do not need examples we know what he is talking about.

  • @kaptenadhoc
    @kaptenadhoc 2 года назад +6

    A better way to go about explaining this taxonomy would have been to say that procedural programming uses function calls rather than just doing everything inline (which would be referred to as an imperative style), and that functional programming expands on this by introducing concepts such as side effects, pure functions, higher-order functions etc.
    The two families at the top are imperative and procedural. Object oriented (not "orientated") and functional are offshoots from procedural. Purely imperative is not really a thing any more (luckily) and with a little luck we'll stop clinging to OO as well.
    For anyone who still clings to OO, I highly recommend Brian Wills videos on the topic.

  • @charg1nmalaz0r51
    @charg1nmalaz0r51 Год назад +6

    I never get the idea between this stuff. Because for example in the functional example its still using the stuff you claimed to be OOP. And OOP is using procedural stuff. It always appers that there is no clear line between this stuff and people are essentially just being pedantic about things. Maybe i am wrong

    • @pdd5793
      @pdd5793 5 месяцев назад

      short answer: OOP is about different objects communicating only necessary information with each other, while maintaining some privacy for themselves; FP is about being able to trace back everything that happens in the program by making functions that don't change anything outside of their scope with the exception of returning values; PP... I don't really know the major difference between PP and the other ones, just that it is basically the one concerned about the program itself lol.

  • @chrisklest1238
    @chrisklest1238 Год назад +3

    So, is the difference just an added layer of abstraction? For instance, in procedural programming: for(a = 1; a < 5; a++){write-host a}. In functional programming, you encapsulate that loop in a function and make a function call - Increase(a), and in object-oriented languages, you take that same loop, and attach it as a method of an object, like DoLotsOfStuff.Increase(a)?

    • @grawss
      @grawss Год назад +1

      Yep.
      Functions are the new "goto."
      Objects are "goto" with a dict.

  • @kamogelokhumalo4792
    @kamogelokhumalo4792 3 года назад +24

    Wow that explanation was just too perfect for a beginner like me. Thank you. I have subscribed and I can't wait to learn more from your channel. Thank you once again :)

    • @Acadeaio
      @Acadeaio  3 года назад +2

      Welcome aboard! Looking forward to seeing you around here. Here's the full playlist of this series: ruclips.net/video/FNh2JCiFXIg/видео.html
      Hope you'll enjoy and any feedback is much appreciated!

    • @raconvid6521
      @raconvid6521 3 года назад

      I little tooo perfect.

  • @zeroskillgaming1203
    @zeroskillgaming1203 3 года назад +12

    Procedural code contains functions and is usually much shorter that object orientated programming

    • @Acadeaio
      @Acadeaio  3 года назад +2

      Good point, but shorter or not, it really depends on the developer and the design patterns/architecture

  • @wire_head10
    @wire_head10 3 года назад +1

    Best explanation I've seen on YT!

    • @Acadeaio
      @Acadeaio  3 года назад +1

      Thanks a lot Eli! Glad it helped!

  • @lf00t
    @lf00t Год назад +1

    I don't understand.
    In OOP you you call the log method inside the console object. "console.log()"
    Im FP you call the map() method which is inside the array object
    Where's the difference?

  • @ayotomiwasalau6373
    @ayotomiwasalau6373 2 года назад +6

    Awesome. Thanks for clear and concise explanation.

    • @Acadeaio
      @Acadeaio  2 года назад

      You're welcome! Glad it was helpful

  • @ryszardk2534
    @ryszardk2534 3 года назад +4

    Very clearly explained, liked and subscribed!

    • @Acadeaio
      @Acadeaio  3 года назад

      Thanks and welcome!

  • @oodeveloper4230
    @oodeveloper4230 3 года назад +4

    Procedural is not writing code line by line, but is writing code as a procedure (functions), and I'm stopping here...

    • @Acadeaio
      @Acadeaio  3 года назад

      Thanks for pointing that out, for me procedural programming is similar to writing step by step instructions / procedures :) You're free to think of it as anything that you like, as long as it makes sense.

    • @oodeveloper4230
      @oodeveloper4230 3 года назад +1

      @@Acadeaio Also with OOP you write code step by step.
      With procedural you don't write code like assembler (your first example) but you use functions to wrap small tasks as you do in OOP as well where you use methods instead of functions (the are the same thing.)

    • @kaptenadhoc
      @kaptenadhoc 2 года назад +2

      Exactly. A better way to go about explaining would have been to say that procedural programming uses function calls rather than just doing everything inline (which could be referred to as an imperative style), and that functional programming expands on this by introducing concepts such as side effects, pure functions, higher-order functions etc.
      The two families at the top are imperative and procedural. Object oriented (not "orientated") and functional are offshoots from procedural. Purely imperative is not really a thing any more (luckily) and with a little luck we'll stop clinging to OO as well.

  • @unitydev457
    @unitydev457 Год назад +1

    In your example of FP at the bottom, aren't you also showcasing the strengths of OOP? .map and .filter are encapsulating the same logic as your for loop method into some syntactic sugar. The same way you would hide that logic using OOP into either an ArrayFilter object or perhaps an extension method/utility class that extends the array datatype?
    This is part of why I find it hard to grasp why people often rally for FP and disparage OOP because in my mind they're both trying to solve the problem of encapsulating more complex logic and making more readable and easier to write code, no?

  • @phonesj3422
    @phonesj3422 2 года назад +2

    Thank you !
    Those examples are really easy to know and to the point !

  • @PixelOutlaw
    @PixelOutlaw Месяц назад

    There are way more than three types of paradigm. You need some experience in different languages like Prolog, Forth, Smalltalk, Lisp, SQL and more. Procedural code didn't lead to object-oriented programming directly. It led to what was known as Structured Programming which addressed the issues inherent and Unstructured Programming. Procedural code is the opposite of Declarative code. And there are shades of gray in between. Object-oriented programming is such an overloaded term that is has lost almost all meaning. Different languages have very different object systems but you have to move out of the Java and C++ world to see it. CLOS in Lisp and Smalltalk's message passing would be good for you to experience. OOP doesn't require you to hide logic in objects. It simply requires that objects consist of attributes instead of working in something like parallel arrays with an index. JavaScript has elements of all of these because all of these things are styles to work within a programming language not things that define a programming language.

  • @jyotiamkar2016
    @jyotiamkar2016 2 года назад

    Now I am able to understand these paradigms. Thanks a lot brother ❤️❤️. Keep up the good work.

  • @ekkamailax
    @ekkamailax 3 года назад +4

    Good explanation. Question - doesn’t functional programming and OOP exist together? For example “fruits.map” uses OOP because “map” is a member function of the Array class.
    Also, Class methods can use functional style programming for their function bodies

    • @Acadeaio
      @Acadeaio  3 года назад +2

      Yes you are right. At the end of the day, FP and OOP are just programming styles/techniques. How your code will look like in the end is the one that makes the difference. Even though "map" is a (prototype) method of Array, it uses functional techniques and therefore we get the behaviour of functional programming. There is nothing wrong to use functional techniques in OOP/procedural and vice versa. In language like JS you will see a lot of overlapping areas between both styles. One thing to note here is JS is based on neither OOP nor FP nor procedural, it is a prototypical language, and it supports OOP and FP programming styles.

    • @TanigaDanae
      @TanigaDanae 3 года назад

      The map function is part of the JavaScript array and shortens the code. You could actually implement your own objectless "array := map(array, function)" function to make this more functional.

    • @emreaka3965
      @emreaka3965 2 года назад

      indeed

  • @Jezy258
    @Jezy258 2 года назад

    Great information! I had trouble seeing your screen however

    • @Acadeaio
      @Acadeaio  2 года назад

      Oh no, sorry to hear that, was it too small for you?

  • @hexerei02021
    @hexerei02021 2 года назад +1

    Isn't everything in programming written as step by step instructions?

    • @Acadeaio
      @Acadeaio  2 года назад

      technically yes, but the notion it is about how the code reads at a high level. At the fundamental level, everything is written as step by step instructions.

  • @atmanvisual190
    @atmanvisual190 3 года назад +8

    Straight to the point. Thank you.

  • @Bhishma68
    @Bhishma68 3 года назад +1

    i wish my university mam could teach like this

  • @xiaolinghe4314
    @xiaolinghe4314 2 года назад

    The point of functional programming is not to have it "look like English"(Also personal opinion is functional code doesn't really look like English). It has characteristics that imperative programming doesn't have, for example values can't be modified, which is nice in a sense.

    • @Chilli_Tea
      @Chilli_Tea 2 месяца назад

      Agree. Depends on the language. I have to code in Scala and I don't think that looks like English at all lmao

  • @MrSpyTubes
    @MrSpyTubes 2 года назад +2

    I believe that functional programming was invented before object oriented

  • @compilerrun5516
    @compilerrun5516 3 года назад +5

    I just found gold.

  • @fadhilh3931
    @fadhilh3931 3 года назад +2

    Thank you for the explanation 👍🏻

    • @Acadeaio
      @Acadeaio  3 года назад

      Glad it was helpful!

  • @shakilthakur2674
    @shakilthakur2674 Год назад

    amazing explanation.

  • @meditataor
    @meditataor 4 месяца назад

    nicely explained

  • @alexkotusenko
    @alexkotusenko 2 месяца назад

    Amazing video thank you

  • @rekan_98
    @rekan_98 2 года назад

    is php and mysql Pop or OOP ?

  • @gymgeek6833
    @gymgeek6833 3 года назад

    You’re a great teacher and you explain things in an extremely clear and easy to understand way. Thank you for your time. You deserve millions of views, millions of likes and millions of subscribers. Unfortunately the youth of today would rather watch pointless, braining numbing content. Instead of using their time constructively and learning a fun and powerful skill set, such as programming 🙏

    • @Acadeaio
      @Acadeaio  3 года назад

      Thank you for the kind comment, it means a lot to me. I really do appreciate it! Please share my videos around if you can, it will really help me out!

  • @MahmudHasan-rc1rw
    @MahmudHasan-rc1rw Год назад

    C programming language have functions, then why it isnt called a functional programming language?? or why it can not be used in functional way??

  • @zyggzag4154
    @zyggzag4154 2 года назад

    how do you type so fast????????????????? Please thats the most i want to know from this video!

  • @sandmann6851
    @sandmann6851 3 года назад +1

    Wonderfull! Thank you!

  • @zeynepbetulkaya3645
    @zeynepbetulkaya3645 3 года назад

    Thank you!

  • @darrenbreydsor5604
    @darrenbreydsor5604 9 месяцев назад

    The definition of Procedural Programming is wrong here: Writing or using an API to handle persistent objects / tables, and using functions are part of procedural. It only becomes non procedural when you introduce restrictions like only using instances of classes, or having no side effects. Everything else is procedural. Otherwise the linux kernal and all software before Java would contain no function definitions.

  • @mirlamontano6640
    @mirlamontano6640 Год назад

    good video

  • @Jeetz
    @Jeetz 3 года назад

    Well explained thank you

    • @Acadeaio
      @Acadeaio  3 года назад

      Glad it was helpful!

  • @ivanshatrov3
    @ivanshatrov3 2 года назад

    Console is not provided by JS. It's either provided by browser as WebAPI or by Nodejs.

    • @Acadeaio
      @Acadeaio  2 года назад

      That's correct :)

  • @sawilliams
    @sawilliams 2 года назад

    the functional programing is using oop...array.map...

  • @tello9504
    @tello9504 3 года назад

    Qué buen canal!!!

  • @malcorub
    @malcorub 2 года назад

    Ewwww, durian fruit LOL

  • @alphayowakarindi
    @alphayowakarindi 2 года назад

    Thank you!