반응형

Template Method 패턴은 객체지향 설계에서 제공되는 행동형 패턴 중 하나로, 알고리즘의 구조를 정의하고, 그 세부 구현은 서브클래스에서 정의하는 방식입니다. 즉, 어떤 처리 과정의 전체 흐름을 정의해 두고, 그 세부적인 단계만을 자식 클래스에서 구체화하는 방식으로 동작합니다. 이 패턴은 주로 중복된 코드의 재사용성을 높이고, 알고리즘을 일정하게 유지하기 위해 활용됩니다.

Template Method 패턴의 주요 구성 요소

Template Method 패턴은 주로 두 가지 주요 요소로 나눌 수 있습니다:

  1. 추상 클래스(Abstract Class): 알고리즘의 기본 뼈대를 정의합니다. 알고리즘의 흐름을 설정하는 "템플릿 메소드"를 포함하며, 구체적인 단계는 서브클래스에서 구현하도록 되어 있습니다.
  2. 구체적인 클래스(Concrete Class): 추상 클래스에서 정의한 템플릿 메소드에 포함된 구체적인 알고리즘 단계를 구현합니다.

Template Method 패턴의 동작 원리

Template Method 패턴에서 가장 중요한 요소는 바로 템플릿 메소드입니다. 이 메소드는 알고리즘의 기본적인 흐름을 정의하고, 특정 단계의 실행을 서브클래스에 위임합니다. 예를 들어, 어떤 데이터를 처리하는 알고리즘에서 '데이터 읽기', '처리', '출력' 단계를 거친다고 할 때, 이 흐름을 템플릿 메소드에서 정의하고, 각 단계별 세부 사항은 서브클래스에서 구현하는 방식입니다.

예시

간단한 예시로, 커피를 만드는 알고리즘을 고려해봅시다. 커피를 만드는 과정은 비슷하지만, 커피의 종류에 따라 세부적인 과정이 달라질 수 있습니다.


abstract class CoffeeTemplate {
    // 템플릿 메소드
    public final void makeCoffee() {
        boilWater();
        brewCoffeeGrinds();
        pourInCup();
        addCondiments();
    }

    // 기본 알고리즘 단계
    public void boilWater() {
        System.out.println("Boiling water");
    }

    public void brewCoffeeGrinds() {
        System.out.println("Brewing coffee grounds");
    }

    public void pourInCup() {
        System.out.println("Pouring coffee into cup");
    }

    // 자식 클래스에서 구현해야 할 부분
    public abstract void addCondiments();
}

class Tea extends CoffeeTemplate {
    @Override
    public void addCondiments() {
        System.out.println("Adding lemon to tea");
    }
}

class Coffee extends CoffeeTemplate {
    @Override
    public void addCondiments() {
        System.out.println("Adding sugar and milk to coffee");
    }
}
        

위 예시에서 makeCoffee() 메소드는 커피를 만드는 기본 흐름을 정의합니다. addCondiments() 메소드는 추상 메소드로, 커피와 차에 따라 다른 양념을 추가하는 세부 구현을 서브클래스에서 담당합니다.

Template Method 패턴의 장점

  • 코드 재사용성: 알고리즘의 구조는 상위 클래스에 정의되고, 세부 구현만 자식 클래스에서 수정하므로 코드 중복을 줄일 수 있습니다.
  • 일관성 유지: 알고리즘의 구조가 고정되어 있기 때문에, 알고리즘의 흐름이 일관되게 유지됩니다.
  • 유연성 제공: 알고리즘의 일부 단계만 수정할 수 있어 유연하게 확장할 수 있습니다.

Template Method 패턴의 단점

  • 상속 의존성: 추상 클래스에 의존해야 하므로, 상속 관계가 복잡해질 수 있습니다.
  • 세부 구현에 대한 제한: 기본적인 알고리즘은 상위 클래스에 정의되지만, 세부 구현에 대한 유연성이 떨어질 수 있습니다.

사용 시기

Template Method 패턴은 다음과 같은 상황에서 유용하게 사용됩니다:

  • 알고리즘의 구조가 거의 비슷하고, 일부 단계만 달라지는 경우.
  • 코드의 재사용성을 높이고, 알고리즘 흐름을 일관성 있게 유지하고자 할 때.
  • 여러 서브클래스에서 공통된 알고리즘 흐름을 따르되, 세부적인 구현만 달리 하고자 할 때.

