☕️JAVA Language Community
2.91K subscribers
144 photos
7 videos
31 files
42 links
☕️ Software, IT, Java, news
💻 IT highlights
🎯 AI update
🖥⌨️🖱
Download Telegram
#Design_Patterns
#Adapter_Design_Pattern

👉Intent

Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.

▪️Wrap an existing class with a new interface.

▪️Impedance match an old component to a new system

@javaCode☕️
☕️JAVA Language Community
#Adapter_Design_Pattern @javaCode
#Design_Patterns
#Adapter_Design_Pattern

👉Discussion

Reuse has always been painful and elusive. One reason has been the tribulation of designing something new, while reusing something old. There is always something not quite right between the old and the new. It may be physical dimensions or misalignment. It may be timing or synchronization. It may be unfortunate assumptions or competing standards.

It is like the problem of inserting a new three-prong electrical plug in an old two-prong wall outlet – some kind of adapter or intermediary is necessary.

Adapter is about creating an intermediary abstraction that translates, or maps, the old component to the new system. Clients call methods on the Adapter object which redirects them into calls to the legacy component. This strategy can be implemented either with inheritance or with aggregation.

Adapter functions as a wrapper or modifier of an existing class. It provides a different or translated view of that class.

@javaCode☕️
#Design_Patterns

#Bridge_Design_Pattern

👉Intent

▪️Decouple an abstraction from its implementation so that the two can vary independently.

▪️Publish interface in an inheritance hierarchy, and bury implementation in its own inheritance hierarchy.

▪️Beyond encapsulation, to insulation

@javaCode☕️
#Design_Patterns

#Structural_patterns

#Composite_Design_Pattern

👉Intent

▪️Compose objects into tree structures to represent whole-part hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

▪️Recursive composition

▪️"Directories contain entries, each of which could be a directory."

▪️1-to-many "has a" up the "is a" hierarchy

@javaCode☕️