Python OOP Tutorials | Composition and Aggregation
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!
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!!
Great job. Using "has a" and "part of" as a way to reinforce the descriptions of the two different relationships was brilliant.
Man, you are so criminally underrated. This is not fair. Your video was very good.
Thank you for everything, I'm not an expert in English but I understood every word you said, you´re terrific. Greetings from Mexico.
I’ve got an exam soon and this really clarified the differences. Thanks
Very helpful. Thank you. Repeatedly going back and forth in your descriptions helped a lot
Genuinely very helpful video and your way of teaching are superb. You really make me easy to understand. Thanks
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.
Superb Sir... grt8
crystal clear explaination....I want more videos on Python Advanced concept
great vid man! THANK YOU.
I was looking for this😊thank you👍
Thank you for making this video, great explanation and applications of the concepts!
wonderful explanation. Keep it up.
Very Short and clear
Simply great,
Excellent explanation
thank you so much, this is literally good video!
Very clear!!
Thank You So Much Sir. It is a great explanation.
simply and wonderful explanation thank yoy
Thank you SO much
Awesome
thank you
loved ur video from Pakistan😘
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
What if we would like access pay through Employee class? how to do it?
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?
Yes, of course
man I'm confused between composition and dependency, I know they are represented in different ways in UML with different pointers.
How to print pay and bonus
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())
there is a semicolon in aggregation line 13 but still the code working????
it's valid to have it in python code
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
actually I found contradicting info in Google. Please Help
thank you