결론

Template Method 패턴은 알고리즘의 구조를 상위 클래스에서 정의하고, 세부적인 구현을 자식 클래스에서 다르게 구현할 수 있도록 함으로써 코드의 중복을 줄이고, 알고리즘 흐름을 일관성 있게 유지할 수 있게 해줍니다. 이 패턴은 특히 알고리즘의 구조가 동일하지만, 세부 구현만 다른 경우에 매우 유용하게 사용됩니다.

 

728x90
반응형

자바에서 람다 표현식은 익명 함수를 간결하게 표현할 수 있는 기능입니다. 람다 표현식을 사용하면 코드가 더 직관적이고 간결해지며, 특히 함수형 인터페이스를 사용할 때 유용합니다.

1. 람다 표현식 기본 구조

(매개변수들) -> { 실행할 코드 }
    
  • 매개변수들: 람다식에 전달되는 입력 값들.
  • 실행할 코드: 람다식이 실행할 코드 블록.

2. 예시

1) 매개변수가 없는 람다

() -> System.out.println("Hello, World!");
    

이 예시는 매개변수가 없고, "Hello, World!"를 출력하는 람다식입니다.

2) 매개변수가 하나인 람다

x -> x * x
    

매개변수 x를 받아서 x의 제곱을 반환하는 람다식입니다.

3) 매개변수가 여러 개인 람다

(x, y) -> x + y
    

매개변수 x와 y를 받아서 두 값을 더하는 람다식입니다.

3. 람다 표현식 사용 예시

람다 표현식은 주로 함수형 인터페이스에서 사용됩니다. 예를 들어, Runnable 인터페이스를 사용한 예시는 다음과 같습니다:

Runnable task = () -> System.out.println("Hello from a thread!");
task.run();
    

4. 람다 표현식의 장점

  • 간결한 코드: 익명 클래스를 사용하는 것보다 코드가 훨씬 간결해집니다.
  • 가독성 향상: 불필요한 boilerplate 코드가 줄어들어 가독성이 향상됩니다.
  • 함수형 프로그래밍: 자바에서 함수형 프로그래밍 스타일을 사용할 수 있습니다.

5. 함수형 인터페이스

람다 표현식은 함수형 인터페이스와 함께 사용됩니다. 함수형 인터페이스는 하나의 추상 메서드만을 가지는 인터페이스를 말합니다. 예시로 Runnable, Callable, Comparator 등이 있습니다.

@FunctionalInterface
public interface MyFunction {
    void apply();
}
    

위 예시에서 MyFunction 인터페이스는 하나의 추상 메서드를 가지고 있으며, 람다로 구현할 수 있습니다.

MyFunction myFunc = () -> System.out.println("Hello from MyFunction!");
myFunc.apply();
    

6. 람다 표현식의 제한 사항

  • final 또는 effectively final 변수만 사용 가능: 람다식 내에서 참조되는 변수는 반드시 final이거나 사실상 final이어야 합니다.
  • 상태 변경이 어려움: 람다식 내부에서 외부 변수를 변경할 수 없으므로 상태 관리에 제한이 있을 수 있습니다.

7. 결론

람다 표현식은 자바에서 함수형 프로그래밍을 보다 쉽게 구현할 수 있게 해 주는 강력한 도구입니다. 간결한 코드 작성, 가독성 향상 및 함수형 프로그래밍 스타일을 지원하는 데 큰 장점이 있습니다.

728x90
반응형

람다로 객체지향 디자인 패턴 리팩터링하기-지선학

디자인 패턴에 람다 표현식이 더해지면 색다른 기능을 발휘할 수 있다. 즉, 람다를 이용하면 이전에 디자인 패턴으로 해결하던 문제를 더 쉽고 간단하게 해결할 수 있다. 또한 람다 표현식으로 기존의 많은 객체지향 디자인 패턴을 제거하거나 간결하게 재구현할 수 있다.

람다 미적분학(Lambda Calculus)?

수학과 컴퓨터 과학에서 함수와 계산을 표현하고 연구하는 데 사용되는 형식 체계(formal system)입니다. 알론조 처치(Alonzo Church)가 1930년대에 개발했으며, 프로그래밍 언어 이론함수형 프로그래밍의 기초가 되는 이론입니다.

1급 객체(First-Class Citizen)*

