From 157dde3c488c908df756e9aba54c77f0f446e425 Mon Sep 17 00:00:00 2001 From: sjsdfg <736777445@qq.com> Date: Wed, 5 Jun 2019 23:33:29 +0800 Subject: [PATCH] update --- docs/notes/02. 当构造方法参数过多时使用builder模式.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/notes/02. 当构造方法参数过多时使用builder模式.md b/docs/notes/02. 当构造方法参数过多时使用builder模式.md index da9238b..3ffef75 100644 --- a/docs/notes/02. 当构造方法参数过多时使用builder模式.md +++ b/docs/notes/02. 当构造方法参数过多时使用builder模式.md @@ -7,7 +7,6 @@ ```java // Telescoping constructor pattern - does not scale well! - public class NutritionFacts { private final int servingSize; // (mL) required private final int servings; // (per container) required @@ -61,7 +60,6 @@ NutritionFacts cocaCola = new NutritionFacts(240, 8, 100, 0, 35, 27); ```java // JavaBeans Pattern - allows inconsistency, mandates mutability - public class NutritionFacts { // Parameters initialized to default values (if any) private int servingSize = -1; // Required; no default value @@ -102,7 +100,6 @@ cocaCola.setCarbohydrate(27); ```java // Builder Pattern - public class NutritionFacts { private final int servingSize; private final int servings; @@ -178,7 +175,6 @@ NutritionFacts cocaCola = new NutritionFacts.Builder(240, 8) ```java // Builder pattern for class hierarchies - import java.util.EnumSet; import java.util.Objects; import java.util.Set;