Understanding Java Composition Part 1

  Рет қаралды 30,944

The Learn Programming Channel

The Learn Programming Channel

Күн бұрын

Java Composition Part 1- From my Complete Java Developer course.

Пікірлер: 42
@FontySchriek
@FontySchriek 6 жыл бұрын
This is an excellent example of Aggregation, not of Composition! In Composition the PC is the owner of its parts (motherboard,case, monitor) to enforce life-long dependency , so the motherboard, case and monitor objects should never exist as stand alone objects outside of the PC object, since this would mean you still would have a reference to them, even if you would mark the PC object for deletion (by setting: thePC = null;)
@missjude01
@missjude01 6 жыл бұрын
so should the motherboard, case and monitor be created inside the PC constructor? or should the tutorial be renamed to aggregration in java?
@muhammedwafa9646
@muhammedwafa9646 4 жыл бұрын
the fun thing is i am taking your course on Udemy and i did not understand it there, then i said maybe i can find anything on youtube that can help, then i found you lol .. the same video that i did not understand earlier.
@bern1223
@bern1223 3 жыл бұрын
You monster. You took one of the greatest IDE's in the world and you put it on light theme! I could hardly recognize it! Great tutorial though.
@karthiknatarajan8990
@karthiknatarajan8990 6 жыл бұрын
but it is aggregation not composition because lifetime of monitor case is not dependent of pc object
@kwabenaampofo5094
@kwabenaampofo5094 2 жыл бұрын
seen other videos on the topic, this has been the best so far. thanks for making this
@SamuelNKiap
@SamuelNKiap 2 жыл бұрын
I enjoyed the tutorial as Aggregation. Composition should have code to create contained object inside the constructor.
@Frazful
@Frazful 7 жыл бұрын
Best video on composition I came across. Subbed, thank you sir!
@inayatullah67
@inayatullah67 2 жыл бұрын
I'm a taking course of yours on udemy and its fantastic.
@bilalrana4863
@bilalrana4863 6 жыл бұрын
Great example to explain Composition Thanks Tim !!
@amirsmair71
@amirsmair71 7 жыл бұрын
finally i understand this concept .. thanks so much
@yamaraahi
@yamaraahi 9 жыл бұрын
.Thank You .You just described a great example greatly but for suggestion, I think it might be better to make it simpler ... I mean do not going too much on details would be better
@milosdjokovic5735
@milosdjokovic5735 6 жыл бұрын
Good job! Very well explained
@anikv25
@anikv25 7 ай бұрын
Thank you!
@deactivisiongames9961
@deactivisiongames9961 6 жыл бұрын
Great work !!!!!
@atomatom4825
@atomatom4825 3 жыл бұрын
Good job
@deactivisiongames9961
@deactivisiongames9961 6 жыл бұрын
Loved your tutorial !!!!!
@mohammadsulaiman2301
@mohammadsulaiman2301 4 жыл бұрын
thanks
@weetyytasdsa3855
@weetyytasdsa3855 5 жыл бұрын
do you make sure this is Composition ? if it compostion why dont you try add line pc = null and see whether or not Case ,Monitor and Motherboard already delete ?
@krishnashakya2858
@krishnashakya2858 4 жыл бұрын
Pretty neat. thank you
@facundocolino5017
@facundocolino5017 5 жыл бұрын
There is something that I can't undestand. For instance if the PC object is composed by a Case object, I think that you should have a new Case() sentence inside the PC constructor. The way you implemented it, creating the Case object in the main and passing the reference to the set method, looks more like aggregation than composition to me.
@mk42948
@mk42948 7 жыл бұрын
Greate, thanks)
@jecksonulloa1174
@jecksonulloa1174 3 жыл бұрын
Thank you!!!
@ckbapps2009
@ckbapps2009 8 жыл бұрын
I have owned the full course... Very depth course.. I have one problem. In Monitor class, in getter method public String getNativeResolution() { return nativeResolution; } It is showing me an error - Incompatible types: Required: Java.lang.String Found: com.Composition.Resolution I am also using same IDE.... Please help
@sovanraksa2112
@sovanraksa2112 6 жыл бұрын
Thank you so much
@rizwandogar9563
@rizwandogar9563 8 жыл бұрын
Hey Awesome man Thanku #Tim
@TheLearnProgrammingChannel
@TheLearnProgrammingChannel 8 жыл бұрын
+Rizwan Dogan Thanks for that :)
@CuteWorld.1
@CuteWorld.1 6 жыл бұрын
thanks a lot
@avi_mukesh
@avi_mukesh 7 жыл бұрын
Thank you so much for this video! Very nicely explained. However, I have one question: where you called the drawPixelAt() method like thePC.getMonitor().drawPixelAt(x,y,""), this does the same thing as theMonitor.drawPixelAt(x,y,""). Why is the previous way better? Is it simply so you only have to remember the name of the PC object?
@niklasmenard4872
@niklasmenard4872 5 жыл бұрын
A few very interesting points made in this video and I like that the computer example is easy to visualize. Maybe next time use less time creating classes and more focus on the subject at hand (what is composition). This is my personal opinion though.
@TheLearnProgrammingChannel
@TheLearnProgrammingChannel 5 жыл бұрын
Thanks for the feedback Niklas :)
@jdfdoyley
@jdfdoyley 8 жыл бұрын
Great tutorial Tim, however, I wanted to know what your reason for using only "getters" as oppose to using both "getters and setters"?
@TheLearnProgrammingChannel
@TheLearnProgrammingChannel 8 жыл бұрын
Thanks Jason. The reason is sometimes you may have a class where you don't want to allow an external class to update fields directly. Think of a bank account for example. You would probably be happy to have a getter to retrieve the balance, but would not want a setter to update the balance directly. You would probably want to only allow the balance to be affected by a particular method that validates the amount passed, logs the transaction, etc.
@prakashale1627
@prakashale1627 8 жыл бұрын
Brilliant tutorial that I have ever watched ! By the way, I got a question, which platform you are using for code, I don't think it is eclipse :)
@TheLearnProgrammingChannel
@TheLearnProgrammingChannel 8 жыл бұрын
Thanks :) It's IntelliJ, the IDE by Jetbrains
@ef28525
@ef28525 6 жыл бұрын
Lately i've been hearing Composition > Inheritance, but i've been having trouble understanding how to build structures so that they avoid inheritance. Can someone give an example of how the vehicle class could be set up as composition instead of inheritance.
@bohdanbrazhynenko9684
@bohdanbrazhynenko9684 2 жыл бұрын
Hi there! Did you find the answer to your question? I am also concerned about this issue(
@RamaKrishna-xp4ju
@RamaKrishna-xp4ju 8 жыл бұрын
Great Video .. Can I know any videos on jsp
@TheLearnProgrammingChannel
@TheLearnProgrammingChannel 8 жыл бұрын
+Rama Krishna I dont, sorry.
@irasemaangeles9035
@irasemaangeles9035 6 жыл бұрын
Aggregation please!!
@TheKarl321
@TheKarl321 8 жыл бұрын
can't believe i baught the course from udemy
@TheLearnProgrammingChannel
@TheLearnProgrammingChannel 8 жыл бұрын
+Karl Samaha You are enjoying the course on udemy? This is one of the 100+ videos on udemy for this course.
Understanding Java Composition Part 2 - Includes a Challenge
14:15
The Learn Programming Channel
Рет қаралды 7 М.
OOP Principles: Composition vs Inheritance
15:38
Dave Crabbe
Рет қаралды 51 М.
escape in roblox in real life
00:13
Kan Andrey
Рет қаралды 15 МЛН
Men Vs Women Survive The Wilderness For $500,000
31:48
MrBeast
Рет қаралды 59 МЛН
He bought this so I can drive too🥹😭 #tiktok #elsarca
00:22
Elsa Arca
Рет қаралды 45 МЛН
Generics In Java - Full Simple Tutorial
17:34
Coding with John
Рет қаралды 1 МЛН
What is JSON ?
11:56
Telusko
Рет қаралды 1,1 МЛН
019 Favour Composition over Inheritance
8:49
maysam pasokh
Рет қаралды 15 М.
Learn Java Programming - Composition Tutorial
8:15
Daniel Ross
Рет қаралды 8 М.
Learn SOLID Principles with CLEAN CODE Examples
28:35
Amigoscode
Рет қаралды 270 М.
All useEffect Mistakes Every Junior React Developer Makes
22:23
Primitive and Reference (Object) Types in Memory (Java Tutorial)
5:12
escape in roblox in real life
00:13
Kan Andrey
Рет қаралды 15 МЛН