L'adaptateur est un modèle structurel qui permet aux objets dotés d'interfaces incompatibles de collaborer. Il agit comme un wrapper — traduisant les appels de l'interface attendue par votre code en appels que la classe incompatible comprend. Pensez-y exactement comme à un adaptateur secteur réel : votre ordinateur portable s'attend à 110 V mais la prise fournit 220 V – l'adaptateur comble l'écart sans modifier aucun des côtés.

Idée principale : enveloppez un objet incompatible dans un adaptateur qui implémente l'interface attendue par votre client. Le client ne connaît jamais l'adapté - il ne parle qu'à l'adaptateur.
Full content is available with a subscription.
Get full access to all courses on the platform for one year with a single payment.
Unlike other platforms that charge per course, here you get everything for one price, and after one year of use there will be no automatic charge for the following year.