사회학적 배경

  • 1급 객체 : 1급 객체(First-Class Citizen)라는 표현은 원래 법률 및 사회학적인 맥락에서 나온 용어로, 특정 대상이 동등한 권리와 특권을 가지는 것을 의미합니다.

예를 들어, 민주주의 사회에서는 모든 시민이 법 앞에서 평등하다는 개념을 의미하는데, "1급 시민"이라는 용어는 이런 평등을 강조하는 데 사용되었습니다.

결과적으로 함수를 1급 객체로 취급하면 유연성, 재사용성, 추상화 수준이 높아집니다. 함수가 변수처럼 자유롭게 전달되고 반환될 수 있기 때문에, 복잡한 계산이나 데이터 흐름을 더 간단하고 선언적으로 표현할 수 있습니다.

Lambda calculus

 

Lambda calculus - Wikipedia

From Wikipedia, the free encyclopedia Mathematical-logic system based on functions Lambda calculus (also written as λ-calculus) is a formal system in mathematical logic for expressing computation based on function abstraction and application using variabl

en.wikipedia.org

 

람다란 무엇인가?

람다 표현식은 메서드로 전달할 수 있는 익명 함수를 단순화한 것이라고 할 수 있다. 람다 표현식에는 이름은 없지만, 파라미터 리스트, 바디, 반환 형식, 발생할 수 있는 예외 리스트는 가질 수 있다.

람다 표현식은 파라미터, 화살표, 바디로 이루어진다.

(Apple a1, Apple a2) -> a1.getWeight().compareTo(a2.getWeight());
사용 사례 람다 예제
불리언 표현식 (List list) → list.isEmpty()
객체 생성 () → new Apple(10)
객체에서 소비 (Apple a) → { System.out.println(a.getWeight));
객체에서 선택/추출 (String s) → s.length()
두 값을 조합 (int a, int b) → a * b

함수형 인터페이스(Functional Interface)

하나의 추상 메서드를 가지는 인터페이스를 의미합니다.

@FunctionalInterface
interface Calculator {
    int calculate(int x, int y);
}
Calculator add = (x, y) -> x + y;
System.out.println(add.calculate(5, 3)); // 출력: 8

자바에서는 왜 함수형 인터페이스가 필요한가?

  1. Java의 객체 중심 특성
    • Java는 철저히 객체 지향 언어로 설계되었습니다. 모든 메서드는 클래스나 객체의 일부로만 존재할 수 있습니다.
    • 람다식은 함수형 프로그래밍의 핵심 요소로, 함수 자체를 전달하거나 처리해야 합니다.
    • 그러나 Java에서는 함수 자체를 일급 객체로 지원하지 않기 때문에, 람다식을 객체 지향 모델과 통합할 방법이 필요했습니다.
  2. 인터페이스를 통한 함수 표현
    • Java 8에서는 람다식을 사용하여 함수를 표현하기 위해, 메서드 하나만 가진 인터페이스(즉, 함수형 인터페이스)를 사용했습니다.
    • 이 인터페이스를 사용하면, 람다식을 해당 인터페이스의 구현체로 취급할 수 있습니다. 이렇게 하면 Java의 기존 객체 지향 모델과 호환성을 유지할 수 있습니다.

자바에서 제공하는 기본 함수형 인터페이스

[Java] Lazy Evaluation (지연 연산)

 

[Java] Lazy Evaluation (지연 연산)

Lazy Evaluation는 불필요한 연산을 피하기 위해 연산을 지연 시켜 놓았다가 필요할 때 연산하는 방법이다.

velog.io

 

java vs javascript 함수형 인터페이스 비교

람다로 객체지향 디자인 패턴 리팩터링하기

전략(Strategy)

https://ko.wikipedia.org/wiki/%EC%A0%84%EB%9E%B5_%ED%8C%A8%ED%84%B4

 

전략 패턴 - 위키백과, 우리 모두의 백과사전

위키백과, 우리 모두의 백과사전. 전략 패턴(strategy pattern) 또는 정책 패턴(policy pattern)은 실행 중에 알고리즘을 선택할 수 있게 하는 행위 소프트웨어 디자인 패턴이다. 전략 패턴은 특정한 계열

ko.wikipedia.org

Legacy 예제

public interface ValidationStrategy {
    boolean execute(String s);
}
public class IsAllLowerCase implements ValidationStrategy {

    @Override
    public boolean execute(String s) {
        return s.matches("[a-z]+");
    }
}
public class IsNumeric implements ValidationStrategy {

