Skip to content

Commit fba30e5

Browse files
committed
iluwatar#590 Kramdown fixes
1 parent 2d750dc commit fba30e5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

factory-method/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ decide which class to instantiate. Factory Method lets a class defer
2020
instantiation to subclasses.
2121

2222
## Explanation
23-
2423
Real world example
24+
2525
> Blacksmith manufactures weapons. Elves require Elvish weapons and orcs require Orcish weapons. Depending on the customer at hand the right type of blacksmith is summoned.
2626
2727
In plain words
28+
2829
> It provides a way to delegate the instantiation logic to child classes.
2930
3031
Wikipedia says
32+
3133
> In class-based programming, the factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created. This is done by creating objects by calling a factory method—either specified in an interface and implemented by child classes, or implemented in a base class and optionally overridden by derived classes—rather than by calling a constructor.
3234
3335
**Programmatic Example**
@@ -53,6 +55,7 @@ public class OrcBlacksmith implements Blacksmith {
5355
```
5456

5557
Now as the customers come the correct type of blacksmith is summoned and requested weapons are manufactured
58+
5659
```
5760
Blacksmith blacksmith = new ElfBlacksmith();
5861
blacksmith.manufactureWeapon(WeaponType.SPEAR);

singleton/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,31 @@ access to it.
1818

1919
## Explanation
2020
Real world example
21+
2122
> There can only be one ivory tower where the wizards study their magic. The same enchanted ivory tower is always used by the wizards. Ivory tower here is singleton.
2223
2324
In plain words
25+
2426
> Ensures that only one object of a particular class is ever created.
2527
2628
Wikipedia says
29+
2730
> In software engineering, the singleton pattern is a software design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system.
2831
2932
**Programmatic Example**
3033

3134
Joshua Bloch, Effective Java 2nd Edition p.18
35+
3236
> A single-element enum type is the best way to implement a singleton
37+
3338
```
3439
public enum EnumIvoryTower {
3540
INSTANCE;
3641
}
3742
```
43+
3844
Then in order to use
45+
3946
```
4047
EnumIvoryTower enumIvoryTower1 = EnumIvoryTower.INSTANCE;
4148
EnumIvoryTower enumIvoryTower2 = EnumIvoryTower.INSTANCE;

0 commit comments

Comments
 (0)