Skip to content

Commit 8305e93

Browse files
committed
Fix typos
1 parent 04e3368 commit 8305e93

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

private-class-data/README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,31 @@ tags:
99
---
1010

1111
## Intent
12-
Private Class Data design pattern seeks to reduce exposure of
13-
attributes by limiting their visibility. It reduces the number of class
14-
attributes by encapsulating them in single Data object.
12+
Private Class Data design pattern seeks to reduce exposure of attributes by limiting their
13+
visibility. It reduces the number of class attributes by encapsulating them in single Data object.
1514

1615
## Explanation
1716

1817
Real world example
1918

20-
> Imagine you are cooking a stew for your family for dinner. You want to prevent your family members from consuming the stew by tasting it while you are cooking, otherwise there will be no more stew for dinner later.
19+
> Imagine you are cooking a stew for your family for dinner. You want to prevent your family members
20+
> from consuming the stew by tasting it while you are cooking, otherwise there will be no more stew
21+
> for dinner later.
2122
2223
In plain words
2324

24-
> Private class data pattern prevent manipulation of data that is meant to be immutable by separating the data from methods that use it into a class that maintains the data state.
25+
> Private class data pattern prevents manipulation of data that is meant to be immutable by
26+
> separating the data from the methods that use it into a class that maintains the data state.
2527
2628
Wikipedia says
2729

28-
> Private class data is a design pattern in computer programming used to encapsulate class attributes and their manipulation.
30+
> Private class data is a design pattern in computer programming used to encapsulate class
31+
> attributes and their manipulation.
2932
3033
**Programmatic Example**
3134

32-
Taking our stew example from above. First we have a `Stew` class where its data is not protected by private class data, making the stew's ingredient mutable to class methods.
35+
Taking our stew example from above. First we have a `Stew` class where its data is not protected by
36+
private class data, making the stew's ingredient mutable to class methods.
3337

3438
```
3539
public class Stew {
@@ -66,7 +70,9 @@ public class Stew {
6670
}
6771
```
6872

69-
Now, we have `ImmutableStew` class, where its data is protected by `StewData` class. Now, the methods in are unable to manipulate the data of the `ImmutableStew` class.
73+
Now, we have `ImmutableStew` class, where its data is protected by `StewData` class. Now, the
74+
methods in are unable to manipulate the data of the `ImmutableStew` class.
75+
7076
```
7177
public class StewData {
7278
private final int numPotatoes;
@@ -106,7 +112,8 @@ public class ImmutableStew {
106112
}
107113
```
108114

109-
Let's try creating some instance of each class and calling their methods
115+
Let's try creating an instance of each class and call their methods:
116+
110117
```
111118
var stew = new Stew(1, 2, 3, 4);
112119
stew.mix(); // Mixing the stew we find: 1 potatoes, 2 carrots, 3 meat and 4 peppers

0 commit comments

Comments
 (0)