    @Override
    public boolean execute(String s) {
        return s.matches("\\d+");
    }
}
public class Validator {

    private final ValidationStrategy strategy;

    public Validator(ValidationStrategy v) {
        this.strategy = v;
    }

    public boolean validate(String s){
        return strategy.execute(s);
    }
}
public class LegacyMain {

    public static void main(String[] args) {

        Validator numericValidator = new Validator(new IsNumeric());
        boolean b1 = numericValidator.validate("aaa");
        System.out.println(b1);

        Validator lowerCaseValidator = new Validator(new IsAllLowerCase());
        boolean b2 = lowerCaseValidator.validate("hello");
        System.out.println(b2);

    }

}

Lambda로 리팩터링 예제

public class LambdaMain {
    public static void main(String[] args) {
        Validator numericValidator = new Validator((String s) -> s.matches("[a-z]+"));
        boolean b1 = numericValidator.validate("aaaaa");
        System.out.println(b1);

        Validator lowerCaseValidator = new Validator((String s) -> s.matches("\\d+"));
        boolean b2 = lowerCaseValidator.validate("bbbb");
        System.out.println(b2);
    }
}
  • ValidationStrategy 는 함수형 인터페이스며 Predicate과 같은 함수 디스크립터를 갖고 있음을 파악할 수 있음.

템플릿 메서드(Template Method)

https://ko.wikipedia.org/wiki/%ED%85%9C%ED%94%8C%EB%A6%BF_%EB%A9%94%EC%86%8C%EB%93%9C_%ED%8C%A8%ED%84%B4

 

템플릿 메소드 패턴 - 위키백과, 우리 모두의 백과사전

위키백과, 우리 모두의 백과사전. 템플릿 메소드 패턴(template method pattern)은 소프트웨어 공학에서 동작 상의 알고리즘의 프로그램 뼈대를 정의하는 행위 디자인 패턴이다.[1] 알고리즘의 구조를

ko.wikipedia.org

 

Legacy 예제

public class Customer {
    private int id;

    private String name;

    public Customer(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public String getName() {
        return name;
    }

}
public class Database {
    private static final Map<Integer, String> TEMP_DATA = new HashMap<>();

    static {
        TEMP_DATA.put(1, "철수");
        TEMP_DATA.put(2, "영희");
        TEMP_DATA.put(3, "민수");
        TEMP_DATA.put(4, "지영");
    }
    public static Customer getCustomerWithId(int id) throws Exception {
        if (TEMP_DATA.get(id) == null) {
            throw new Exception("db 에 해당 값 없음");
        }
        return new Customer(id, TEMP_DATA.get(id));
    }

}
interface OnlineBanking {
    default void processCustomer(int id) throws Exception {
        Customer c = Database.getCustomerWithId(id);
        makeCustomerHappy(c);
    }

    void makeCustomerHappy(Customer c);
}
public class Kbank implements OnlineBanking{
    @Override
    public void makeCustomerHappy(Customer c) {
        System.out.println(c.getName() + "케이뱅크 오버라이딩");
    }
}
public class NH implements OnlineBanking{
    @Override
    public void makeCustomerHappy(Customer c) {
        System.out.println(c.getName() + "농협 오버라이딩");
    }
}
public class LagacyMain {

    public static void main(String[] args) throws Exception {
        OnlineBanking kBanking = new Kbank();
        kBanking.processCustomer(1);
        kBanking.processCustomer(2);

        OnlineBanking nhBanking = new NH();
        nhBanking.processCustomer(1);
        nhBanking.processCustomer(2);
    }

}

Lambda로 리팩터링 예제

public class OnlineBankingLambda {
    public void processCustomer(int id, Consumer<Customer> makeCustomerHappy) throws Exception {
        Customer c = Database.getCustomerWithId(id);
        makeCustomerHappy.accept(c);
    }
}
public class LambdaMain {

