Giter Club home page Giter Club logo

effective-java's Introduction

Effective Java

생성자 대신 정적 팩터리 메서드를 사용할 수 없는지 생각해 보라

  • 이름이 있음, 호출할때 Singleton, 반환값 자료형의 하위 자료형 객체를 반환 가능하다.
  • 형인자 자료형 객체를 만들때 편함
public static <K, V> HashMap<K, V> new Instance() {
    return new HashMap<K, V>();
}

Map<String, List<String>> m = hashMap.newInstance();
  • 단점, 하위 클래스 생성 불가. 새로운 인스턴스는 생성 불가하기 때문에
  • 정적 팩터리 메서드가 다른 정적 메서드와 확연히 구분되지 않음

생성자 인자가 많을때, Builder 패턴 적용을 고려하라.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.