I really find your teaching style efficient and useful. You explain the problem first, then show the solution, then you show a real-world use case. Really appreciate it ❤ Please continue with this design patterns real-world examples ❤❤❤
21:00 Why do you want to do manual entries to map. Anyway, spring injects the beans right, if you have specific names to all components. I dont see you're making two incompatable services to make compatable using adapter anywhere here. This is more of a kinda stratergy and factory, where you're deciding implementation runtime(stratergy) and getting bean based on decision(factory)
Agree, this is not adapter, but more like strategy pattern. Adapter is to make the interface compatible, implies the payment service implementation of “make payment” changes the adapter should hide it from the client. The client should still be able to call this method, but the adapter makes appropriate calls to facilitate the payment of the target class.
That's what I have done right. Only the mistake I haven't cover incompatible stuff by creating different method with name That's why it's confusing buddy. I will remake this with more meaningful usecase
@@Javatechie Design patterns are tricky, some of them look similar, the definition and intention should guide us. In your example Basant, instead of having different payment services, a better way of showing this pattern would have been, if say “Paypal” had a “process payment” method with one implementation say taking amount in integer or so and later it changed to a different one say taking a float or BigDecimal value, the client will call the adapter and the adapter would make the call to paypal with appropriate arguments and that way the client is hidden from the changes. You are almost there with your example, but it does not show the following point. Correct me if I am missing something. The Adapter Design Pattern solves this problem by defining a separate adapter class that converts the incompatible interface of a class (called the “adaptee”) into another interface (called the “target”) that clients require. Still enjoyed your presentation and found it useful. Thank you for taking the time to share your knowledge.Appreciate it!
I apologise for confusion . I relaise after read many comments . I could make it better by focusing more on the incompatible usecase. Thanks for detailed information @Phoenix I will remake this with clear context
21:00.. we can have one more abstract method returning gateway type(string).. so instead of storying class name in map.. we can store gateway type directly
No need write a custom logic to populate map in constructor @ 23:00. Spring will autowire all the beans based on interface @Autowired private Map paymentProcessorMap;
@@Javatechie yeah exactly this i what I told in my comment, instead of manually mapping beans if we have name to to the component like @component ("paypalAdapter") so on...then when you do Map and do constructor injection spring will automatically injects all the components that implemented PaymentProcessor
I recently did same changes - where I created interface had three implementation class and my spring container has three beans. i had else if statement to assign it processor then i call unified method. Thanks for the constructor which is holding all the processors.
Hi, The concept is clear on the adapter. I tried it using qualifiers but changes required in qualifier annotations, Again and again I am required to change parameters Could you make one video on qualifiers where they do not require to change as in this video based on parameter gpay object created
@@CenturionDobrius i never delete anyone's comment buddy irrespective of good or bad . Because all the way i am learning so Let me check with my team and sorry for it . Please add it again . Thank you for appreciating my work
Hi Basant your video is nice but I think this is not adapter pattern this looks like Strategy pattern where we are selecting one strategy dynamically based on user input
I love your knowledge sharing but for this tutorial is not adapter pattern. It's strategy pattern combining to factory pattern. An adapter wraps one of the objects to hide the complexity of conversion happening behind the scenes. The wrapped object isn’t even aware of the adapter. For example, you can wrap an object that operates in meters and kilometers with an adapter that converts all of the data to imperial units such as feet and miles. Here you wrap anything