Added comments about object sharing in Flyweight example + some minor

fixes.
This commit is contained in:
Ilkka Seppala
2015-05-31 21:10:19 +03:00
parent 2a9de6abcc
commit b952469a44
2 changed files with 80 additions and 77 deletions

View File

@ -11,8 +11,8 @@ import java.util.List;
*/
public class AlchemistShop {
List<Potion> topShelf;
List<Potion> bottomShelf;
private List<Potion> topShelf;
private List<Potion> bottomShelf;
public AlchemistShop() {
topShelf = new ArrayList<>();

View File

@ -10,6 +10,9 @@ package com.iluwatar.flyweight;
* the Flyweight in this example). Internally PotionFactory holds a map
* of the potions and lazily creates new ones when requested.
*
* To enable safe sharing, between clients and threads, Flyweight objects must
* be immutable. Flyweight objects are by definition value objects.
*
*/
public class App {