Skip to content

Commit 68aaa99

Browse files
author
Julien
committed
Anglicize the problem statement.
1 parent 31a0d63 commit 68aaa99

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

chapters/design_patterns/adapter.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ chapter: Design patterns
55
---
66
## Problem
77

8-
Suppose we have 3-rd party grid component. We want to apply there our own custom sorting but a small problem. Our custom sorter does not implement required interface by grid component.
9-
To understand the problem completely best example would be an socket from our usual life. Everybody knows this device. In some countries it has 3 pins and in other countries it has only 2 pins.
10-
This is exactly right situation to use [adapter pattern](https://en.wikipedia.org/wiki/Adapter_pattern).
8+
Imagine you are traveling to a foreign country and once at your hotel room you realize your power cord is not compatible with the wall electric socket.
9+
Luckily you remember you brought with you a socket adapter.
10+
It will connect to the wall socket on one side and to your power cord on the other side, allowing for communication between them.
11+
12+
The same situation may arise in code, when 2 (or more) instances (of classes, modules, etc.) want to talk to each other, but whose communication protocol (e.i. the language they use to communicate) is different from each other.
13+
In such a situation, the [Adapter Pattern](//en.wikipedia.org/wiki/Adapter_pattern) comes in handy. It will do the translation, from one side to the other.
1114

1215
## Solution
1316

@@ -47,5 +50,5 @@ agrid.sort() # sort data with custom sorter through adapter
4750

4851
## Discussion
4952

50-
Adapter is useful when you have to organize an interaction between two objects with different interfaces. It can happen when you use 3-rd party libraries or you work with legacy code.
53+
Adapter is useful when you have to organize an interaction between two objects with different interfaces. It can happen when you use 3rd party libraries or you work with legacy code.
5154
In any case be careful with adapter: it can be helpful but it can instigate design errors.

0 commit comments

Comments
 (0)