2-design-patterns-java-structural-m2-slides
2-design-patterns-java-structural-m2-slides
Bryan Hansen
twitter: bh5k | http://www.linkedin.com/in/hansenbryan
Adapter
Concepts
▪ Plug adaptor
▪ Convert interface into another interface
▪ Legacy
▪ Translates requests
▪ Client, Adapter, Adaptee
▪ Examples:
▪ Arrays -> Lists
▪ Streams
Design
Client centric
Integrate new with old
Interface, but not required
Adaptee can be the implementation
Everyday Example - Arrays.asList
Walkthrough
Create Adapter
Decorator
Another Adapter
Pitfalls
▪ Not a lot!
▪ Don’t complicate
▪ Multiple Adapters
▪ Don’t add functionality
Contrast
Adapter Bridge
▪ Works after code is designed ▪ Designed upfront
▪ Legacy ▪ Abstraction and implementation
▪ Retrofitted vary
▪ Provides different interface ▪ Built in advance
▪ Both adapt multiple systems
Adapter Summary
• Simple solution
• Easy to implement
• Integrate with Legacy
• Can provide multiple adapters