πŸ“š
TIL
  • README
  • Git
    • Basic
    • Remote Repository
    • Log & Diff
    • Rebase&Cherri-Pick
    • git-flow
  • DevOps
    • Monolithic vs MSA
    • Jenkins μ‹œμž‘ν•˜κΈ°
    • Airflow μ‹œμž‘ν•˜κΈ°
    • Airflow μ‹œμž‘ν•˜κΈ°
    • Build Tools
      • maven
  • 개발 방법둠
    • TDD
  • Spring
    • IoC
    • Is Spring Bean Thread-Safe?
    • Spring Singleton
    • Component Scan
    • Spring Annotation
    • 의쑴 관계 μ£Όμž…(DI)
    • Lombok ν™œμš©ν•˜κΈ°
    • Bean 생λͺ…주기와 콜백
    • Bean Scope
    • AOP(1) - AOPλž€
    • AOP(2) - Aop Proxy
    • AOP(3) - Dynamic Proxy
    • AOP(4) - AspectJ
    • POJO
    • Spring μ„œλΉ„μŠ€ ꡬ쑰
    • Transaction
    • JPAλž€?
    • JPA Entity
    • Spring Data JPA
    • Spring Data Specification
    • Model Mapping
    • Cache
    • restTemplate
    • YAML 파일 μ„€μ •
    • Spring Boot
      • H2 DB μ„€μ •
      • 닀쀑 λ°μ΄ν„°λ² μ΄μŠ€ μ„€μ •
      • Mybatis μ—°λ™ν•˜κΈ°
    • Spring Batch
      • Batch μ‹œμž‘ν•΄λ³΄κΈ°
      • Batch Job Flow
      • Job
      • Step
      • Batch Scope & Job Parameter
      • JobRepository와 λ©”νƒ€ν…Œμ΄λΈ”
      • Chunk μ§€ν–₯ ν”„λ‘œκ·Έλž˜λ°
      • ItemReader
      • ItemProcessor
      • ItemWriter
      • Batch Schedular
      • Job별 Beanλ“±λ‘ν•˜κΈ°
      • Batch κ΅¬ν˜„μ‹œ λ°œμƒν•œ 였λ₯˜ 정리
      • Spring Batch Scaling
        • Multithread Jobκ΅¬ν˜„μ‹œ μ΄μŠˆμ‚¬ν•­
    • Spring test
      • Junit5
        • ν…ŒμŠ€νŠΈ 이름 ν‘œκΈ°
        • ν…ŒμŠ€νŠΈ κ·Έλ£Ή μ‚¬μ΄μ˜ 관계
        • νƒœκ·Έμ™€ 필터링
        • 동적 ν…ŒμŠ€νŠΈ
        • ν…ŒμŠ€νŠΈ LifeCycle
        • ν…ŒμŠ€νŠΈ λ©”μ„œλ“œ
        • ν…ŒμŠ€νŠΈ μˆœμ„œ
        • AssertJ
        • ν…ŒμŠ€νŠΈ 병렬 μ‹€ν–‰
        • AssertJ
        • Mock
      • Spring Boot Test DB 뢄리
      • Spring Batch Test
  • Web Application
    • Web Server & WAS
    • κ΄€λ ¨ κ°œλ… - HTTP API, HTML, CSR, SSR
    • Servlet
    • JSP
    • Cookie And Session
    • μ˜ˆμ™ΈνŽ˜μ΄μ§€
    • Java Bean
    • JDBC
    • Connection Pool
    • 파일 μ—…λ‘œλ“œ
    • Expression Language
    • JSTL
    • FrontControllerνŒ¨ν„΄ Command νŒ¨ν„΄
    • Forwarding
    • MVC
    • νšŒμ›κ°€μž…μ˜ˆμ œ
    • μ°Έκ³ 
      • κ°œλ°œν™˜κ²½μ„€μ •
  • Java+
    • SOAP/WSDL vs REST
    • WSDL을 JAVA둜 λ³€ν™˜ν•˜κΈ°
    • SOAP 톡신 OPEN API둜 κ°œλ°œν•΄λ³΄κΈ°
  • Java
    • Basic
      • λ³€μˆ˜μ™€ νƒ€μž…
      • μ—°μ‚°μž
      • 쑰건문과 반볡문
      • μ°Έμ‘° νƒ€μž…
      • 클래슀
      • 상속(Inheritance)
      • μΈν„°νŽ˜μ΄μŠ€(Interface)
      • 쀑첩 ν΄λž˜μŠ€μ™€ 쀑첩 μΈν„°νŽ˜μ΄μŠ€
      • μ˜ˆμ™Έ 처리
      • API - Object, System, Class, Math, Wrapper
      • API - String, StringBuffer, StringBuilder
      • Thread
      • Generic
      • Lambda
      • Collection - List, Set
      • Collection - Map
      • Collection - Tree
      • Collection - Stack, Queue
      • Stream
      • Reflection
      • μ •κ·œν‘œν˜„μ‹
      • GUI
      • UML
      • Serializable
    • Advanced
      • OutOfMemoryError
      • AutoValue
      • meta-annotation
        • @Retention
        • @Target
        • @Repeatable
    • Effective Java 3/E
      • ITEM 1: Static Factory Method(정적 λ©”μ†Œλ“œ)
      • ITEM 2: Builder Pattern
      • ITEM 3: Singleton
      • ITEM 4: Private Constructor
      • ITEM 5: Dependency Injection
      • ITEM 6: Avoid Unnecessary Object
      • ITEM 7: Eliminate Object Reference
      • ITEM 8: Avoid finalizer and cleaner
      • ITEM 9: try-with-resources
      • ITEM 10: The gerneral contract when overriding equlas
      • ITEM 11: Overriding hashCode
      • ITEM 12: overriding toString
      • ITEM 13: overriding clone judiciously
      • ITEM 14: Consider implementing comparable
      • ITEM 15: ν΄λž˜μŠ€μ™€ λ©€λ²„μ˜ 접근을 μ΅œμ†Œν™”ν•΄λΌ
      • ITEM 16: Use Accessor methods
      • ITEM 17: λ³€κ²½ κ°€λŠ₯성을 μ΅œμ†Œν™”ν•΄λΌ(λΆˆλ³€ 클래슀)
      • ITEM 18: 상속보단 μ»΄ν¬μ§€μ…˜μ„ μ‚¬μš©ν•΄λΌ
      • ITEM 19: 상속을 κ³ λ €ν•΄ μ„€κ³„ν•˜κ³  λ¬Έμ„œν™”ν•΄λΌ
      • ITEM 20: 좔상 ν΄λž˜μŠ€λ³΄λ‹€ μΈν„°νŽ˜μ΄μŠ€λ₯Ό μš°μ„ ν•˜λΌ
      • ITEM 21: μΈν„°νŽ˜μ΄μŠ€λŠ” κ΅¬ν˜„ν•˜λŠ” μͺ½μ„ 생각해 섀계해라.
      • ITEM 22: μΈν„°νŽ˜μ΄μŠ€λŠ” νƒ€μž…μ„ μ •μ˜ν•˜λŠ” μš©λ„λ‘œλ§Œ μ‚¬μš©ν•΄λΌ
      • ITEM 23: νƒœκ·Έ 달린 ν΄λž˜μŠ€λ³΄λ‹€ 클래슀 계측ꡬ쑰λ₯Ό ν™œμš©ν•΄λΌ
      • ITEM 24: 멀버 ν΄λž˜μŠ€λŠ” λ˜λ„λ‘ static으둜 κ΅¬ν˜„ν•΄λΌ
      • ITEM 25: ν†±λ ˆλ²¨ ν΄λž˜μŠ€λŠ” ν•œ νŒŒμΌμ— ν•˜λ‚˜λ§Œ 생성해라.
      • ITEM 26: Raw type은 μ‚¬μš©ν•˜μ§€ 마라
      • ITEM 27: 비검사 κ²½κ³ λ₯Ό μ œκ±°ν•΄λΌ
      • ITEM 28: λ°°μ—΄λ³΄λ‹€λŠ” 리슀트λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 29: 이왕이면 μ œλ„€λ¦­ νƒ€μž…μœΌλ‘œ λ§Œλ“€μ–΄λΌ
      • ITEM 30: 이왕이면 μ œλ„€λ¦­ λ©”μ„œλ“œλ‘œ λ§Œλ“€μ–΄λΌ
      • ITEM 31 : ν•œμ •μ  μ™€μΌλ“œμΉ΄λ“œλ₯Ό μ‚¬μš©ν•΄ API μœ μ—°μ„±μ„ 높여라
      • ITEM 32: μ œλ„€λ¦­κ³Ό κ°€λ³€μΈμˆ˜λ₯Ό ν•¨κ»˜ μ“Έ λ•ŒλŠ” 신쀑해라
      • ITEM 33: νƒ€μž… μ•ˆμ „ 이쒅 μ»¨ν…Œμ΄λ„ˆλ₯Ό 고렀해라
      • ITEM 34: int μƒμˆ˜ λŒ€μ‹  μ—΄κ±° νƒ€μž…μ„ μ‚¬μš©ν•΄λΌ
      • ITEM 35: ordinal λ©”μ„œλ“œ λŒ€μ‹  μΈμŠ€ν„΄μŠ€ ν•„λ“œλ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 36: λΉ„νŠΈ ν•„λ“œ λŒ€μ‹  EnumSet을 μ‚¬μš©ν•΄λΌ
      • ITEM 37: ordinal 인덱싱 λŒ€μ‹  EnumMap을 μ‚¬μš©ν•΄λΌ
      • TEM 38 : ν™•μž₯ν•  수 μžˆλŠ” μ—΄κ±°νƒ€μž…μ΄ ν•„μš”ν•˜λ©΄ μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 39: λͺ…λͺ… νŒ¨ν„΄λ³΄λ‹€ μ• λ„ˆν…Œμ΄μ…˜μ„ μ‚¬μš©ν•΄λΌ
      • ITEM 40: @Override μ–΄λ…Έν…Œμ΄μ…˜μ„ μΌκ΄€λ˜κ²Œ μ‚¬μš©ν•΄λΌ
      • ITEM 41: μ •μ˜ν•˜λ €λŠ” 것이 νƒ€μž…μ΄λΌλ©΄ 마컀 μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 42: 읡λͺ… ν΄λž˜μŠ€λ³΄λ‹€λŠ” λžŒλ‹€λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 43: λžŒλ‹€λ³΄λ‹€λŠ” λ©”μ„œλ“œ μ°Έμ‘°λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 44: ν‘œμ€€ ν•¨μˆ˜ν˜• μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 45: μŠ€νŠΈλ¦Όμ€ μ£Όμ˜ν•΄μ„œ μ‚¬μš©ν•΄λΌ
      • ITEM 46: μŠ€νŠΈλ¦Όμ—μ„œ λΆ€μž‘μš© μ—†λŠ” ν•¨μˆ˜λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 47: λ°˜ν™˜ νƒ€μž…μœΌλ‘œλŠ” μŠ€νŠΈλ¦Όλ³΄λ‹€ μ»¬λ ‰μ…˜μ΄ λ‚«λ‹€.
      • ITEM 48: 슀트림 λ³‘λ ¬ν™”λŠ” μ£Όμ˜ν•΄μ„œ μ‚¬μš©ν•΄λΌ
      • ITEM 49: λ§€κ°œλ³€μˆ˜κ°€ μœ νš¨ν•œμ§€ 검사해라
      • ITEM 50: μ μ‹œμ— 방어적 볡사본을 λ§Œλ“€μ–΄λΌ
      • ITEM 51: λ©”μ„œλ“œ μ‹œκ·Έλ‹ˆμ²˜λ₯Ό μ‹ μ€‘νžˆ 섀계해라
      • ITEM 52: λ‹€μ€‘μ •μ˜λŠ” μ‹ μ€‘νžˆ μ‚¬μš©ν•΄λΌ
      • ITEM 53: κ°€λ³€μΈμˆ˜λŠ” μ‹ μ€‘νžˆ μ‚¬μš©ν•΄λΌ
      • ITEM 54: null이 μ•„λ‹Œ, 빈 μ»¬λ ‰μ…˜μ΄λ‚˜ 배열을 λ°˜ν™˜ν•΄λΌ
      • ITEM 55: Optional λ°˜ν™˜μ€ μ‹ μ€‘ν•˜κ²Œ 해라
      • ITEM 56: 곡개된 API μš”μ†Œμ—λŠ” 항상 주석을 μž‘μ„±ν•΄λΌ
      • ITEM 57: μ§€μ—­λ³€μˆ˜μ˜ λ²”μœ„λ₯Ό μ΅œμ†Œν™”ν•΄λΌ
      • ITEM 58: 전톡적인 for λ¬Έλ³΄λ‹€λŠ” for-each문을 μ‚¬μš©ν•΄λΌ
      • ITEM 59: 라이브러리λ₯Ό 읡히고 μ‚¬μš©ν•΄λΌ
      • ITEM 60: μ •ν™•ν•œ 닡이 ν•„μš”ν•˜λ‹€λ©΄ float와 double은 피해라
      • ITEM 61: λ°•μ‹±λœ κΈ°λ³Έ νƒ€μž…λ³΄λ‹€λŠ” κΈ°λ³Έ νƒ€μž…μ„ μ‚¬μš©ν•΄λΌ
      • ITEM 62: λ‹€λ₯Έ νƒ€μž…μ΄ μ μ ˆν•˜λ‹€λ©΄ λ¬Έμžμ—΄ μ‚¬μš©μ„ 피해라
      • ITEM 63: λ¬Έμžμ—΄ 연결은 λŠλ¦¬λ‹ˆ μ£Όμ˜ν•΄λΌ
      • ITEM 64: κ°μ²΄λŠ” μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ‚¬μš©ν•΄ 참쑰해라
      • ITEM 65: λ¦¬ν”Œλ ‰μ…˜λ³΄λ‹€λŠ” μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ‚¬μš©ν•΄λΌ
      • ITEM 66: λ„€μ΄ν‹°λΈŒ λ©”μ„œλ“œλŠ” μ‹ μ€‘νžˆ μ‚¬μš©ν•΄λΌ
      • ITEM 67: μ΅œμ ν™”λŠ” μ‹ μ€‘νžˆ 해라
      • ITEM 68: 일반적으둜 ν†΅μš©λ˜λŠ” λͺ…λͺ… κ·œμΉ™μ„ 따라라
    • 객체지ν–₯ 섀계 원칙(SOLID)
    • λ””μžμΈνŒ¨ν„΄
      • Strategy Pattern
      • Template Method Pattern
      • Factory Method Pattern
      • Singleton
      • Delegation
      • Proxy
      • Adapter Pattern
    • μ‹€μŠ΅
      • μΈν„°νŽ˜μ΄μŠ€ μ‹€μŠ΅ - Vehicle
      • μΈν„°νŽ˜μ΄μŠ€ μ‹€μŠ΅ - Remote
      • GUI μ‹€μŠ΅ - Calculator
      • GUI μ‹€μŠ΅ - button
      • GUI μ‹€μŠ΅ - lotto
      • Thread μ‹€μŠ΅ - μ’Œμ„μ˜ˆμ•½, 메세지보내기
    • Jar vs War
  • λ°μ΄ν„°λ² μ΄μŠ€
    • KEY
    • Index
    • Transaction
    • Trigger
    • Procedure / Function
    • Package
    • λ°μ΄ν„°λ² μ΄μŠ€ 배움터
      • λ°μ΄ν„°λ² μ΄μŠ€ μ‹œμŠ€ν…œ
      • 관계데이터 λͺ¨λΈ
      • κ΄€κ³„λŒ€μˆ˜μ™€ SQL
    • MySQL
      • Databaseλž€
      • MySQL μ‹œμž‘ν•˜κΈ°
      • MySQL Database
      • MySQL Table
      • CRUD
      • κ΄€κ³„ν˜• λ°μ΄ν„°λ² μ΄μŠ€
      • Server와 Client
    • PostgreSQL
    • NoSQL
      • Install Cassandra on mac
      • Cassandraλž€?
      • NiFiλž€
  • Algorithm
    • String
    • Recursion
    • Dynamic Programming
    • Array, Struct, Pointer
    • Math
    • Sort
    • List
    • Stack
    • Queue
    • Graph
    • Tree
    • Maze
    • AVL
    • μ΄μ§„νƒμƒ‰νŠΈλ¦¬(Binary Search Tree)
    • DFS와 BFS
    • λ‹€μ΅μŠ€νŠΈλΌ μ•Œκ³ λ¦¬μ¦˜(Dijkstra's Algorithm)
    • Red-Black 트리
    • A* μ•Œκ³ λ¦¬μ¦˜
    • Heap
    • Huffman Coding
    • Priority Queue
    • Bellman-Ford μ•Œκ³ λ¦¬μ¦˜
    • C++
      • Class
      • STL
        • STL pair
        • STL Container - Associate Container
        • STL Container - Sequence Container
        • STL Container - Container Adapter
  • JavaScript
    • JABASCRIPT BASIC
    • Shallow Copy vs Deep Copy
    • OBJECT MODEL
    • NODE
    • 동기 처리 vs 비동기 처리
    • AJAX
    • CALLBACK
    • PROMISE
    • DEFERRER
    • UNDERSCORE
    • WEBPACK
    • SCOPE
    • EXECUTION CONTEXT
    • Image Object
    • BFCacheλž€?
    • history.scrollRestoration
    • Intersection Observer
    • JWT - JSON Web Token
    • HTML vs JSON
  • Vue.js
    • ν™˜κ²½μ„€μ •
    • Vue.jsλž€?
    • Vue Instance
    • Vue Component
    • Vue Router
    • HTTP 톡신
    • Template
    • Single File Component
    • Vue Animation
    • Vuex
    • Djnago와 μ—°λ™ν•˜κΈ°
  • Backbone.js
    • Model
    • Collection
    • Sync
    • view
  • Node.js
    • Doit! - λ…Έλ“œλ‘œ λ§Œλ“€ 수 μžˆλŠ” λŒ€ν‘œμ μΈ μ„œλ²„μ™€ μš©λ„
    • Doit! - λ…Έλ“œμ— λŒ€ν•΄ μ•Œμ•„λ³΄κ³  개발 도ꡬ μ„€μΉ˜ν•˜κΈ°
    • Doit! - λ…Έλ“œ κ°„λ‹¨ν•˜κ²Œ μ‚΄νŽ΄λ³΄κΈ°
    • Doit! - λ…Έλ“œμ˜ μžλ°”μŠ€ν¬λ¦½νŠΈμ™€ μΉœν•΄μ§€κΈ°
    • Doit! - λ…Έλ“œμ˜ κΈ°λ³Έ κΈ°λŠ₯ μ•Œμ•„λ³΄κΈ°
    • Doit! - μ›Ή μ„œλ²„ λ§Œλ“€κΈ°
    • Doit! - λ°μ΄ν„°λ² μ΄μŠ€ μ‚¬μš©ν•˜κΈ°
    • Doit! - μ΅μŠ€ν”„λ ˆμŠ€ ν”„λ‘œμ νŠΈλ₯Ό λͺ¨λ“ˆν™”ν•˜κΈ°
    • Doit! - λ·° ν…œν”Œλ¦Ώ μ μš©ν•˜κΈ°
    • Doit! - 패슀포트둜 μ‚¬μš©μž μΈμ¦ν•˜κΈ°
    • Doit! - μ±„νŒ…μ„œλ²„ λ§Œλ“€κΈ°
    • Doit! - JSON-RPC μ„œλ²„ λ§Œλ“€κΈ°
  • Python
    • Warning-Could not import the lzma module
    • Pandas
      • Pandas 자료ꡬ쑰
      • Pandas 데이터 μž…μΆœλ ₯
      • DataFrame Data μ‚΄νŽ΄λ³΄κΈ°
      • μ‹œκ°ν™” 도ꡬ - Matplotlib
  • ML
    • μΆ”μ²œ μ‹œμŠ€ν…œ
      • Collaborative Filtering
      • Matrix Factorization
  • Django
    • Basic
      • ν™˜κ²½μ„€μ •
      • About Django
      • Start Django Project
      • Secret Key κ΄€λ¦¬ν•˜κΈ°
      • Settings λΆ„λ¦¬ν•˜κΈ°
      • Django App
      • Django View & URL (1)
      • Django Model
        • MySQL 연동
      • Django Admin
      • Django View & URL (2)
      • Django Template
      • Django Template & View & URL
      • Django Static
      • Django form
    • Advanced
      • Django Generic View
      • Django Automated Testing
      • Django Extenstion Template
      • Django Model Package
      • Django OpenSSL setting
    • REST framework
      • Rest API
      • Serializers
      • ViewSet
    • Error
      • ν™˜κ²½μ„€μ • zlib 였λ₯˜λ°œμƒ
      • ModuleNotFoundError
    • νŒ¨ν‚€μ§€
      • django-debug-toolbar
    • Vue.js μ—°λ™ν•˜κΈ°
  • Ruby
    • variable & input/output
    • 쑰건문
    • 반볡문
    • Array & Hash
    • Method
    • Proc&Lamda
    • Class
  • Ruby on Rails
    • Scaffolding
    • Controller
    • Model
    • Model-M:N relation
    • Model Validation
    • 멋사 10μ£Όμ°¨ μˆ˜μ—…(Tip)
  • HTML/CSS
    • Udacity - Intro to HTML/CSS
    • Udacity - Responsive Web Design
    • Udacity - Responsive Images
    • HTML Basic
    • CSS Basic
    • HTML5 Sementic Tag
    • HTML ν…μŠ€νŠΈ κ΄€λ ¨ νƒœκ·Έλ“€
    • HTML5 λ©€ν‹°λ―Έλ””μ–΄
    • HTML 폼 κ΄€λ ¨ νƒœκ·Έλ“€
    • ν…μŠ€νŠΈ κ΄€λ ¨ μŠ€νƒ€μΌ
    • 색상과 배경을 μœ„ν•œ μŠ€νƒ€μΌ
    • λ ˆμ΄μ•„μ›ƒμ„ μœ„ν•œ μŠ€νƒ€μΌ
    • CSS 포지셔닝
    • λ‹€μž¬λ‹€λŠ₯ν•œ CSS3 μ„ νƒμž
    • CSS와 μ• λ‹ˆλ©”μ΄μ…˜
    • λ°˜μ‘ν˜• μ›Ήμ΄λž€?
  • OS(운영체제)
    • Linux
      • Daemon
      • Cron
      • ν”„λ‘œμ„ΈμŠ€ κ΄€λ ¨ λͺ…λ Ήμ–΄
      • ν…μŠ€νŠΈ 파일 λͺ…λ Ήμ–΄
  • Network
    • λ„€νŠΈμ›Œν¬ κΈ°λ³Έ κ°œλ…
    • λ„€νŠΈμ›Œν¬ κΈ°λ³Έ κ·œμΉ™
    • 물리 계측
    • 데이터 링크 계측
    • λ„€νŠΈμ›Œν¬ 계측
    • 전솑 계측
    • μ‘μš© 계측
    • λ„€νŠΈμ›Œν¬ 전체 흐름
    • 무선 랜
  • IT 기타지식
    • NASλž€
Powered by GitBook
On this page
  • μ‚¬μš©λ˜λŠ” Utility
  • java.util.Arrays
  • java.lang.Math
  • java.util.Collection
  • final ν΄λž˜μŠ€μ™€ κ΄€λ ¨ λ©”μ„œλ“œ

Was this helpful?

  1. Java
  2. Effective Java 3/E

ITEM 4: Private Constructor

// Utilμ΄μ§€λ§Œ μƒμ„±μžκ°€ μ—†μŒ
public class ImageUtility {
    private static String IMAGE_DATE_FORMAT = "yyyyMMddHHmm";

    public static String makeImageFileNm(String imgFileNm) {
        return imgFileNm + "_" + new SimpleDateFormat(IMAGE_DATE_FORMAT).format(new Date());
    }
}

μƒμ„±μžλ₯Ό λͺ…μ‹œν•˜μ§€ μ•ŠμœΌλ©΄ μ»΄νŒŒμΌλŸ¬κ°€ μžλ™μœΌλ‘œ λ§€κ°œλ³€μˆ˜λ₯Ό λ°›μ§€ μ•ŠλŠ” public μƒμ„±μžλ₯Ό λ§Œλ“ λ‹€. μ΄λ•Œ μ‚¬μš©μžλŠ” 이 μƒμ„±μžκ°€ μžλ™μœΌλ‘œ μƒμ„±λœ 것인지 ꡬ뢄할 수 μ—†μœΌλ©°,

// λ‹€μŒκ³Ό 같이 μ‚¬μš©ν•˜κΈ°λ₯Ό λ°”λž¬μœΌλ‚˜,
ImageUtility.makeImageFileNm("test", ".png");

// μƒμ„±μžλ₯Ό μƒμ„±ν•΄μ„œ μ‚¬μš©ν•  μˆ˜λ„ 있음
ImageUtility imageUtility = new ImageUtility();
String imageFileNm = imageUtility.makeImageFileNm("test", ".png");

이처럼 μ˜λ„μΉ˜ μ•Šκ²Œ μΈμŠ€ν„΄μŠ€ν™”ν•  수 있게된 ν΄λž˜μŠ€λ“€λ„ λ°œμƒν•œλ‹€.

// Utilμ΄μ§€λ§Œ μƒμ„±μžκ°€ μ—†μŒ
abstract class ImageUtility {
    private static String IMAGE_DATE_FORMAT = "yyyyMMddHHmm";

    public static String makeImageFileNm(String imgFileNm) {
        return imgFileNm + "_" + new SimpleDateFormat(IMAGE_DATE_FORMAT).format(new Date());
    }
}
public class ItemImageUtility extends ImageUtility {
  // ...
}
// μΆ”μƒν΄λž˜μŠ€μ΄κΈ° λ•Œλ¬Έμ— μƒμ„±μž 생성 λΆˆκ°€
// ImageUtility imageUtility = new ImageUtility();

// 상속받은 ν΄λž˜μŠ€μ—μ„œ μƒμ„±μž 호좜 κ°€λŠ₯
ItemImageUtility itemImageUtility = new ItemImageUtility();

좔상 클래슀둜 λ§Œλ“œλŠ” κ²ƒμœΌλ‘œλŠ” μΈμŠ€ν„΄μŠ€ν™”λ₯Ό 막을 수 μ—†μœΌλ©°, private μƒμ„±μžλ₯Ό μΆ”κ°€ν•˜λ©΄ 클래슀의 μΈμŠ€ν„΄μŠ€ν™”λ₯Ό 막을 수 μžˆλ‹€.

public class ImageUtility {
    // κΈ°λ³Έ μƒμ„±μžκ°€ λ§Œλ“€μ–΄μ§€λŠ” 것을 λ°©μ–΄(μΈμŠ€ν„΄μŠ€ν™” λ°©μ§€μš©)
    private ImageUtility(){
        throw new AssertionError();
    }
}

private μƒμ„±μžμ΄λ―€λ‘œ 클래슀 μ™ΈλΆ€μ—μ„œλŠ” μ ‘κ·Όν•  수 μ—†μœΌλ©°, λ‚΄λΆ€μ—μ„œ μ‹€μˆ˜λ‘œ μƒμ„±μžλ₯Ό ν˜ΈμΆœν•˜λŠ” κ²½μš°μ— λŒ€μ‘ν•˜κΈ° μœ„ν•΄ AssrtionError μ˜ˆμ™Έμ²˜λ¦¬λ₯Ό ν–ˆλ‹€. ν•˜μ§€λ§Œ, μƒμ„±μžκ°€ μžˆλŠ”λ° ν˜ΈμΆœν•  수 μ—†λŠ” 것은 직관적이지 μ•ŠμœΌλ―€λ‘œ, μ μ ˆν•œ 주석을 λ‹€λŠ” 것을 ꢌμž₯ν•œλ‹€.

λ˜ν•œ, private μƒμ„±μžλŠ” 상속도 λΆˆκ°€λŠ₯ν•˜λ‹€. λͺ¨λ“  μƒμ„±μžλŠ” μƒμœ„ 클래슀의 μƒμ„±μžλ₯Ό ν˜ΈμΆœν•˜κ²Œ λ˜λŠ”λ°, 이λ₯Ό private μ„ μ–ΈμœΌλ‘œ ν•˜μœ„ν΄λž˜μŠ€κ°€ μƒμœ„ 클래슀의 μƒμ„±μžμ— 접근을 λͺ»ν•΄ 상속이 λΆˆκ°€λŠ₯ν•˜λ‹€.

μ‚¬μš©λ˜λŠ” Utility

java.util.Arrays

public class Arrays {

    /**
     * The minimum array length below which a parallel sorting
     * algorithm will not further partition the sorting task. Using
     * smaller sizes typically results in memory contention across
     * tasks that makes parallel speedups unlikely.
     */
    private static final int MIN_ARRAY_SORT_GRAN = 1 << 13;

    // Suppresses default constructor, ensuring non-instantiability.
    private Arrays() {}

    /**
     * A comparator that implements the natural ordering of a group of
     * mutually comparable elements. May be used when a supplied
     * comparator is null. To simplify code-sharing within underlying
     * implementations, the compare method only declares type Object
     * for its second argument.
     *
     * Arrays class implementor's note: It is an empirical matter
     * whether ComparableTimSort offers any performance benefit over
     * TimSort used with this comparator.  If not, you are better off
     * deleting or bypassing ComparableTimSort.  There is currently no
     * empirical case for separating them for parallel sorting, so all
     * public Object parallelSort methods use the same comparator
     * based implementation.
     */
    static final class NaturalOrder implements Comparator<Object> {
        @SuppressWarnings("unchecked")
        public int compare(Object first, Object second) {
            return ((Comparable<Object>)first).compareTo(second);
        }
        static final NaturalOrder INSTANCE = new NaturalOrder();
    }
   ...

μΈμŠ€ν„΄μŠ€ν™”λ₯Ό ν•˜μ§€ μ•ŠκΈ° μœ„ν•΄ private μƒμ„±μžλ₯Ό μ„ μ–Έν•œ 것을 λ³Ό 수 있으며, λ°°μ—΄ κ΄€λ ¨ λ©”μ„œλ“œλ“€μ„ λͺ¨μ•„ λ†“λ‘μ—ˆλ‹€.

java.lang.Math

public final class Math {

    /**
     * Don't let anyone instantiate this class.
     */
    private Math() {}

    /**
     * The {@code double} value that is closer than any other to
     * <i>e</i>, the base of the natural logarithms.
     */
    public static final double E = 2.7182818284590452354;

    /**
     * The {@code double} value that is closer than any other to
     * <i>pi</i>, the ratio of the circumference of a circle to its
     * diameter.
     */
    public static final double PI = 3.14159265358979323846;

    /**
     * Returns the trigonometric sine of an angle.  Special cases:
     * <ul><li>If the argument is NaN or an infinity, then the
     * result is NaN.
     * <li>If the argument is zero, then the result is a zero with the
     * same sign as the argument.</ul>
     *
     * <p>The computed result must be within 1 ulp of the exact result.
     * Results must be semi-monotonic.
     *
     * @param   a   an angle, in radians.
     * @return  the sine of the argument.
     */
    public static double sin(double a) {
        return StrictMath.sin(a); // default impl. delegates to StrictMath
    }

Math에 λŒ€ν•œ κΈ°λ³Έ νƒ€μž…(PI, E)μ΄λ‚˜ κ΄€λ ¨ λ©”μ„œλ“œλ“€μ„ λͺ¨μ•„λ‘μ—ˆλ‹€.

java.util.Collection

νŠΉμ • μΈν„°νŽ˜μ΄μŠ€λ₯΄ κ΅¬ν˜„ν•˜λŠ” 객체λ₯Ό μƒμ„±ν•΄μ£ΌλŠ” 정적 λ©”μ„œλ“œ(νŒ©ν„°λ¦¬)λ₯Ό λͺ¨μ•„놓을 수 μžˆλ‹€. (java8λΆ€ν„° 이런 λ©”μ„œλ“œλ₯Ό μΈν„°νŽ˜μ΄μŠ€μ— 넣을 수 있음)

final ν΄λž˜μŠ€μ™€ κ΄€λ ¨ λ©”μ„œλ“œ

final classλ₯Ό μƒμ†ν•΄μ„œ ν•˜μœ„ ν΄λž˜μŠ€μ— λ©”μ„œλ“œλ₯Ό λ„£λŠ” 것은 λΆˆκ°€λŠ₯ν•˜λ―€λ‘œ, final ν΄λž˜μŠ€μ™€ κ΄€λ ¨ λ©”μ„œλ“œλ“€μ„ λͺ¨μ•„λ†“μ„λ•Œλ„ μ‚¬μš©ν•œλ‹€.

PreviousITEM 3: SingletonNextITEM 5: Dependency Injection

Last updated 3 years ago

Was this helpful?