Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1369695
study : 싱글톤 패턴 학습
Mar 4, 2022
a741730
study : 팩토리 메서드 - concrete class (OCP 위배 클래스)
Mar 4, 2022
c8e3fa2
study : FactoryMethod 패턴을 적용한 리팩토링
Mar 8, 2022
aea02de
study : Client 클래스도 변경에 닫혀있는 코드로 리팩토링
Mar 8, 2022
d2017f8
study : 추상 팩토리 메서드 초기 구현
Mar 8, 2022
7720303
study : 추상 팩토리 메서드 패턴 적용
Mar 8, 2022
dcc2c16
study : 추상 팩토리 메서드 패턴 적용 (외부에서 주입해서 처리)
Mar 8, 2022
fe799b3
study : 추상 팩토리 메서드 패턴 적용 (외부에서 주입해서 처리)
Mar 8, 2022
ebc766c
study : 빌더 패턴 초기 구현
Mar 8, 2022
5610f33
study : 기본 빌더 패턴 구현
Mar 8, 2022
d5c65c5
study : 기본 빌더 패턴 구현
Mar 8, 2022
861db2b
study : 기본 빌더 패턴 구현(Director 사용)
Mar 8, 2022
d5be9da
study : 프로토타입 패턴 적용 전
Mar 9, 2022
02328fa
study : 프로토타입 패턴 (얕은 복사 적용)
Mar 9, 2022
fef6c27
study : 프로토타입 패턴 (깊은 복사 적용)
Mar 9, 2022
4331b39
study : 어댑터 패턴 적용 전
Mar 9, 2022
254d848
study : 어댑터 패턴 적용(별도 클래스 적용)
Mar 9, 2022
b648a22
study : 어댑터 패턴 적용(별도 클래스 적용 X)
Mar 9, 2022
1a140d2
study : 브릿지 패턴 적용 전
Mar 9, 2022
436334f
study : 브릿지 패턴 적용 전(중복 코드가 많아진다.)
Mar 9, 2022
9a66ea5
study : 브릿지 패턴 적용
Mar 9, 2022
a252e5a
study : 컴포짓 패턴 적용 전
Mar 9, 2022
5f663c4
study : 컴포짓 패턴 적용
Mar 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions inflearn/design-pattern/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

test {
useJUnitPlatform()
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
185 changes: 185 additions & 0 deletions inflearn/design-pattern/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 89 additions & 0 deletions inflearn/design-pattern/gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions inflearn/design-pattern/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rootProject.name = 'design-pattern'

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package abstract_factorymethod;

public interface Anchor {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package abstract_factorymethod;

import factorymethod.Ship;
import factorymethod.WhiteShip;

public class Client extends DefaultShipFactory{
private ShipPartsFactory shipPartsFactory;

public Client(ShipPartsFactory shipPartsFactory) {
this.shipPartsFactory = shipPartsFactory;
}

@Override
Ship createShip() {
WhiteShip ship = new WhiteShip();
ship.setAnchor(shipPartsFactory.createAnchor());
ship.setWheel(shipPartsFactory.createWheel());
return ship;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package abstract_factorymethod;

import factorymethod.Ship;
import factorymethod.ShipFactory;

public abstract class DefaultShipFactory {
Ship orderShip(String name, String email) {
validate(name, email);
prepareFor(name);
Ship ship = createShip();
sendEmailTo(email, ship);
return ship;
}

abstract Ship createShip();
private void sendEmailTo(String email, Ship ship) {
System.out.println(ship.getName() + "만들어졌습니다.");
System.out.println(email + "에게 " + ship.getName() + "이 완성됐음을 이메일로 알림을 보냈습니다.");
}

private void validate(String name, String email) {
if(name == null || name.isBlank()) {
throw new IllegalArgumentException("배 이름을 지어주세요.");
}

if(email == null || email.isBlank()) {
throw new IllegalArgumentException("연락처를 남겨주세요.");
}
}

private static void prepareFor(String name) {
System.out.println(name + "만들 준비 중..");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package abstract_factorymethod;


import factorymethod.Ship;
import factorymethod.ShipFactory;
import factorymethod.WhiteShipFactory;

public class ShipInventory {
public static void main(String[] args) {
ShipFactory shipFactory = new WhiteShipFactory(new WhitePartsProFactory());
Ship ship = shipFactory.createShip();
System.out.println(ship.getAnchor().getClass());
System.out.println(ship.getWheel().getClass());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package abstract_factorymethod;

// 추상 팩토리
public interface ShipPartsFactory {
Anchor createAnchor();
Wheel createWheel();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package abstract_factorymethod;

public interface Wheel {
}
Loading