    public static void main(String[] args) throws Exception {
        new OnlineBankingLambda().processCustomer(1, (Customer c) -> {
            System.out.println(c.getName() + "케이뱅크 오버라이딩");
        });
        new OnlineBankingLambda().processCustomer(2, (Customer c) -> {
            System.out.println(c.getName() + "케이뱅크 오버라이딩");
        });

        new OnlineBankingLambda().processCustomer(1, (Customer c) -> {
            System.out.println(c.getName() + "농협 오버라이딩");
        });
        new OnlineBankingLambda().processCustomer(2, (Customer c) -> {
            System.out.println(c.getName() + "농협 오버라이딩");
        });
    }
}

옵저버(Observer)

https://ko.wikipedia.org/wiki/%EC%98%B5%EC%84%9C%EB%B2%84_%ED%8C%A8%ED%84%B4

 

옵서버 패턴 - 위키백과, 우리 모두의 백과사전

위키백과, 우리 모두의 백과사전. 옵서버 패턴(observer pattern)은 객체의 상태 변화를 관찰하는 관찰자들, 즉 옵저버들의 목록을 객체에 등록하여 상태 변화가 있을 때마다 메서드 등을 통해 객체

ko.wikipedia.org

Legacy 예제

public interface Observer {
    void notify(String tweet);
}
public class Guardian implements Observer{
    @Override
    public void notify(String tweet) {
        if (tweet != null && tweet.contains("queen")) {
            System.out.println("Yet more news from London..." + tweet);
        }
    }
}
public class LeMonde implements Observer{
    @Override
    public void notify(String tweet) {
        if (tweet != null && tweet.contains("wine")) {
            System.out.println("Today cheese, wine and news!" + tweet);
        }
    }
}
public class NYTimes implements Observer {
    @Override
    public void notify(String tweet) {
        if (tweet != null && tweet.contains("money")) {
            System.out.println("Breaking news in NY!" + tweet);
        }
    }
}
public interface Subject {
    void registerObserver(Observer o);
    void notifyObservers(String tweet);
}
public class Feed implements Subject{
    private final List<Observer> observers = new ArrayList<>();
    @Override
    public void registerObserver(Observer o) {
        this.observers.add(o);
    }

    @Override
    public void notifyObservers(String tweet) {
        observers.forEach(o -> o.notify(tweet));
    }
}
public class LagacyMain {

    public static void main(String[] args) {
        Feed f = new Feed();
        f.registerObserver(new NYTimes());
        f.registerObserver(new Guardian());
        f.registerObserver(new LeMonde());
        f.notifyObservers("The queen said her favourite book is Modern Java in Action!");
    }
}

Lambda로 리팩터링 예제

public class LambdaMain {
    public static void main(String[] args) {
        Feed f = new Feed();
        f.registerObserver((String tweet) -> {
            if (tweet != null && tweet.contains("money")) {
                System.out.println("Breaking news in NY!" + tweet);
            }
        });

        f.registerObserver((String tweet) -> {
            if (tweet != null && tweet.contains("queen")) {
                System.out.println("Yet more news from London..." + tweet);
            }
        });

        f.registerObserver((String tweet) -> {
            if (tweet != null && tweet.contains("wine")) {
                System.out.println("Today cheese, wine and news!" + tweet);
            }
        });

        f.notifyObservers("The queen said her favourite book is Modern Java in Action!");
    }
}

의무 체인(Chain of Responsibility), 책임 연쇄

https://ko.wikipedia.org/wiki/%EC%B1%85%EC%9E%84_%EC%97%B0%EC%87%84_%ED%8C%A8%ED%84%B4

 

책임 연쇄 패턴 - 위키백과, 우리 모두의 백과사전

위키백과, 우리 모두의 백과사전. 객체 지향 디자인에서 책임 연쇄 패턴(chain-of-responsibility pattern)은 명령 객체와 일련의 처리 객체를 포함하는 디자인 패턴이다. 각각의 처리 객체는 명령 객체를

ko.wikipedia.org

Legacy 예제

public abstract class ProcessingObject<T> {
    protected ProcessingObject<T> successor;

    public void setSuccessor(ProcessingObject<T> successor) {
        this.successor = successor;
    }
    public T handle(T input){
        T r = handleWork(input);
        if(successor != null){
            return successor.handle(r);
        }
        return r;
    }

    abstract protected T handleWork(T input);
}
public class HeaderTextProcessing extends ProcessingObject<String> {
    @Override
    protected String handleWork(String text) {
        return "From Raoul, Mario and Alan : "+ text;
    }
}
public class SpellCheckerProcessing extends ProcessingObject<String>{
    @Override
    protected String handleWork(String text) {
        return text.replaceAll("labda", "lambda");
    }
}
public class LagacyMain {

