Python OOP Tutorials | Composition and Aggregation

Sdílet
Vložit
  • čas přidán 4. 07. 2024
  • In this Python Tutorial for Beginners video I am going to show How to use Class Composition in Python. Composition allows us to delegate some responsibility from one class to another class.
    In Class Composition one class acts like a Container and other acts like a content. Composition represents "part-of" relationship.When there is a composition between two Python classes , the content object cannot exist without the container object.
    In this Python Tutorial for Beginners video I am going to show How to use Class Aggregation in Python. Also I am going to give the Difference between Aggregation and Composition with a python example.Aggregation represents Has-A relationship.
    Aggregation has a unidirectional association i.e. a one way relationship between associated classes.In Aggregation, both the associate class objects can survive individually.
    #PythonTutorialforBeginners #ProgrammingKnowledge #LearnPython #PythonCourse #Python #Python3
    ★★★Top Online Courses From ProgrammingKnowledge ★★★
    Python Programming Course ➡️ bit.ly/2vsuMaS ⚫️ bit.ly/2GOaeQB
    Java Programming Course ➡️ bit.ly/2GEfQMf ⚫️ bit.ly/2Vvjy4a
    Bash Shell Scripting Course ➡️ bit.ly/2DBVF0C ⚫️ bit.ly/2UM06vF
    Linux Command Line Tutorials ➡️ bit.ly/2IXuil0 ⚫️ bit.ly/2IXukt8
    C Programming Course ➡️ bit.ly/2GQCiD1 ⚫️ bit.ly/2ZGN6ej
    C++ Programming Course ➡️ bit.ly/2V4oEVJ ⚫️ bit.ly/2XMvqMs
    PHP Programming Course ➡️ bit.ly/2XP71WH ⚫️ bit.ly/2vs3od6
    Android Development Course ➡️ bit.ly/2UHih5H ⚫️ bit.ly/2IMhVci
    C# Programming Course ➡️ bit.ly/2Vr7HEl ⚫️ bit.ly/2W6RXTU
    JavaFx Programming Course ➡️ bit.ly/2XMvZWA ⚫️ bit.ly/2V2CoAi
    NodeJs Programming Course ➡️ bit.ly/2GPg7gA ⚫️ bit.ly/2GQYTQ2
    Jenkins Course For Developers and DevOps ➡️ bit.ly/2Wd4l4W ⚫️ bit.ly/2J1B1ug
    Scala Programming Tutorial Course ➡️ bit.ly/2PysyA4 ⚫️ bit.ly/2PCaVj2
    Bootstrap Responsive Web Design Tutorial ➡️ bit.ly/2DFQ2yC ⚫️ bit.ly/2VoJWwH
    MongoDB Tutorial Course ➡️ bit.ly/2LaCJfP ⚫️ bit.ly/2WaI7Ap
    QT C++ GUI Tutorial For Beginners ➡️ bit.ly/2vwqHSZ
    ★★★ Online Courses to learn ★★★
    Get 2 FREE Months of Unlimited Classes from skillshare - skillshare.eqcm.net/r1KEj
    Data Science - bit.ly/2lD9h5L | bit.ly/2lI8wIl
    Machine Learning - bit.ly/2WGGQpb | bit.ly/2GghLXX
    Artificial Intelligence - bit.ly/2lYqaYx | bit.ly/2NmaPya
    MERN Stack E-Degree Program - bit.ly/2kx2NFe | bit.ly/2lWj4no
    DevOps E-degree - bit.ly/2k1PwUQ | bit.ly/2k8Ypfy
    Data Analytics with R - bit.ly/2lBKqz8 | bit.ly/2lAjos3
    AWS Certification Training - bit.ly/2kmLtTu | bit.ly/2lAkQL1
    Projects in Java - bit.ly/2kzn25d | bit.ly/2lBMffs
    Machine Learning With TensorFlow - bit.ly/2m1z3AF | bit.ly/2lBMhnA
    Angular 8 - Complete Essential Guide - bit.ly/2lYvYRP
    Kotlin Android Development Masterclass - bit.ly/2GcblsI
    Learn iOS Programming Building Advance Projects - bit.ly/2kyX7ue
    ★★★ Follow ★★★
    My Website - www.codebind.com
    DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!

