You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/posts/java-design-pattern.md
+19-6Lines changed: 19 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ FAseries: ["Themes Guide"] #indicates that this post is part of a series of r
9
9
aliases: ["migrate-from-jekyl"] #Alternative URLs or paths that can be used to access this post, useful for redirects from old posts or similar content.
10
10
ShowToc: true # Determines whether to display the Table of Contents (TOC) for the post.
11
11
TocOpen: true # Controls whether the TOC is expanded when the post is loaded.
12
-
weight: 11# The order in which the post appears in a list of posts. Lower numbers make the post appear earlier.
12
+
weight: 1# The order in which the post appears in a list of posts. Lower numbers make the post appear earlier.
13
13
---
14
14
Explain how to use the design patterns. (Creational Patterns)
- when the class does not know beforehand the exact types and dependencies of the objects it needs to create.
@@ -125,7 +125,7 @@ public class MainTestFactory {
125
125
```
126
126
<br>
127
127
128
-
## 1.2. 🏭 Factory Method
128
+
## 1.2. Factory Method
129
129
-**Factory Method** is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.
130
130
-**Use cases:**
131
131
- when class cannot anticipate the class of objects it must create.
@@ -241,13 +241,13 @@ public class MainTestFactory {
241
241
242
242
<br>
243
243
244
-
## 1.3. 🔨 Abstract Factory
244
+
## 1.3. Abstract Factory
245
245
-**Abstract Factory** is a creational design pattern that lets you produce families of related objects without specifying their concrete classes.
246
246
-**Use cases:**
247
247
- when need a way to **create individual furniture objects** so that they **match other objects of the same family**.
248
248
- When don’t want to change existing code when adding new products or families of products to the program.
249
249
250
-
-**Examples:**You intend to manufacture a product line that included a family of related products: A,B,and C - along with several variants such as AWin,ALinux, BWin,BLinux, CWin, and CLinux.
250
+
-**Examples:**We intend to manufacture a product line that included a family of related products: A,B,and C - along with several variants such as AWin,ALinux, BWin,BLinux, CWin, and CLinux.
251
251
- Design UML:
252
252

253
253
@@ -392,4 +392,17 @@ public class Main {
392
392
}
393
393
}
394
394
395
-
```
395
+
```
396
+
<br>
397
+
398
+
## 1.4. Builder
399
+
-**Builder** is a creational design pattern that lets you construct complex objects step by step. The pattern allows you to produce different types and representations of an object using the same construction code.
400
+
-**Use cases:**
401
+
- build objects step by step, using only those steps that you really need.
402
+
403
+
-**Examples:** We need to create some products: A,B and C with multiple optional attributes.
Copy file name to clipboardExpand all lines: content/posts/java-osgi-service.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ FAseries: ["Themes Guide"] #indicates that this post is part of a series of r
9
9
aliases: ["migrate-from-jekyl"] #Alternative URLs or paths that can be used to access this post, useful for redirects from old posts or similar content.
10
10
ShowToc: true # Determines whether to display the Table of Contents (TOC) for the post.
11
11
TocOpen: true # Controls whether the TOC is expanded when the post is loaded.
12
-
weight: 1# The order in which the post appears in a list of posts. Lower numbers make the post appear earlier.
12
+
weight: 11# The order in which the post appears in a list of posts. Lower numbers make the post appear earlier.
0 commit comments