Skip to content

Commit 5b2ae1d

Browse files
committed
Merge pull request coffeescript-cookbook#88 from nepsilon/adapter-pattern-typos
Anglicize and fix typos for the Adapter design pattern page.
2 parents 141ea03 + 026fd00 commit 5b2ae1d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

chapters/design_patterns/adapter.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
---
22
layout: recipe
3-
title: Adapter patter
3+
title: Adapter pattern
44
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 contries 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 socket is not compatible with the wall socket.
9+
Luckily, you remembered you've brought your power adapter with you.
10+
It will connect your power cord socket on one side and wall socket 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 usefull 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.
51-
In any case be carefull with adapter: it can be helpfull but it can instigate design errors.
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.
54+
In any case be careful with adapter: it can be helpful but it can instigate design errors.

0 commit comments

Comments
 (0)