Is Golang Object Oriented!? (OOP)

Sdílet
Vložit
  • čas přidán 25. 11. 2021
  • Is Golang Object Oriented!? (OOP)
    In today's Golang video, we will talk about the reasons why and how Go is not an object oriented programming language. We will go through why OOP is invented, its 4 main features, problems with OOP, and how Go programming language's solve its OOP problem. Enjoy!
    --
    Golang Dojo is all about becoming Golang Ninjas together. You can expect all kinds of Golang tutorials, news, tips & tricks, and my daily struggles as a Golang developer. Make sure to subscribe if you look forward to such content!
    Get Your Golang Cheat Sheet! - golangdojo.com/cheatsheet
    Git repos & notes - golangdojo.com/resources
    Golang Informative - • How much do Golang dev...
    --
    #golang #goprogramming #golangdojo
  • Věda a technologie

Komentáře • 57

  • @GolangDojo
    @GolangDojo  Před 2 lety +5

    📝Get your *FREE Golang Cheat Sheet* -
    golangdojo.com/cheatsheet

  • @aaron_journey
    @aaron_journey Před 2 lety +35

    I'm converting my project from Python to GoLang. It was great experience. Thanks for such a great video!

    • @edboss36
      @edboss36 Před 2 lety +3

      To make it faster?

    • @GolangDojo
      @GolangDojo  Před 2 lety +2

      Glad you liked it!

    • @74Bagas
      @74Bagas Před rokem +4

      imagine, me from nodejs... delicious

  • @AndrewErwin73
    @AndrewErwin73 Před rokem +3

    So, I get into the discussions a lot. The problem with inheritance isn't inheritance itself, but the fact that is so often misused (and indeed misunderstood). Full disclosure, I am primarily an OOP developer, I just think in objects. I really like your point about duck typing, and I think if more people understood that idea, inheritance wouldn't get such a bad wrap.
    Example... take the super class A. It has a set of functions that are useful for other things. But it IS a thing. If you decide to inherit from A (class B extends A), the very first question you should ask is "is B an A?"... the problem is that a lot of people (anecdotally speaking for myself and 20+ years of experience) might look at the methods within A and say "yeah, that is what I want to do". This is NOT a good reason to inherit from that class. I have seen it so many times. And where you run into problems is when something DOES change with class A!, It will generally not (assuming the overall architecture is good in the first place) affect subclasses that ARE an A! What it WILL affect (and usually adversely) is a random class that just wanted to use the functions that already existed within A (but that are not As themselves).
    So, I do love the duck method you refer to. I think that should be the rule in OOP (not just with inheritance, but with interfaces and polymorphism in general as well).
    Thanks for the video. I am getting deeper into Go and find your content very useful.

  • @yoda-of-soda
    @yoda-of-soda Před 2 lety +8

    In 6:26 you don't need to include the "super struct" as a variable just remove "human" from line 13 and the struct is "inherited"

  • @blenderpanzi
    @blenderpanzi Před 2 lety +5

    As I learned it at uni, inheritance is not a necessary part of OOP, subtyping is. It is often conflated in many programming languages, but doesn't have to be. Inheritance is basically about code reuse, subtyping is about a more formal relationship between types, see the Liskov substitution principle.

  • @thanhtupham4726
    @thanhtupham4726 Před 2 lety +10

    i've always presume that OOP is a must in any programming languages. Go is like a whole new world to me

    • @GolangDojo
      @GolangDojo  Před 2 lety +3

      Same with me at first!

    • @manpt123
      @manpt123 Před rokem +2

      whole new world because you are a self learner programmer. Golang is just like c which is the basic of all programming language.

  • @cs_student1094
    @cs_student1094 Před 8 měsíci +1

    Encapsulation is not about making some data private , this is called data hiding.
    Encapsulation as defined in the object oriented through process book is about making data and behaviors ( methods ) into a single unit

  • @vanjazed7021
    @vanjazed7021 Před 2 lety +2

    8:10 it is a state of mind. GO does lack subtyping via class inheritance but composition over inheritance is a thing in Java, C# etc. and is actually prefered. Class inheritance is still useful when you want to hide some library/framework glue inside base class, but it can be achieved in other ways.
    I like GO, but languages like C#, Scala, Python, etc. happily mix OOP, procedural, functional and work just fine.

  • @esra_erimez
    @esra_erimez Před 2 lety +1

    What you said at 8:05 simply cannot be overstated!

  • @Serpiall
    @Serpiall Před 2 lety +1

    Nice video dude. really well produced and answered the questions I had

  • @sigreer83
    @sigreer83 Před 2 lety +4

    Really enjoying the vids. Many thanks!

  • @softwarearchitect9171
    @softwarearchitect9171 Před 2 lety +6

    Could you please make a video about Golang modules, thank you.

    • @GolangDojo
      @GolangDojo  Před 2 lety +2

      In the pipeline!

    • @flexairz
      @flexairz Před 2 lety

      @@GolangDojo Interfaces also please...

  • @angeldev96
    @angeldev96 Před 2 lety +1

    This is my favorite channel of golang content.

  • @justellvonk2518
    @justellvonk2518 Před 2 lety

    Thank you soo much for this!

  • @abubelal2553
    @abubelal2553 Před 2 lety +4

    You mentioned in oop one danger with inheritance is changing a super class method causing breaking changes. How does go solve this issue? Based on composition the same problem exists?

    • @ZamaaN
      @ZamaaN Před 2 lety +1

      if chnage means renaming identifiers to you, then good luck to you...

    • @abubelal2553
      @abubelal2553 Před 2 lety +2

      @@ZamaaN I was hoping someone with experience would answer but thanks for your comment anyway.

    • @GolangDojo
      @GolangDojo  Před 2 lety +3

      I will make a more example focused video soon!

  • @faldikn
    @faldikn Před 2 lety +2

    Can u make video about Go packages? Best go packages or most useful

  • @joshi1q2w3e
    @joshi1q2w3e Před 10 měsíci +1

    So I still don’t understand, if you don’t use OOP in Go what do you use?
    I’m still a noob so don’t know everything.

    • @fabricehategekimana5350
      @fabricehategekimana5350 Před 9 měsíci +1

      Tbh not everything need to be put in a case. Now some languages are build with a specific goal and take the functionalities of paradigms (like OOP, FP, concurent, parallelism, procedural, ...) without taking everything to achieve the said goal. There are for instance, Go, Rust, Nim that do so

  • @TJ-wc3iq
    @TJ-wc3iq Před 2 lety +3

    That is something I'm interested in 🤗

  • @denilbhatt1005
    @denilbhatt1005 Před 2 lety +6

    Yes surely need a deeper understanding of Interfaces please..!!

  • @aashishupadhyay5566
    @aashishupadhyay5566 Před rokem +1

    programming or hooogramming?

  • @kaushik5055
    @kaushik5055 Před 2 lety +1

    👍

  • @Jediahgames
    @Jediahgames Před 8 měsíci

    I'm learning Go for a college assignment and I've been liking most of it but the OOP-like stuff is so damn verbose and overly complex
    Also I don't understand the problem you mentioned with inheritance in OOP languages, seems like a non-issue, just don't put errors in the base class??

  • @danikingrd
    @danikingrd Před 2 lety +4

    Let’s get rusty guys

  • @Dev_Everything
    @Dev_Everything Před rokem +2

    I stopped using GO for this reason. Its fine for little projects but designing anything substantial it quickly becomes a mess. I am actually in the process of converting everything to C++

  • @rumpeldrump
    @rumpeldrump Před 2 lety +4

    I think that's a mistake by yours. You think OOP ist class oriented. But that's not true. Alan Kay's definition here: “1. Everything is an object, 2. Objects communicate by sending and receiving messages (in terms of objects), 3. Objects have their own memory (in terms of objects), 4. Every object is an instance of a class (which must be an object), 5. The class holds the shared behavior for its instances (in the form of objects in a program list), 6. To eval a program list, control is passed to the first object and the remainder is treated as its message”

    • @GolangDojo
      @GolangDojo  Před 2 lety +4

      What do you mean by class oriented? Thank you for the comment!

    • @rumpeldrump
      @rumpeldrump Před 2 lety +1

      @@GolangDojo I think that OOP is equated with the c++ family. There are some people who say Java is not OOP, as it only allows single inheritance.

    • @ZamaaN
      @ZamaaN Před 2 lety +1

      @@rumpeldrump lol, who says that? Java supports all types of inheritance. study well before talk...

    • @DroidZed
      @DroidZed Před 2 lety +3

      @@ZamaaN He meant Java does not support multiple inheritance between regular classes , but that can be compensated with multiple inheritance between interfaces...

    • @rumpeldrump
      @rumpeldrump Před 2 lety +4

      @@ZamaaNthat would look good on you too. Java has no multi inheritance and use primitive types. And don't tell me about interfaces. Implementing is not the same as extending.

  • @KimberlyWilliamsch
    @KimberlyWilliamsch Před 4 měsíci

    Is golang OOP?

  • @MarcosVMSoares
    @MarcosVMSoares Před 2 lety

    OOP can't be but funcional its a joke hahahaa without having map, filter and reduce ^^

  • @parlor3115
    @parlor3115 Před rokem

    No Go is crap-oriented. I can't believe no other GC-based language have attempted to do what Go did before, which is compile to native code directly. There are efforts in this direction in .NET but honestly, it's late with modest results

    • @fabricehategekimana5350
      @fabricehategekimana5350 Před 9 měsíci

      Why ? Go learned from his predecessors and have modern features without keeping the heavy old features. It will be a winner in the long run