Komentáře • 36

  • @Christina__V
    @Christina__V Před 2 lety +13

    I dont know who you are, but I hope you're doing well.
    This is the best beginner friendly explanation I've seen BY FAR and you're a real lifesaver.
    THANK YOU!!

  • @rantalbott6963
    @rantalbott6963 Před 6 měsíci +1

    Great job. Using "has a" and "part of" as a way to reinforce the descriptions of the two different relationships was brilliant.

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

    Man, you are so criminally underrated. This is not fair. Your video was very good.

  • @luispacheco9078
    @luispacheco9078 Před rokem +1

    Thank you for everything, I'm not an expert in English but I understood every word you said, you´re terrific. Greetings from Mexico.

  • @Playmade-
    @Playmade- Před 25 dny

    I’ve got an exam soon and this really clarified the differences. Thanks

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

    Very helpful. Thank you. Repeatedly going back and forth in your descriptions helped a lot

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

    Genuinely very helpful video and your way of teaching are superb. You really make me easy to understand. Thanks

  • @alexl4447
    @alexl4447 Před rokem

    Thank you for this practicaly explanation. I understood composition and agregation before, but you explained it here so detailed - I never thought about the three diffrent charakteristics of them.

  • @shamiqureshi7991
    @shamiqureshi7991 Před 3 lety +1

    Superb Sir... grt8
    crystal clear explaination....I want more videos on Python Advanced concept

  • @sumayyakamal8857
    @sumayyakamal8857 Před 3 lety

    great vid man! THANK YOU.

  • @arpitagec9
    @arpitagec9 Před 4 lety

    I was looking for this😊thank you👍

  • @azzamjoy9053
    @azzamjoy9053 Před 2 lety

    Thank you for making this video, great explanation and applications of the concepts!

  • @SuperSandman1995
    @SuperSandman1995 Před 3 lety

    wonderful explanation. Keep it up.

  • @ankitkumaryadav562
    @ankitkumaryadav562 Před 3 lety

    Very Short and clear

  • @muzammilrizvi6424
    @muzammilrizvi6424 Před 2 lety

    Simply great,

  • @josephjabin
    @josephjabin Před 2 lety

    Excellent explanation

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

    thank you so much, this is literally good video!

  • @pyopin2049
    @pyopin2049 Před rokem

    Very clear!!

  • @ArhamKhan05
    @ArhamKhan05 Před měsícem

    Thank You So Much Sir. It is a great explanation.

  • @user-of2wr4js6h
    @user-of2wr4js6h Před 4 měsíci

    simply and wonderful explanation thank yoy

  • @marthanelis225
    @marthanelis225 Před rokem

    Thank you SO much

  • @vedantbhagat5721
    @vedantbhagat5721 Před 4 lety

    Awesome

  • @helenasdiaries515
    @helenasdiaries515 Před 2 lety

    thank you

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

    loved ur video from Pakistan😘

  • @leopoje
    @leopoje Před rokem

    Please note that I followed the same example code and I am getting an error under the total_salary method, and trying to call annual_salary method implemented under the Salary class The exact line is return self.obj_salary.annual_salary(), its expecting a parameter, Its either something changed with latest python release or something.
    mouse over is displaying a hint : Parameter 'self' unfilled

  • @Garczek
    @Garczek Před 10 měsíci

    What if we would like access pay through Employee class? how to do it?

  • @nandinirm2234
    @nandinirm2234 Před 2 lety

    Please anyone answer this ...
    In the above example in aggregation ...inside employee constructor ..instead of writing
    self.obj_salary =salary
    Can we write
    self.salary =salary?

  • @user-dm5qi4nb6l
    @user-dm5qi4nb6l Před 2 lety

    man I'm confused between composition and dependency, I know they are represented in different ways in UML with different pointers.

  • @abdulmunif4073
    @abdulmunif4073 Před 3 lety

    How to print pay and bonus

    • @Ebb0Productions
      @Ebb0Productions Před 2 lety

      you can create "get()" functions within employee._
      class Employee:
      def getPay(self):
      return self.obj_salary.pay
      _then use it like total salary_
      print(emp.obj_salary.getPay())

  • @AayushSharma-sw4tt
    @AayushSharma-sw4tt Před 4 lety +2

    there is a semicolon in aggregation line 13 but still the code working????

    • @dizpers
      @dizpers Před 3 lety

      it's valid to have it in python code

  • @FranEnchufes
    @FranEnchufes Před 2 lety

    8:13
    watch out 👀 *has.a* is Composition, not Aggregation. has.a if you think about it is like part.of
    edit: I am not sure anymore

    • @FranEnchufes
      @FranEnchufes Před 2 lety

      actually I found contradicting info in Google. Please Help

  • @samiboy350
    @samiboy350 Před rokem

    thank you