    public static void main(String[] args) {
        ProcessingObject<String> p1 = new HeaderTextProcessing();
        ProcessingObject<String> p2 = new SpellCheckerProcessing();
        p1.setSuccessor(p2); //두 작업 처리 객체를 연결
        String result = p1.handle("Aren't labdas really sexy?!!");
        System.out.println(result);
    }
}

Lambda로 리팩터링 예제

public class LambdaMain {
    public static void main(String[] args) {
        UnaryOperator<String> headerProcessing = (String text) -> "From Raoul, Mario and Alan: " + text;
        UnaryOperator<String> spellCheckerProcessing = (String text) -> text.replaceAll("labda", "lambda");
        Function<String, String> pipeline = headerProcessing.andThen(spellCheckerProcessing);
        String result = pipeline.apply("Aren't labdas really sexy?!!");
        System.out.println(result);
    }
}

팩토리(Factory)

https://ko.wikipedia.org/wiki/%ED%8C%A9%ED%86%A0%EB%A6%AC_%EB%A9%94%EC%84%9C%EB%93%9C_%ED%8C%A8%ED%84%B4

 

팩토리 메서드 패턴 - 위키백과, 우리 모두의 백과사전

위키백과, 우리 모두의 백과사전. UML로 표현된 팩토리 메서드 LePUS3로 표현된 팩토리 메서드 팩토리 메서드 패턴(Factory method pattern)은 객체지향 디자인 패턴이다. Factory method는 부모(상위) 클래스

ko.wikipedia.org

Legacy 예제

public class Product {
    String name;   
}
public class Loan extends Product {
}
public class Bond extends Product {
}
public class Stock extends Product {
}
public class ProductFactory {
    public static Product createProduct(String name){
        return switch (name) {
            case "loan" -> new Loan();
            case "stock" -> new Stock();
            case "bond" -> new Bond();
            default -> throw new RuntimeException("No such product" + name);
        };
    }
}
public class LagacyMain {
    public static void main(String[] args) {
        Product p = ProductFactory.createProduct("loan");
        System.out.println(p.getClass());
    }
}

Lambda로 리팩터링 예제

public class LambdaProductFactory {

    final static Map<String, Supplier<Product>> map = new HashMap<>();

    static {
        map.put("loan", Loan::new);
        map.put("stock", Stock::new);
        map.put("bond", Bond::new);
    }

    public static Product createProduct(String name) {
        Supplier<Product> p = map.get(name);
        if (p != null) return p.get();
        throw new IllegalArgumentException("No such Product " + name);
    }
}
public class LambdaMain {
    public static void main(String[] args) {
        Product p = LambdaProductFactory.createProduct("loan");
        System.out.println(p.getClass());
    }
}

참고자료

https://www.yes24.com/Product/Goods/77125987?pid=123487&cosemkid=go15646485055614872&utm_source=google_pc&utm_medium=cpc&utm_campaign=book_pc&utm_content=ys_240530_google_pc_cc_book_pc_11906%EB%8F%84%EC%84%9C&utm_term=%EB%AA%A8%EB%8D%98%EC%9E%90%EB%B0%94%EC%9D%B8%EC%95%A1%EC%85%98&gad_source=1&gclid=Cj0KCQiAkJO8BhCGARIsAMkswyhABf_O0DVcohWq0DPlyqkn9RKmtvRNYz_zEfI8vbG7c7jJEJh8-UkaAoF5EALw_wcB

 

모던 자바 인 액션 - 예스24

자바 1.0이 나온 이후 18년을 통틀어 가장 큰 변화가 자바 8 이후 이어지고 있다. 자바 8 이후 모던 자바를 이용하면 기존의 자바 코드 모두 그대로 쓸 수 있으며, 새로운 기능과 문법, 디자인 패턴

www.yes24.com

https://m.blog.naver.com/zzang9ha/222087025042

 

[Java/자바] - Supplier<T> interface

Supplier<T> interface 안녕하세요, 이번시간에 알아볼 함수형 인터페이스는 Supplier<T>...

blog.naver.com

https://velog.io/@minseojo/Java-Lazy-Evaluation-%EC%A7%80%EC%97%B0-%EC%97%B0%EC%82%B0

 

[Java] Lazy Evaluation (지연 연산)

Lazy Evaluation는 불필요한 연산을 피하기 위해 연산을 지연 시켜 놓았다가 필요할 때 연산하는 방법이다.

velog.io

 

728x90

+ Recent posts