Adapter Design Pattern

  Рет қаралды 313,762

Derek Banas

Derek Banas

Күн бұрын

Пікірлер: 287
@suman6327
@suman6327 8 жыл бұрын
5 years old video and you r still one of the best when it comes to Java tutors on KZbin !!
@derekbanas
@derekbanas 8 жыл бұрын
Thank you very much :)
@tomatomov9061
@tomatomov9061 5 жыл бұрын
The best tutorials at all ...
@vedantsharma5876
@vedantsharma5876 3 жыл бұрын
10 years and still this is the best playlist I could find on KZbin!
@InsertName74284
@InsertName74284 2 жыл бұрын
make it 10
@derekbanas
@derekbanas 11 жыл бұрын
You're very welcome :) You're right about explaining this topic. I used to teach design patterns to all new programmers at a former employer. I always enjoyed it for some reason.
@JeanMaryBorgella87
@JeanMaryBorgella87 9 жыл бұрын
Sir Derek, A cup of coffee isn't enough to thank you before your videos i was mediocre and now my teacher is telling how good i'm and i know it's your video's effect. I' m ending my bacc and everything become so easy for me. Thanks a lot.
@derekbanas
@derekbanas 9 жыл бұрын
+Jean Mary Borgella Thank you for the nice compliment :) I'm glad that I could help, but your hard work is the reason why you are succeeding!
@derekbanas
@derekbanas 11 жыл бұрын
I'm very happy to hear that I was able to help. You're very welcome
@thtblondasianchick1498
@thtblondasianchick1498 2 жыл бұрын
This is the most clearly articulated explanation of the adaptor pattern I have ever heard. Thank you
@MrGQ
@MrGQ 8 жыл бұрын
Almost every time I need a tutorial on CS related topics, I find one of your videos. I am immediately relived since you are a master, and provide the information in a pristine manner. Thank you for all your time and help!
@derekbanas
@derekbanas 8 жыл бұрын
+Cristobal Gallegos Thank you very much for the nice compliment :)
@BlueOwl2024
@BlueOwl2024 3 жыл бұрын
After 9 years, this video is still the best.
@hunterw287
@hunterw287 5 жыл бұрын
Dude, you are a godsend. Clean, easy to understand implementation. Helped so much with a project I had for school
@derekbanas
@derekbanas 5 жыл бұрын
Thank you very much :) I'm happy I could help
@goddardpk
@goddardpk 11 жыл бұрын
Considering that you have probably explained this hundreds of times, it must be hard not to sound a little like a tour guide. However, thanks for making the effort to share and do such a great job!
@evgeniys3269
@evgeniys3269 10 жыл бұрын
Thank you, it took me an hour and 10 tutorials to make me even more confused. your tutorial was great, I understood everything in 10 minutes. That is Y I also subscribed.
@derekbanas
@derekbanas 10 жыл бұрын
Jack J You're very welcome :) I'm glad that I could help.
@Besiktas7Bjk7
@Besiktas7Bjk7 7 жыл бұрын
This "Like or Hate?" note, which appears in the bottom at some time is just perfect for youtube videos. You make sure to show us a way we can support you if we liked it, but don't waste precious explenation time for that. When ever someone says in the middle of the video "If u liked this video..." I instantly hate this guy. Well done on that one. I always like when i see it.
@derekbanas
@derekbanas 7 жыл бұрын
Thank you very much :) I do my best to not irritate people
@Popexssj
@Popexssj 8 жыл бұрын
You saved my life with your videos. I am totally going to pass my data structures exam tomorrow! And it's all thanks to your videos about patterns!!! *THANKS*!!!
@derekbanas
@derekbanas 8 жыл бұрын
+Popexssj I'm very happy I could help :) Best of luck on your exam
@Popexssj
@Popexssj 8 жыл бұрын
+Derek Banas I just came back from the exam. Thanks to your videos I completely destroyed it and answered all the questions in detail and I am so excited!!! I checked my answers after the exam (they allowed us to keep the question paper) and I am aiming at high 80% or even possibly 90%!!! Again, thank you so much! :)
@derekbanas
@derekbanas 8 жыл бұрын
+Popexssj Great Job! I'm glad I could help :)
@ancientneophyte8322
@ancientneophyte8322 8 жыл бұрын
Derek - You've made this and the other patterns accessible by mortals. Thanks ever so much!
@derekbanas
@derekbanas 8 жыл бұрын
Thank you :) I'm happy I could help
@AlexandreSilva-io6lb
@AlexandreSilva-io6lb 11 жыл бұрын
i'm glad i started looking for design patterns on youtube! This comes in really handy right now, thanks Derek Banas for the great videos!
@AlexandreSilva-io6lb
@AlexandreSilva-io6lb 11 жыл бұрын
Sorry Derek, I forgot to ask.. what would be the difference if this was implemented with class adapter ? Would the adaptee EnemyRobot mandatorily be an interface or could it be just a class ?
@derekbanas
@derekbanas 11 жыл бұрын
I'm sorry, but I'm not understanding the question. Can you give me an example on what you are trying to create?
@AlexandreSilva-io6lb
@AlexandreSilva-io6lb 11 жыл бұрын
Derek Banas First of all thanks for the answer ,I'm just studying for a test not really developing :/ My question is due to the class Adapter, there are class Adapter and object Adapter right ? This example was on object adapter, what would be the differences if we used class Adapter instead ? using multiple inheritance on the Adapter instead of object composition..
@derekbanas
@derekbanas 11 жыл бұрын
Alexandre Silva I'm using composition here because Java doesn't allow for multiple inheritance. I normally default to composition, but that may be because I prefer to use Java over other languages for this type of stuff.
@derekbanas
@derekbanas 12 жыл бұрын
You're very welcome :) I'm very happy to have been of help!
@Mejj
@Mejj 4 жыл бұрын
8 years old and also still one of the best java Lesson about Adapter I found.
@derekbanas
@derekbanas 4 жыл бұрын
Thank you very much :)
@jo3ypx
@jo3ypx 4 жыл бұрын
You seem so comfortable with design patterns, I wish I had that confidence with them because I absolutely hate this and I've been struggling to learn them for years...
@derekbanas
@derekbanas 4 жыл бұрын
Please ask any questions that you have and I'll try to help
@derekbanas
@derekbanas 12 жыл бұрын
Your very welcome :) Have you seen Java Video Tutorial 44, 45, and 46. You can also parse xml with JavaScript and PHP to say the least. I haven't covered that yet I don't think. I plan on redoing the PHP tutorial some day so that it is as good as my java tutorial
@derekbanas
@derekbanas 11 жыл бұрын
"I promise I'm not a robot" - Skynet
@KatrinaFishman
@KatrinaFishman 12 жыл бұрын
I don't know why people don't like this, this is great!
@derekbanas
@derekbanas 12 жыл бұрын
You're very welcome :) I'm glad you are enjoying them
@derekbanas
@derekbanas 12 жыл бұрын
Great! If you can use design patterns that will make you stand out from most programmers
@derekbanas
@derekbanas 11 жыл бұрын
Thank you :) I can promise you that I don't mean to sound condescending. My allergies were probably acting up at the time I made this video. Sorry about that
@derekbanas
@derekbanas 12 жыл бұрын
I'm going to upload an MVC tutorial in a few hours. It should clear everything up. If not, feel free to ask me questions
@derekbanas
@derekbanas 12 жыл бұрын
It is always better to use an interface to lower coupling. Many of the things you see in patterns are there to add future flexibility. Check out my refactoring and object oriented design tutorial to learn more
@derekbanas
@derekbanas 12 жыл бұрын
Thank you very much :) It is just a very niche subject. Most programmers don't use design patterns.
@derekbanas
@derekbanas 12 жыл бұрын
You you can emulate an Interface in JavaScript. You can also sort of implement oop in PHP, but it is kind of like attaching another wheel to a car just to say it is there. In some situations it can seem useful, but I haven't been persuaded to believe this functionality provides benefits near those of true oop languages. I'll explore the topic in depth soon. Thank you for the request :)
@AlberTesla1024
@AlberTesla1024 5 ай бұрын
Thank you so much, the explanation is so clear and concise along with the implementation. I will watch the whole playlist for learning design patterns.
@ryklin1
@ryklin1 7 жыл бұрын
Hi Derek, To fully appreciate the advantages of this design pattern, I believe, it is best to declare the rx7Tank as an EnemyAttacker rather than EnemyTank. This way, the base pointer is the same for the robot and the tank.
@AlanMeile
@AlanMeile 7 жыл бұрын
at last someone capable of explaining this pattern to me.. the robot story did the trick. Ty
@derekbanas
@derekbanas 7 жыл бұрын
I'm happy it helped :)
@derekbanas
@derekbanas 12 жыл бұрын
Which language are you referring to? PHP isn't an OOP language and no matter what people try to do I think it is a waste to turn it into one. I prefer to use languages for what they are good at. That is all an opinion though
@mitaanshuagarwal007
@mitaanshuagarwal007 7 жыл бұрын
Software engineering is incomplete if you haven't spent hours on this channel.
@derekbanas
@derekbanas 7 жыл бұрын
Thank you for the nice compliment :)
@derekbanas
@derekbanas 11 жыл бұрын
Thank you :) Good luck on your test.
@NyihaNgotho
@NyihaNgotho 11 жыл бұрын
I watched this right before my exam and it came!!!! THANK YOU
@derekbanas
@derekbanas 11 жыл бұрын
I record the screen with camtasia 2. I edit with iMovie. That is basically it. I use cheap or free stuff
@AkhilKumar
@AkhilKumar 10 жыл бұрын
I've got my DP xam tomorrow and completed watching all your DP videos today.....now i'm confident enough to face the test which would have been impossible without these sort of quick reference vid's.....and yet again, Thank you my LORD! :-P __/\__
@derekbanas
@derekbanas 10 жыл бұрын
Best of luck on your test. I'm glad i could help :)
@benjaminayangbola1773
@benjaminayangbola1773 4 жыл бұрын
Hi Derek. There's something about how you make things look so simple. I'm going over the rest of your videos on design patterns. Many thanks.
@derekbanas
@derekbanas 4 жыл бұрын
Thank you very much :) I'm happy you enjoy them
@derekbanas
@derekbanas 12 жыл бұрын
Thank you :) I'll do my best to get 2 more done in the next 2 days
@derekbanas
@derekbanas 11 жыл бұрын
Thank you :) I'm glad you found it useful
@JonahNelson7
@JonahNelson7 4 жыл бұрын
Thanks. I understood the concept but just needed to see an implementation of it. This helped a lot
@derekbanas
@derekbanas 4 жыл бұрын
Happy I could help :)
@derekbanas
@derekbanas 11 жыл бұрын
Thank you :) I'm very happy to be able to help.
@Anton-dl7me
@Anton-dl7me 9 жыл бұрын
Caught myself at a thought that narrator sounds like a robot himself))
@UmairAli
@UmairAli 4 жыл бұрын
Hahha nailed it :D
@arthurmee
@arthurmee 12 жыл бұрын
Beautifully clear tutorial. Thanks Derek. I'm finding your tutorials so helpful.
@antarikshverma8999
@antarikshverma8999 4 жыл бұрын
Again it's awesome , clear and lucid explanation.
@derekbanas
@derekbanas 4 жыл бұрын
Thank you very much :)
@pinkponyofprey1965
@pinkponyofprey1965 7 жыл бұрын
Aaaawwww! I still have my old rx7 on my desk over theeeeere!i It's a Yamaha RX7 drum machine from the eighties ... built like a tank actually haha! :D And yeah! I've been doing PHP with OOP (kind of) for a while now and with a big pile of code I need to untangle this is the first pattern I check and the explanation is great but not what I need. I've seen this video series before more or less just dry watching it but now I need it and it makes more sense. I've 25 videos to rewatch ... * deep breath * ... cover me, I'm going in! :D
@derekbanas
@derekbanas 7 жыл бұрын
That's funny :) I hope the series helps
@FritsvanDoorn
@FritsvanDoorn 9 жыл бұрын
Hi Derek, I studied this wonderful video and then try to reproduce it by memory. At this point I was wondering how to make it to use and came up with a class that has an array of EnemyAttackers of which size is set by the constructor, a method to Add an Attacker, a method to walk all Attackers and a method to let all Attackers Shoot. Now this class has no interest in what it gets, either an EnemyTank or an EnemyRobotAdapter as both are EnemyAttackers with the same interface. Wow, it works. I named this class Game, made a tank and a robot and added them to the game. Now I call game.walk() and both walk. I call game.shoot() and both shoot. Thanks to the Adapter class and thanks to your wonderful super simple explanation of the Adapter Design Pattern. Thank you for long hours of programming fun.
@derekbanas
@derekbanas 9 жыл бұрын
+Frits van Doorn That is awesome! I'm very happy that I could help :)
@pkhafeez1
@pkhafeez1 12 жыл бұрын
Thanks Derek ! I quickly managed knowing design pattersn just a day b4 my interview :D
@johnsineath3633
@johnsineath3633 6 жыл бұрын
What a great video on Design Patterns!
@derekbanas
@derekbanas 6 жыл бұрын
Thank you very much :)
@chrisspencer6502
@chrisspencer6502 5 жыл бұрын
thanks So much clearer and to the point than my lecturer Im not sure if he had slides and time to fill
@derekbanas
@derekbanas 5 жыл бұрын
I'm happy I could help :)
@DracoEvolve
@DracoEvolve 2 жыл бұрын
These are fantastic and was so helpful. I am learning ALOT. quick question, what does void mean? i always see things like 'public void'
@gillianbc
@gillianbc 6 жыл бұрын
I get it - nice simple explanation. The robot scenario worked well for me.
@derekbanas
@derekbanas 6 жыл бұрын
I'm happy it helped :)
@WhyNotKevin
@WhyNotKevin 11 жыл бұрын
Thanks Derek, helped a lot. Busy studying for mid year exams and my lecture slides were very vague. You cleared everything up perfectly. Subscribed ;-)
@fqwixhg
@fqwixhg 10 жыл бұрын
These videos are great! Very straight forward and easy to understand, thank you so much!
@derekbanas
@derekbanas 10 жыл бұрын
Eric Kavalec Thank you :) You're very welcome
@liquidpebbles
@liquidpebbles 6 жыл бұрын
I love you Derek, you're the best
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :) You're very kind
@derekbanas
@derekbanas 11 жыл бұрын
Thank you :) You're very welcome.
@jonathanandrei6411
@jonathanandrei6411 4 жыл бұрын
Still watching this in 2020, good video
@derekbanas
@derekbanas 4 жыл бұрын
Thank you :)
@Desidesi12111
@Desidesi12111 4 жыл бұрын
Thanks Derek. Your videos are to the point and real useful. I would appreciate if you also mention when to use a particular design pattern with real world example. Thanks :)
@derekbanas
@derekbanas 11 жыл бұрын
Thank you :) You're very welcome
@pcihazer20
@pcihazer20 10 жыл бұрын
I appreciate this one and ALL your videos as well. THANKS SO MUCH!!!
@M2dScientist
@M2dScientist 10 жыл бұрын
So easy to understand! Awesome work!
@scarlaticious
@scarlaticious 8 жыл бұрын
Great video! I feel like I finally get it
@derekbanas
@derekbanas 8 жыл бұрын
+scarlaticious Great I'm glad it helped :)
@derekbanas
@derekbanas 11 жыл бұрын
Well the Office is getting cancelled so I needed the work :)
@megaton12
@megaton12 12 жыл бұрын
Yes, those are precisely the languages I'm talking about (duck-typed, no support of interfaces). PHP, Ruby, especially Javascript. What if you wanted to use all these design patterns in Javascript, for example? Won't it not use interfaces, like almost of all these design patterns are using in your examples?
@JohnGosling0
@JohnGosling0 11 жыл бұрын
I think something missing from most of these is some examples of "why?" As zebnat says it seems like the two classes should just be using a parent abstract method to inherit from. Examples of what sort of problems these patterns solve better than other means would be useful!
@derekbanas
@derekbanas 11 жыл бұрын
I cover that more in my refactoring tutorials.
@krowdzilla4534
@krowdzilla4534 6 жыл бұрын
I think that in the RobotAdapter "composition" with enemyRobot you should call it agregation, since you are not controling the instance of newRobot, but receiving in constructor.
@OvyIstrate
@OvyIstrate 11 жыл бұрын
really nice , i'm so glad i found your videos they are very helpful , is so easy to understand , keep up the good work
@derekbanas
@derekbanas 11 жыл бұрын
Thank you very much :) I'm happy that you enjoyed them. They were fun to make
@derekbanas
@derekbanas 12 жыл бұрын
Thank you :)
@unactive95
@unactive95 6 жыл бұрын
Thanks Alot! , my lecturer failed to explain this properly for 5 lessons
@derekbanas
@derekbanas 6 жыл бұрын
I'm happy I could help :)
@moglimogify
@moglimogify 5 жыл бұрын
Very clear explanation, thank you.
@derekbanas
@derekbanas 5 жыл бұрын
Thank you :)
@123japanuser
@123japanuser 12 жыл бұрын
Have to settle for the Bronze =( . But the tutorial is a GOLDEN hands down..............as ever
@mohammadsaif4508
@mohammadsaif4508 9 жыл бұрын
Good job and great work done by you with no words from me .
@derekbanas
@derekbanas 9 жыл бұрын
+Mohammad Saif Thank you :)
@datsonyan3499
@datsonyan3499 6 жыл бұрын
this is a great tutorial and way of explaining this pattern. thanks
@derekbanas
@derekbanas 6 жыл бұрын
Happy to be of service :)
@shutanovac
@shutanovac 9 жыл бұрын
I said once already that your Design pattern course is great. I just have one remark: even though you try to portray the practical use of these, it's still pretty made up. It would be useful to have a reference to some standard Java class(es) that implement a certain pattern. Those were my 2 cents. Thanks a bunch!
@MrToftheL
@MrToftheL 4 жыл бұрын
Thanks Derek. I might make my own example using different character classes in a fantasy game.
@crudhost
@crudhost 9 жыл бұрын
Like always, thank you very much for the intuitive video. :)
@derekbanas
@derekbanas 9 жыл бұрын
+crudhost You're very welcome :)
@imadouzoun
@imadouzoun 6 жыл бұрын
Thank you for the clear explanation! I liked your style.
@derekbanas
@derekbanas 6 жыл бұрын
I'm happy I could help :)
@MengJia73
@MengJia73 11 жыл бұрын
Wow this is some really awesome tutorials!!!! Thanks you soooooo much!
@derekbanas
@derekbanas 11 жыл бұрын
You're very welcome :) I'm glad you are finding them useful.
@AgnaldoC
@AgnaldoC 11 жыл бұрын
You are awesome! Congrats! I understand you easy and I'm gonna have a great test today!
@36ravi36
@36ravi36 12 жыл бұрын
thanks a lot sir, this helped a lot to my seminar.
@ashishbharg
@ashishbharg 9 жыл бұрын
Very nice video. Can you also tell the difference between Class Adapter and Object Adapter with some explanation? Also when both kind of adapters should be used?
@klawenn01
@klawenn01 4 жыл бұрын
Thanks, great explanation! Helped a lot!
@derekbanas
@derekbanas 4 жыл бұрын
Happy I could help :)
@SRISHONLINE
@SRISHONLINE 7 жыл бұрын
I think, it could have been made more simple, by just mentioning that the adapter-pattern, kind of a mapping-class, where the interfaces (on one component) is mapped to available interfaces (of another component). - This serves, that changes in the interfaces, would have minimal change, all at one place. - And secondly, that the component-1 interface can be made more human-readable (use-case specific), even though it uses the underlying component-2 interfaces (which are more oriented towards core-functionality). What say @Derek Banas?
@acuti13
@acuti13 12 жыл бұрын
Thanks, do you have any videos for delegate or MVC patterns? I'm using these to study for my midterm Monday :)
@chasenbettinger9651
@chasenbettinger9651 8 жыл бұрын
What is the purpose of having the adapter? Is it because you could ultimately make different adapters for different platforms (i.e. tank, robot, jet)? Why wouldn't you just create classes for each different object and manipulate their components through getter and setter methods?
@guilhas98fcp
@guilhas98fcp 6 жыл бұрын
This was extremly helpful. Thank you!
@derekbanas
@derekbanas 6 жыл бұрын
I'm happy I could help :)
@sagartrehan6597
@sagartrehan6597 10 жыл бұрын
Thanks very knowledgable. Very good work.
@derekbanas
@derekbanas 10 жыл бұрын
Sagar Trehan Thank you very much :)
@SrikanthReddymalyala
@SrikanthReddymalyala 10 жыл бұрын
Thanks Derek Very useful and feel so simple
@derekbanas
@derekbanas 10 жыл бұрын
Srikanth Reddy You're very welcome :) That is the goal of every video.
@VishalDeshpandedotnet
@VishalDeshpandedotnet 10 жыл бұрын
Hi Derek, It was really awesome..! I have one confusion regarding Wrapper class and Addapter Pattern. How they are differ from each other. because in both the cases we are hiding concrete implementation and creates wrappers around it. Thank You.
@zk1476
@zk1476 10 жыл бұрын
Wrapper is about changing data types totally different thing.
@VishalDeshpandedotnet
@VishalDeshpandedotnet 10 жыл бұрын
Thank You..!
@arsalanajmal
@arsalanajmal 6 жыл бұрын
Awesome. Thank you for clear explanation
@derekbanas
@derekbanas 6 жыл бұрын
Thank you :)
@aliwassouf
@aliwassouf 10 жыл бұрын
great video man ... THANKS
@derekbanas
@derekbanas 10 жыл бұрын
ali wassouf Thank you :) I'm glad you liked it
@thecuriousone12
@thecuriousone12 10 жыл бұрын
Hi Derek. This may sound like a stupid question, but I wanted to ask you how were you able to create an EnemyRobot object in the EnemyRobotAdapter class, seeing as the class implements the EnemyAttacker interface? Sorry if this is a stupid question but I am new to Java and it is kind of confusing...
@derekbanas
@derekbanas 10 жыл бұрын
UnspokenDesirexX Hi, There is no such thing as a stupid question :) The adapter being EnemyRobotAdapter, has a EnemyRobot defined in it. EnemyRobotAdapter implements EnemyAttacker since the EnemyRobot did not. It is then the job of the adapter to provide an alternative action for each method defined in EnemyAttacker. Does that help?
@thecuriousone12
@thecuriousone12 10 жыл бұрын
Derek Banas Hi, thank you for your response :) Yes, I understand why the EnemyRobot is needed in the Adapter. However, I cannot understand how can you possible create it since there is no inheritance to talk about.. Or are we talking about composition?
@zk1476
@zk1476 10 жыл бұрын
Because the enemy robot is in the same Java package and that class is also defined public thus you can create the object in the adapter class.
@francescolimberti7306
@francescolimberti7306 2 жыл бұрын
Thank you P.S. Your voice sounds a lot like Andy Bernard from The Office
@derekbanas
@derekbanas 2 жыл бұрын
You’re very welcome :) Everyone tells me that which I think is funny
@MaleficPlanet
@MaleficPlanet 12 жыл бұрын
Do you have any plans on doing design pattern tutorials in other OOP languages? Some languages just cant natively handle class-based inheritance, for instance, so maybe things would look different..
@salyiohh
@salyiohh 12 жыл бұрын
thank you for all your effort , i have a question regards xsl/xml toturials , how can i make xsl file deals with some dynamics data instead of static ones of xml file? thank you
@ltamas21
@ltamas21 11 жыл бұрын
Hi Derek, maybe it is a silly question but would this work even if the EnemyRobot doesn't have for example the reactToHuman(String) method? So if the EnemyRobot doesn't have all of the required methods (just some of them) then the Adapter pattern is not suggested?
@derekbanas
@derekbanas 11 жыл бұрын
The adapter pattern is there to insert new objects and methods into a system without forcing other objects to add new code. So when the enemy robot object is called instead of calling assign Driver which the enemy robot doesn't have, the adapter instead calls reactToHuman. Does that help?
@ltamas21
@ltamas21 11 жыл бұрын
Thanks for your response. It is clear now :)
@derekbanas
@derekbanas 11 жыл бұрын
I'm happy I could help
@johnnybatafljeska6368
@johnnybatafljeska6368 7 жыл бұрын
Is it necessary for 'adaptee' methods to have the same return type, or even the same arguments?
@Jackorer
@Jackorer 10 жыл бұрын
What if you have an extra enemy entity? Say you have EnemyAircraft. This has methods dropBomb(), flyForward(), assignPilot() (which for the sake of the example is different than assignDriver). How would you do that with the adapter? The adapter class then has 2 attributes: enemyRobot and enemyPlane, right? Do you then just drop enemyPlane.dropBomb() into the fireWeapon() method together with the enemyRobot.smashWithHands()? (etc etc)
@clyde34
@clyde34 10 жыл бұрын
You make an adaptor just for the EnemyAircraft that accepts an EnemyAircraft and replaces the respective methods with the according ones.
@Jackorer
@Jackorer 10 жыл бұрын
Oh so each class gets a seperate adapter? Thanks
@clyde34
@clyde34 10 жыл бұрын
JayDeeBee Almost. Not every class, but every interface. If you have 5 classes that use interface InterfaceOne, and need to be adapted to InterfaceTwo, one adapter would suit them all. Given your example. Let's say you have flying and walking enemies: Flying enemies use the interface EnemyFlying with dropBomb, while walking enemies use EnemyWalking with smashWithHands. You make "EnemyAircraft implements EnemyFlying", "EnemyHelicopter implements EnemyFlying", "EnemyRobot implements EnemyWalking", "EnemyFootsoldier implements EnemyWalking". You would just need to make 2 adapters: EnemyFlying->EnemyEntity that converts dropBomb->fireWeapon and EnemyWalking->EnemyEntity that converts smashWithHands->fireWeapon. The Adapter patterns is very very ugly to explain in Java because it's the only major language with no form of Duck typing.
@Jackorer
@Jackorer 10 жыл бұрын
AdnanClyde Ok. I meant every class with a different set of methods needs a different adapter, right? If EnemeyAircraft and EnemyHelicopter use different methods, they would need a different adapter, correct?
@clyde34
@clyde34 10 жыл бұрын
JayDeeBee Yes
@QuantumPickleJar
@QuantumPickleJar Жыл бұрын
So is each instance of a EnemyRobot possessing an adapter , Or is one just static?
@eugenezuev7349
@eugenezuev7349 4 ай бұрын
Well-explained. Thanks
@MariamaBK
@MariamaBK 7 жыл бұрын
Hello, this video is very good and understandable but i still have a problem. I need to program a Java project for Uni to show what the usage of the Adapter Patter is and explain in a presentation what the difference is to the Bridge Pattern. The problem is i still dont get the difference between them two. Can you please explain it to me.
Facade Design Pattern
11:32
Derek Banas
Рет қаралды 286 М.
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 916 М.
Adapter Pattern - Design Patterns (ep 8)
26:36
Christopher Okhravi
Рет қаралды 249 М.
3 Powerful Design Patterns You Should Know
14:26
Amichai Mantinband
Рет қаралды 15 М.
The Smart Way of Using the Decorator Pattern in C#
12:37
Nick Chapsas
Рет қаралды 72 М.
10 Design Patterns Explained in 10 Minutes
11:04
Fireship
Рет қаралды 2,4 МЛН
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
Alex Hyett
Рет қаралды 330 М.
8 Design Patterns EVERY Developer Should Know
9:47
NeetCode
Рет қаралды 1,1 МЛН
This is the Only Right Way to Write React clean-code - SOLID
18:23