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.
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.
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!
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!
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.
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.
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*!!!
+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! :)
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 ?
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..
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.
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...
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
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
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
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 :)
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.
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.
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
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 __/\__
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
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.
Thanks Derek, helped a lot. Busy studying for mid year exams and my lecture slides were very vague. You cleared everything up perfectly. Subscribed ;-)
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 :)
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?
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!
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.
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!
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?
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?
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?
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.
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...
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?
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?
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..
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
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?
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?
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)
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.
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?
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.
5 years old video and you r still one of the best when it comes to Java tutors on RUclips !!
Thank you very much :)
The best tutorials at all ...
10 years and still this is the best playlist I could find on RUclips!
make it 10
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.
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.
+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!
I'm very happy to hear that I was able to help. You're very welcome
This is the most clearly articulated explanation of the adaptor pattern I have ever heard. Thank you
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!
+Cristobal Gallegos Thank you very much for the nice compliment :)
After 9 years, this video is still the best.
Dude, you are a godsend. Clean, easy to understand implementation. Helped so much with a project I had for school
Thank you very much :) I'm happy I could help
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!
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.
Jack J You're very welcome :) I'm glad that I could help.
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.
Thank you very much :) I do my best to not irritate people
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*!!!
+Popexssj I'm very happy I could help :) Best of luck on your exam
+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! :)
+Popexssj Great Job! I'm glad I could help :)
Derek - You've made this and the other patterns accessible by mortals. Thanks ever so much!
Thank you :) I'm happy I could help
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!
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 ?
I'm sorry, but I'm not understanding the question. Can you give me an example on what you are trying to create?
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..
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.
You're very welcome :) I'm very happy to have been of help!
8 years old and also still one of the best java Lesson about Adapter I found.
Thank you very much :)
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...
Please ask any questions that you have and I'll try to help
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
"I promise I'm not a robot" - Skynet
I don't know why people don't like this, this is great!
You're very welcome :) I'm glad you are enjoying them
Great! If you can use design patterns that will make you stand out from most programmers
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
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
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
Thank you very much :) It is just a very niche subject. Most programmers don't use design patterns.
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 :)
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.
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.
at last someone capable of explaining this pattern to me.. the robot story did the trick. Ty
I'm happy it helped :)
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
Software engineering is incomplete if you haven't spent hours on this channel.
Thank you for the nice compliment :)
Thank you :) Good luck on your test.
I watched this right before my exam and it came!!!! THANK YOU
I record the screen with camtasia 2. I edit with iMovie. That is basically it. I use cheap or free stuff
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 __/\__
Best of luck on your test. I'm glad i could help :)
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.
Thank you very much :) I'm happy you enjoy them
Thank you :) I'll do my best to get 2 more done in the next 2 days
Thank you :) I'm glad you found it useful
Thanks. I understood the concept but just needed to see an implementation of it. This helped a lot
Happy I could help :)
Thank you :) I'm very happy to be able to help.
Caught myself at a thought that narrator sounds like a robot himself))
Hahha nailed it :D
Beautifully clear tutorial. Thanks Derek. I'm finding your tutorials so helpful.
Again it's awesome , clear and lucid explanation.
Thank you very much :)
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
That's funny :) I hope the series helps
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.
+Frits van Doorn That is awesome! I'm very happy that I could help :)
Thanks Derek ! I quickly managed knowing design pattersn just a day b4 my interview :D
What a great video on Design Patterns!
Thank you very much :)
thanks So much clearer and to the point than my lecturer Im not sure if he had slides and time to fill
I'm happy I could help :)
These are fantastic and was so helpful. I am learning ALOT. quick question, what does void mean? i always see things like 'public void'
I get it - nice simple explanation. The robot scenario worked well for me.
I'm happy it helped :)
Thanks Derek, helped a lot. Busy studying for mid year exams and my lecture slides were very vague. You cleared everything up perfectly. Subscribed ;-)
These videos are great! Very straight forward and easy to understand, thank you so much!
Eric Kavalec Thank you :) You're very welcome
I love you Derek, you're the best
Thank you :) You're very kind
Thank you :) You're very welcome.
Still watching this in 2020, good video
Thank you :)
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 :)
Thank you :) You're very welcome
I appreciate this one and ALL your videos as well. THANKS SO MUCH!!!
So easy to understand! Awesome work!
Great video! I feel like I finally get it
+scarlaticious Great I'm glad it helped :)
Well the Office is getting cancelled so I needed the work :)
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?
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!
I cover that more in my refactoring tutorials.
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.
really nice , i'm so glad i found your videos they are very helpful , is so easy to understand , keep up the good work
Thank you very much :) I'm happy that you enjoyed them. They were fun to make
Thank you :)
Thanks Alot! , my lecturer failed to explain this properly for 5 lessons
I'm happy I could help :)
Very clear explanation, thank you.
Thank you :)
Have to settle for the Bronze =( .
But the tutorial is a GOLDEN hands down..............as ever
Good job and great work done by you with no words from me .
+Mohammad Saif Thank you :)
this is a great tutorial and way of explaining this pattern. thanks
Happy to be of service :)
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!
Thanks Derek. I might make my own example using different character classes in a fantasy game.
Like always, thank you very much for the intuitive video. :)
+crudhost You're very welcome :)
Thank you for the clear explanation! I liked your style.
I'm happy I could help :)
Wow this is some really awesome tutorials!!!! Thanks you soooooo much!
You're very welcome :) I'm glad you are finding them useful.
You are awesome! Congrats! I understand you easy and I'm gonna have a great test today!
thanks a lot sir, this helped a lot to my seminar.
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?
Thanks, great explanation! Helped a lot!
Happy I could help :)
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?
Thanks, do you have any videos for delegate or MVC patterns? I'm using these to study for my midterm Monday :)
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?
This was extremly helpful. Thank you!
I'm happy I could help :)
Thanks very knowledgable. Very good work.
Sagar Trehan Thank you very much :)
Thanks Derek Very useful and feel so simple
Srikanth Reddy You're very welcome :) That is the goal of every video.
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.
Wrapper is about changing data types totally different thing.
Thank You..!
Awesome. Thank you for clear explanation
Thank you :)
great video man ... THANKS
ali wassouf Thank you :) I'm glad you liked it
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...
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?
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?
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.
Thank you
P.S. Your voice sounds a lot like Andy Bernard from The Office
You’re very welcome :) Everyone tells me that which I think is funny
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..
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
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?
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?
Thanks for your response. It is clear now :)
I'm happy I could help
Is it necessary for 'adaptee' methods to have the same return type, or even the same arguments?
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)
You make an adaptor just for the EnemyAircraft that accepts an EnemyAircraft and replaces the respective methods with the according ones.
Oh so each class gets a seperate adapter?
Thanks
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.
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?
JayDeeBee Yes
So is each instance of a EnemyRobot possessing an adapter , Or is one just static?
Well-explained. Thanks
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.