<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Simongs NOTE</title>
    <description></description>
    <link>https://simongs.github.io/</link>
    <atom:link href="https://simongs.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Mon, 07 Jan 2019 13:25:35 +0000</pubDate>
    <lastBuildDate>Mon, 07 Jan 2019 13:25:35 +0000</lastBuildDate>
    <generator>Jekyll v3.7.4</generator>
    
      <item>
        <title>BASE64 그리고 HEX</title>
        <description>&lt;h3 id=&quot;-고민배경&quot;&gt;▣ 고민배경&lt;/h3&gt;
암호화 알고리즘을 통해 나온 바이트 배열을 어떻게 Text 로 표현할 것인가?

&lt;h3 id=&quot;-base64&quot;&gt;▣ BASE64&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;64개의 문자로 표현을 한다.&lt;/li&gt;
  &lt;li&gt;0…63까지 A-Z, a-z, 0-9, =, / 64개의 문자를 사용해서 표현한다.
    &lt;ul&gt;
      &lt;li&gt;별도의 변환표를 가지고 있다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;8비트 짜리를 6개로 쪼개면 000000(2) 6자리의 2진수가 나오게 되고 해당 6자리 2진수는 0부터 63까지의 값을 가지게 된다.&lt;/li&gt;
  &lt;li&gt;3바이트(24비트) 는 4개의 캐릭터 (24비트) 로 변환하게 된다.&lt;/li&gt;
  &lt;li&gt;01000101 00110001 01001100 -&amp;gt; E1L&lt;/li&gt;
  &lt;li&gt;010001 010011 000101 001100 -&amp;gt; RTFM&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;-hex-string&quot;&gt;▣ Hex String&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Hex는 16진수를 의미한다.&lt;/li&gt;
  &lt;li&gt;16진수는 4비트로 표현가능하며 0~F 까지의 표기가능하다.&lt;/li&gt;
  &lt;li&gt;2진수 -&amp;gt; 16진수는 4자리씩 끊어서 표현가능하다.&lt;/li&gt;
  &lt;li&gt;2진수 = 1011 0101 0010&lt;/li&gt;
  &lt;li&gt;10진수 = 2048 + 512 + 256 + 64 + 16 + 2 = 2898&lt;/li&gt;
  &lt;li&gt;16진수 = B 5 2&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;-reference&quot;&gt;▣ Reference&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://seed.kisa.or.kr/iwt/ko/bbs/EgovReferenceDetail.do?bbsId=BBSMSTR_000000000002&amp;amp;nttId=77&quot;&gt;KISA SEED CBC 알고리즘&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://namu.wiki/w/BASE64&quot;&gt;BASE64 나무위키&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Hexadecimal&quot;&gt;HexDecimal WIKI&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 07 Jan 2019 00:00:00 +0000</pubDate>
        <link>https://simongs.github.io/2019/01/07/ETC-BASE64-%EA%B7%B8%EB%A6%AC%EA%B3%A0-HEX/</link>
        <guid isPermaLink="true">https://simongs.github.io/2019/01/07/ETC-BASE64-%EA%B7%B8%EB%A6%AC%EA%B3%A0-HEX/</guid>
        
        
        <category>ETC</category>
        
      </item>
    
      <item>
        <title>GITHUB에 현재 프로젝트 올리기</title>
        <description>&lt;h3 id=&quot;1-github에-repository를-생성한다&quot;&gt;1. github에 Repository를 생성한다.&lt;/h3&gt;

&lt;h3 id=&quot;2-terminal에서-순서대로-입력합니다&quot;&gt;2. Terminal에서 순서대로 입력합니다.&lt;/h3&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;➜  spirngdata git init
/Users/chopokmado/workspace/workspace-git/spirngdata/.git/ 안의 빈 깃 저장소를 다시 초기화했습니다
➜  spirngdata git:(master) ✗ git add .
➜  spirngdata git:(master) ✗ ll
total 72
drwxr-xr-x  12 chopokmado  staff   384 Jan  6 22:36 .
drwxr-xr-x   7 chopokmado  staff   224 Dec 23 18:39 ..
drwxr-xr-x  10 chopokmado  staff   320 Jan  6 22:36 .git
-rw-r--r--   1 chopokmado  staff   268 Jan  6 18:49 .gitignore
drwxr-xr-x   6 chopokmado  staff   192 Jan  6 18:50 .idea
-rw-r--r--   1 chopokmado  staff  2125 Jan  6 18:49 pom.xml
drwxr-xr-x   4 chopokmado  staff   128 Jan  6 18:49 src
➜  spirngdata git:(master) ✗ git commit -m &quot;test&quot;
[master (최상위-커밋) 11b3833] test
 22 files changed, 993 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 pom.xml
 create mode 100644 src/test/java/com/dasolute/simons/springdata/repository/PostRepositoryTest.java
➜  spirngdata git:(master) git remote add origin https://github.com/simongs/jpa_sample_code.git
➜  spirngdata git:(master) git push -u origin master
오브젝트 나열하는 중: 43, 완료.
오브젝트 개수 세는 중: 100% (43/43), 완료.
Delta compression using up to 12 threads
오브젝트 압축하는 중: 100% (32/32), 완료.
오브젝트 쓰는 중: 100% (43/43), 54.25 KiB | 10.85 MiB/s, 완료.
Total 43 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), done.
To https://github.com/simongs/jpa_sample_code.git
 * [new branch]      master -&amp;gt; master
'master' 브랜치가 리모트의 'master' 브랜치를 ('origin'에서) 따라가도록 설정되었습니다.
➜  spirngdata git:(master)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;3-sourcetree-에서-로컬-디렉토리를-로딩합니다&quot;&gt;3. SourceTree 에서 로컬 디렉토리를 로딩합니다.&lt;/h3&gt;

&lt;h3 id=&quot;4-gitflow를-적용합니다&quot;&gt;4. GitFlow를 적용합니다.&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;SourceTree 상단 메뉴에서 오른쪽 클릭 후 Customizing 을 통해 Git Flow 버튼을 노출시킵니다.&lt;/li&gt;
  &lt;li&gt;Git Flow 적용 후 develop 브랜치를 원격에 Push해줍니다.&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sun, 06 Jan 2019 00:00:00 +0000</pubDate>
        <link>https://simongs.github.io/2019/01/06/ETC-GIT%EC%97%90-%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8-%EC%98%AC%EB%A6%AC%EA%B8%B0/</link>
        <guid isPermaLink="true">https://simongs.github.io/2019/01/06/ETC-GIT%EC%97%90-%ED%94%84%EB%A1%9C%EC%A0%9D%ED%8A%B8-%EC%98%AC%EB%A6%AC%EA%B8%B0/</guid>
        
        
        <category>ETC</category>
        
      </item>
    
      <item>
        <title>이펙티브 자바 3판 혼자 정리하기</title>
        <description>&lt;h2 id=&quot;1-생성자-보다는-static-factory-method&quot;&gt;1. 생성자 보다는 static factory method&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;클래스의 인스턴스를 반환하는 방법에 대한 이야기&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;흔히-사용하는-명명-방식&quot;&gt;흔히 사용하는 명명 방식&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Method Name&lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
      &lt;th&gt;Sample Code&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;from&lt;/td&gt;
      &lt;td&gt;매개변수 하나를 받아서 해당 타입의 인스턴시를 반환하는 형변환 메소드&lt;/td&gt;
      &lt;td&gt;Data d = Date.from(instant);&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;of&lt;/td&gt;
      &lt;td&gt;여러 매개변수를 받아서 적절한 타입의 인스턴스를 반환하는 집계 메소드&lt;/td&gt;
      &lt;td&gt;Set&lt;Rank&gt; cards = EnumSet.of(JACK, QUEEN, KING);&lt;/Rank&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;valueOf&lt;/td&gt;
      &lt;td&gt;from, of의 자세한 버전&lt;/td&gt;
      &lt;td&gt;BigInteger.valueOf(Integer.MAX_VALUE)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;instance or getInstance&lt;/td&gt;
      &lt;td&gt;매개변수로 명시한 인스턴스를 반환&lt;/td&gt;
      &lt;td&gt;StackWalker.getInstance(option)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;create or newInstnace&lt;/td&gt;
      &lt;td&gt;매번 새로운 인스턴스를 반환한다.&lt;/td&gt;
      &lt;td&gt;Array.newInstance(classObject, arrayLen)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;getType&lt;/td&gt;
      &lt;td&gt;getInstance와 같으나, 생성할 클래스가 아닌 다른 클래스에 팩터리 메소드를 정의할 때 쓴다&lt;/td&gt;
      &lt;td&gt;Files.getFileStore(path)&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;관련-코드&quot;&gt;관련 코드&lt;/h3&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Boolean&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;valueOf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Boolean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;TRUE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Boolean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;FALSE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;2-연습필요-생성자에-매개변수가-많다면-빌더를-고려하자&quot;&gt;2. (연습필요) 생성자에 매개변수가 많다면 빌더를 고려하자.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;빌더 패턴은 파이썬, 스칼라에 있는 named optional parameter 를 흉내낸 것이다.&lt;/li&gt;
  &lt;li&gt;생성자나 정적팩토리가 처리해야 할 매개변수가 많다면 빌더 패턴을 선택하는게 더 낫다. 매개변수 중 다수가 필수가 아니거나 같은 타입이면 특히 더 그렇다. 빌더는 점층적 생성자보다 클라이언트 코드를 읽고 쓰기가 훨씬 간결하고, 자바빈즈보다 안전한다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;관련코드&quot;&gt;관련코드&lt;/h3&gt;
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;NutritionFacts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cocaCola&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NutritionFacts&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Builder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;240&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;calories&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sodium&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;35&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;carbonydrate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;27&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;3-private-생성자나-enum-type으로-싱글턴임을-보장하라&quot;&gt;3. private 생성자나 Enum Type으로 싱글턴임을 보장하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;싱글톤 패턴은 쓸일이 없어서 패스&lt;/li&gt;
  &lt;li&gt;Enum을 싱글톤에 활용하면 좋다는 이야기&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;4-연습필요-인스턴스-화를-막으려면-private-생성자를-활용하라&quot;&gt;4. (연습필요) 인스턴스 화를 막으려면 private 생성자를 활용하라&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;제목 그대로이다.&lt;/li&gt;
  &lt;li&gt;Instance 화가 되는 것을 방지한다.&lt;/li&gt;
  &lt;li&gt;상속을 불가능하게 한다.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;UtilityClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// 인스턴스화를 방지한다.&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;UtilityClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;AssertionError&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Impossible To new Instance&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;5-자원을-직접-의존하지-말고-의존객체주입을-사용하라&quot;&gt;5. 자원을 직접 의존하지 말고 의존객체주입을 사용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;원제가 무엇을지 궁금해지는 번역이다.&lt;/li&gt;
  &lt;li&gt;추후 관심이 생길때 정리한다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;6-불필요한-객체-생성은-피해라&quot;&gt;6. 불필요한 객체 생성은 피해라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;String s = new String(“bikini”) // 이렇게 하지 마라&lt;/li&gt;
  &lt;li&gt;박싱된 기본타입보다는 그냥 기본타입을 사용하고, 의도치 않은 오토박싱을 주의하라.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;7-다-쓴-객체-참조를-해제하라&quot;&gt;7. 다 쓴 객체 참조를 해제하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;메모리 누수 이슈&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;8-finalizer-와-cleaner-사용을-피하라&quot;&gt;8. finalizer 와 cleaner 사용을 피하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;cleaner(자바8까지는 finalizer)는 안전망 역할이나 중요하지 않은 네이티브 자원 회수용으로만 사용하자.&lt;/li&gt;
  &lt;li&gt;cleaner, finalizer&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;9-try-finally-보다는-try-with-resource-를-활용하라&quot;&gt;9. try-finally 보다는 try-with-resource 를 활용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;이 구조를 활용하려면 해당 자원이 AutoCloseable 을 구현해야 한다.&lt;/li&gt;
  &lt;li&gt;무조건 try-with-resource 를 활용하라.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;10-equals는-일반-규약을-지켜-재정의하라&quot;&gt;10. equals는 일반 규약을 지켜 재정의하라.&lt;/h2&gt;

&lt;h2 id=&quot;11-equals를-재정의하려거든-hashcode도-재정의해라&quot;&gt;11. equals를 재정의하려거든 hashCode도 재정의해라.&lt;/h2&gt;

&lt;h2 id=&quot;12-tostring-는-항상-재정의하라&quot;&gt;12. toString() 는 항상 재정의하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;toString() 의 규약은 “모든 하위클래스에서 이 메소드를 재정의하라” 이다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;13-clone-재정의는-주의해서-진행해리&quot;&gt;13. clone 재정의는 주의해서 진행해리.&lt;/h2&gt;

&lt;h2 id=&quot;14-comparable을-구현할지-고려하라&quot;&gt;14. Comparable을 구현할지 고려하라.&lt;/h2&gt;

&lt;h2 id=&quot;15-클래스와-멤버의-접근권한을-최소화하라&quot;&gt;15. 클래스와 멤버의 접근권한을 최소화하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;모든 클래스와 멤버의 접근성을 최대한으로 좁혀야 한다.&lt;/li&gt;
  &lt;li&gt;멤버에 부여할 수 있는 접근 수준
    &lt;ul&gt;
      &lt;li&gt;멤버린 필드, 메소드, 중첩 클래스, 중첩 인터페이스 이다.&lt;/li&gt;
      &lt;li&gt;private : 멤버를 선언한 톱레벨 클래스에서 접근가능&lt;/li&gt;
      &lt;li&gt;package-private : 멤버가 소속된 패키지 안에서 접근가능&lt;/li&gt;
      &lt;li&gt;protected : 이 멤버를 선안한 클래스의 하위클래스에서도 접근이 가능한다.&lt;/li&gt;
      &lt;li&gt;public : 외부에 열려있다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;자바 9에서는 두 가지 암묵적 접근 수준이 추가되었다.
    &lt;ul&gt;
      &lt;li&gt;패키지가 클래스의 묶음이듯 모듈은 패키지의 묶음이다.&lt;/li&gt;
      &lt;li&gt;모듈은 자신에게 속하는 패키지 중에 공개(export) 할 것들을 선언한다.
        &lt;ul&gt;
          &lt;li&gt;관례상 module-info.java 파일에 선언한다.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;16-public-클래스에서는-public-필드가-아닌-접근자-메소드를-사용하라&quot;&gt;16. public 클래스에서는 public 필드가 아닌 접근자 메소드를 사용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;getter, setter 를 이용하라.&lt;/li&gt;
  &lt;li&gt;package-private 클래스 혹은 private 중첩클래스라면 데이터 필드를 노출한다 해도 하등의 문제가 없다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;17-변경가능성을-최소화해라&quot;&gt;17. 변경가능성을 최소화해라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;객체를 불변으로 만드는 5가지 원칙
    &lt;ul&gt;
      &lt;li&gt;객체의 상태를 변경하는 메소드를 제공하지 않는다.&lt;/li&gt;
      &lt;li&gt;클래스를 확장할 수 없도록 한다. (final class, private 생성자)&lt;/li&gt;
      &lt;li&gt;모든 필드를 final로 선언한다.&lt;/li&gt;
      &lt;li&gt;모든 필드를 private 으로 선언한다.&lt;/li&gt;
      &lt;li&gt;자신 외에 내부의 가변필드에 접근 할 수 없도록 한다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;18-상속보다는-컴포지션을-사용하라&quot;&gt;18. 상속보다는 컴포지션을 사용하라.&lt;/h2&gt;

&lt;h2 id=&quot;19-상속을-고려해-설계히고-문서화하라-그러지-않았다면-상속하지-마라&quot;&gt;19. 상속을 고려해 설계히고 문서화하라. 그러지 않았다면 상속하지 마라.&lt;/h2&gt;

&lt;h2 id=&quot;20-abstract-class-보다는-interface를-우선하라&quot;&gt;20. Abstract Class 보다는 Interface를 우선하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;기존 클래스에도 손쉽게 인터페이스 추가 가능하다.&lt;/li&gt;
  &lt;li&gt;믹스드인 정의에 안성맞춤이다.
    &lt;ul&gt;
      &lt;li&gt;대상 타입의 주된 기능에 부가적인 기능을 정의하는 것을 믹스인이라 한다.&lt;/li&gt;
      &lt;li&gt;예를 들어 Comparable 은 객체간에 순서가 있을을 정의한다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;인터페이스로 계층구조가 없는 타입 프레임워크를 만들 수 있다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;21-인터페이스는-구현하는-쪽을-생각해-설계하라&quot;&gt;21. 인터페이스는 구현하는 쪽을 생각해 설계하라.&lt;/h2&gt;

&lt;h2 id=&quot;22-인터페이스는-타입을-정의하는-용도로만-사용하라&quot;&gt;22 .인터페이스는 타입을 정의하는 용도로만 사용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;SomeThingConstants 같은 클래스를 인터페이스로 만들지 말자.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;23-태그-달린-클래스보다는-클래스-계층구조를-이용하라&quot;&gt;23. 태그 달린 클래스보다는 클래스 계층구조를 이용하라.&lt;/h2&gt;

&lt;h2 id=&quot;24-멤버클래스는-최대한-static-으로-만들라&quot;&gt;24. 멤버클래스는 최대한 static 으로 만들라.&lt;/h2&gt;

&lt;h2 id=&quot;25-top-level-class는-한-파일에-하나씩만-담아라&quot;&gt;25. Top Level Class는 한 파일에 하나씩만 담아라.&lt;/h2&gt;

&lt;h2 id=&quot;26-raw-type은-사용하지-말라&quot;&gt;26. Raw Type은 사용하지 말라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;클래스와 인터페이스 선언에 타입 매개변수가 쓰이면 이를 제네릭 클래스, 제네릭 인터페이스라 한다.
    &lt;ul&gt;
      &lt;li&gt;ex) List 인터페이스는 원소 타입을 나타내는 타입 매개변수 E를 받는다.&lt;/li&gt;
      &lt;li&gt;그래서 완전한 이름은 List&lt;E&gt; 이다.&lt;/E&gt;&lt;/li&gt;
      &lt;li&gt;통칭해서 제네릭 타입이라 한다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;제네릭 타입은 일련의 매개변수화 타입을 정의한다.
    &lt;ul&gt;
      &lt;li&gt;예컨데 List&lt;String&gt; 은 원소타입이 String인 리스트를 뜻하는 매개변수화 타입이다.&lt;/String&gt;&lt;/li&gt;
      &lt;li&gt;String은 타입 매개변수 E 에 해당하는 실제 타입매개변수이다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;제네릭 타입을 정의하면 그에 딸린 Raw Type도 정의된다.
    &lt;ul&gt;
      &lt;li&gt;제네릭 타입에서 타입 매개변수를 전혀 사용하지 않을 때를 의미한다.&lt;/li&gt;
      &lt;li&gt;List&lt;E&gt; 의 Raw Type은 List이다.&lt;/E&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;27-비검사-경고를-제거하라&quot;&gt;27. 비검사 경고를 제거하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;경고를 제거할 수 없지만 타입이 안전하다고 확신할 수 있다면 @SuppressWarning(“unchecked”) 애노테이션을 달자.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;28-array-보다는-list를-사용하라&quot;&gt;28. Array 보다는 List를 사용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;배열과 제네릭은 매우 다른 타입 규칙이 적용된다.&lt;/li&gt;
  &lt;li&gt;배열은 공변이고 실제화되는 반면에 제네릭은 불공변이고 타입정보가 소거(Erasure)된다.&lt;/li&gt;
  &lt;li&gt;그 결과 배열은 런타임에 타입 안전하지만 컴파일 타임에는 그렇지 않다.&lt;/li&gt;
  &lt;li&gt;제네릭은 그 반대이디.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;29-이왕이면-제네릭-타입으로-만들라&quot;&gt;29. 이왕이면 제네릭 타입으로 만들라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;기존 타입에서 제네릭이었어야 하는 게 있다면 제네릭으로 변경하자.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;30-이왕이면-제네릭-메소드로-만들라&quot;&gt;30. 이왕이면 제네릭 메소드로 만들라.&lt;/h2&gt;
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Set&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;union&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Set&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Set&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Set&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HashSet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;addAll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;union&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HashSet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;addAll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;31-한정적-와일드카드를-사용해-api의-유연성을-높여라&quot;&gt;31. 한정적 와일드카드를 사용해 API의 유연성을 높여라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Iterable&amp;lt;? extends E&amp;gt; -&amp;gt; E의 하위타입의 Iterable&lt;/li&gt;
  &lt;li&gt;Collection&amp;lt;? super E&amp;gt; -&amp;gt; E의 상위타입의 Collection&lt;/li&gt;
  &lt;li&gt;PECS : Producer-Extends, Consumer-Super&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;32-제네릭과-가변인수를-쓸-때는-조심하라&quot;&gt;32. 제네릭과 가변인수를 쓸 때는 조심하라.&lt;/h2&gt;

&lt;h2 id=&quot;33-타입-안전-이종-컨테이너를-고려하라&quot;&gt;33. 타입 안전 이종 컨테이너를 고려하라.&lt;/h2&gt;

&lt;h2 id=&quot;34-int-상수-대신-열거-타입을-사용하라&quot;&gt;34. int 상수 대신 열거 타입을 사용하라&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;열거타입은 정수상수보다 뛰어나다.&lt;/li&gt;
  &lt;li&gt;열거타입에서 상수별 메소드 구현도 가능하다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;35-ordinal-메소드-대신-인스턴스-필드를-사용하라&quot;&gt;35. ordinal 메소드 대신 인스턴스 필드를 사용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Enum타입에는 ordinal() 가 존재한다.
    &lt;ul&gt;
      &lt;li&gt;그 열거타입에서 몇 번째에 위치해 있는지를 리턴한다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;중간에 하나가 껴들어가면 예상했던 순서의 값과 달라질 수 있다.&lt;/li&gt;
  &lt;li&gt;열거 타입 상수에 연결된 값은 인스턴스 필드에 저장하자.
    &lt;ul&gt;
      &lt;li&gt;SOLO, DUET&lt;/li&gt;
      &lt;li&gt;SOLO(1), DUET(2)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;36-비트-필드-대신에-enumset을-사용하라&quot;&gt;36. 비트 필드 대신에 EnumSet을 사용하라.&lt;/h2&gt;

&lt;h2 id=&quot;37-ordinal-인덱싱-대신-enummap을-사용하라&quot;&gt;37. ordinal 인덱싱 대신 EnumMap을 사용하라.&lt;/h2&gt;
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Plant&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;LifeCycle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Plant&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;enumMap&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;EnumMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Plant&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;LifeCycle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Plant&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;LifeCycle&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Plant&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;LifeCycle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;enumMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HashSet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;gt;());&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Plant&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;garden&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;enumMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;lifeCycle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;38-확장-할-수-있는-열거타입이-필요하면-인터페이스를-사용하라&quot;&gt;38. 확장 할 수 있는 열거타입이 필요하면 인터페이스를 사용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;열거 타입 자체는 확장 할 수 없지만, 인터페이스와 그 인터페이스를 구현하는 기본 열거 타입을 함께 사용해 같은 효과를 낼 수 있다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;39-명명-패턴보다는-어노테이션을-사용하라&quot;&gt;39. 명명 패턴보다는 어노테이션을 사용하라.&lt;/h2&gt;

&lt;h2 id=&quot;40-override-어노테이션을-일관되게-사용하라&quot;&gt;40. @Override 어노테이션을 일관되게 사용하라.&lt;/h2&gt;

&lt;h2 id=&quot;41-정의하려는-것이-타입이라면-마커-인터페이스를-사용하라&quot;&gt;41. 정의하려는 것이 타입이라면 마커 인터페이스를 사용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;마커 인터페이스, 마커 어노테이션은 각자의 쓰임새가 있다.&lt;/li&gt;
  &lt;li&gt;새로 추가하는 메서드 없이 단지 타입 정의가 목적이라면 마커 인터페이스를 선택하자.&lt;/li&gt;
  &lt;li&gt;적용 대상이 ElementType.TYPE인 마커 어노테이션을 작성하고 있다면, 마커 인터페이스가 나은지를 한번더 검토하라.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;42-익명-클래스보다는-람다를-사용하라&quot;&gt;42. 익명 클래스보다는 람다를 사용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;작은 함수 객체를 구현하는데 적합한 람다가 도입되었다.&lt;/li&gt;
  &lt;li&gt;익명 클래스는 (함수형 인터페이스가 아닌) 타입의 인스턴스를 만들때만 사용하라.&lt;/li&gt;
  &lt;li&gt;낡은 기법.
    &lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;n&quot;&gt;Collections&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;words&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Comparator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;compare&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;compare&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
 &lt;span class=&quot;o&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;람다 기법
    &lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;n&quot;&gt;Collections&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;words&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;compare&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;((),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;43-람다보다는-메소드-레퍼런스를-이용하라&quot;&gt;43. 람다보다는 메소드 레퍼런스를 이용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;메소드 레퍼런스는 람다의 간단명료한 대인이 될 수 있다.&lt;/li&gt;
  &lt;li&gt;메소드 레퍼런스 쪽이 짧고 명확하다면 메소드 레퍼런스를 쓰는 게 좋다.&lt;/li&gt;
  &lt;li&gt;map.merge(key, 1, (count, incr) -&amp;gt; count + incr);&lt;/li&gt;
  &lt;li&gt;map.merge(key, Integer::sum)&lt;/li&gt;
&lt;/ul&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;메소드 레퍼런스 유형&lt;/th&gt;
      &lt;th&gt;예시&lt;/th&gt;
      &lt;th&gt;같은 기능을 하는 람다&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;정적&lt;/td&gt;
      &lt;td&gt;Integer::parseInt&lt;/td&gt;
      &lt;td&gt;str -&amp;gt; Integer.parseInt(str)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;한정적 (인스턴스)&lt;/td&gt;
      &lt;td&gt;Instant.now()::isAfter&lt;/td&gt;
      &lt;td&gt;Instant then = Instant.now(); t -&amp;gt; then.isAfter(t);&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;비한정적 (인스턴스)&lt;/td&gt;
      &lt;td&gt;String::toLowerCase&lt;/td&gt;
      &lt;td&gt;str -&amp;gt; str.toLowerCase();&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;클래스 생성자&lt;/td&gt;
      &lt;td&gt;TreeMap&amp;lt;K,V&amp;gt;::new&lt;/td&gt;
      &lt;td&gt;() -&amp;gt; new TreeMap&amp;lt;K,V&amp;gt;();&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;배열 생성자&lt;/td&gt;
      &lt;td&gt;int[]::new&lt;/td&gt;
      &lt;td&gt;len -&amp;gt; new int[len]&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;44-표준-함수형-인터페이스를-사용하라&quot;&gt;44. 표준 함수형 인터페이스를 사용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;자바가 람다를 지원하면서 API를 작성하는 모범사례도 크게 바뀌고 있다.&lt;/li&gt;
  &lt;li&gt;예를 들어서 상위 클래스의 기본 메소드를 재정의해서 원하는 동작을 구현하는 템플릿 메소드 패턴의 매력이 크게 줄었다.&lt;/li&gt;
  &lt;li&gt;이를 대체하는 현대적 방법은 같은 효과의 함수 객체를 받는 정적 팩토리나 생성자를 제공하는 것이다.&lt;/li&gt;
  &lt;li&gt;함수 객체를 매개변수로 받는 생성자나 메소드를 더 많이 만들어야 한다.&lt;/li&gt;
  &lt;li&gt;java.util.fuction Package에는 다양한 표준 함수형 인터페이스가 담겨있다.&lt;/li&gt;
  &lt;li&gt;필요한 용도에 맞는게 있다면, 직접 구현하지 말고 표준 함수형 인터페이스를 활용하라.&lt;/li&gt;
  &lt;li&gt;총 43개의 인터페이스가 있지만 기본인터페이스 6개를 기억하자&lt;/li&gt;
  &lt;li&gt;직접 만든 함수형 인터페이스에는 항상 @FunctionalInterface 어노테이션을 사용하라.&lt;/li&gt;
&lt;/ul&gt;

인터페이스 | 함수 시그니처 | 설명 | 예시 
 — | — | — | — 
 UnaryOperation&lt;T&gt; | T apply(T t) | 반환값과 인수타입이 같다, 인수 1개 | String::toLowerCase
 BinaryOperation&lt;T&gt; | T apply&amp;lt;T t1, T t2&amp;gt; | 반환타입과 인수타입이 같다, 인수 2개 | BigInteger::add
 Predicate&lt;T&gt;| boolean test(T t) | 인수 하나를 받아 boolean을 반환하는 함수 | Collection::isEmpty
 Function&lt;T&gt; | R apply(T t) | 인수와 반환타입이 다른 함수 | Arrays::asList
 Supplier&lt;T&gt; | T get() | 인수는 없고 반환만 제공하는 함수 | Instant::now
 Consumer&lt;T&gt; | void accept(T t) | 인자만 있고 반환은 없음 | System.out::println&lt;/T&gt;&lt;/T&gt;&lt;/T&gt;&lt;/T&gt;&lt;/T&gt;&lt;/T&gt;

&lt;h2 id=&quot;45-스트림은-주의해서-사용하라&quot;&gt;45. 스트림은 주의해서 사용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;이 API의 추상개념
    &lt;ul&gt;
      &lt;li&gt;스트림은 데이터 원소의 유한 혹은 무한 시퀀스를 뜻한다.&lt;/li&gt;
      &lt;li&gt;스트림 파이프라인은 이 원소들로 수행하는 연산단계를 표현하는 개념이다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;스트림의 원소들은 어디로부터든 올 수 있다.&lt;/li&gt;
  &lt;li&gt;대표적으로는 컬렉션, 배열, 파일, 정규표현식 패턴 매처, 난수 생성기, 혹은 다른 스트림이 있다.&lt;/li&gt;
  &lt;li&gt;기본 타입으로는 int, long, double을 지원한다.&lt;/li&gt;
  &lt;li&gt;스트림 파이프라인은 Source Stream에서부터 시작해서 Terminal Operation으로 끝나며 그 사이에 하나 이상의 중간 연산이 있을 수 있다.&lt;/li&gt;
  &lt;li&gt;스트림 파이프라인은 Lazy Evaluation을 진행한다. Terminal Operation이 호출될때 실행이 이루어진다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;46-스트림에서는-부작용-없는-함수를-사용하라&quot;&gt;46. 스트림에서는 부작용 없는 함수를 사용하라&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;forEach 연산은 스트림 계산결과를 보소할때만 사용하고, 계산하는 데는 쓰지말자.
    &lt;ul&gt;
      &lt;li&gt;스트림 종단 연산 중에 기능이 가장 적고, 가장 덜 스트림답다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;스트림을 올바르게 사용하려면 수집기를 잘 알아둬야 한다.&lt;/li&gt;
  &lt;li&gt;가장 중요한 수집가 팩토리는 toList, toSet, toMap, groupingBy, joining 이다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;47-반환-타입으로는-스트림보다-컬렉션이-낫다&quot;&gt;47. 반환 타입으로는 스트림보다 컬렉션이 낫다.&lt;/h2&gt;

&lt;h2 id=&quot;48-스트림-병렬화는-주의해서-사용하라&quot;&gt;48. 스트림 병렬화는 주의해서 사용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;계산도 올바르게 수행하고 성능도 빨라질거라는 확신 없이는 스트림 파이프라인을 사용하지 마라.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;49-매개변수가-유효한-지-검사하라&quot;&gt;49. 매개변수가 유효한 지 검사하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Objects.requireNonNull() 는 유연하고 사용하기도 편한다. 더이상 null 검사를 수동으로 하지 않아도 된다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;50-적시에-방어적-복사본을-만들어라&quot;&gt;50. 적시에 방어적 복사본을 만들어라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;클라이언트가 여러분의 불변식을 깨뜨리려 혈안이 되어 있다고 가정하고 방어적으로 프로그래밍해야한다.&lt;/li&gt;
  &lt;li&gt;Date 클래스는 낡은 API이니 새로운 코드를 작성할 때는 더 이상 사용하면 안된다.
    &lt;ul&gt;
      &lt;li&gt;LocalDateTime 이나 ZonedDateTime 을 사용해야 한다.
        &lt;h2 id=&quot;51-메소드-시그니처를-신중히-설계해라&quot;&gt;51. 메소드 시그니처를 신중히 설계해라.&lt;/h2&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;52-다중-정의는-신중히-사용하라&quot;&gt;52. 다중 정의는 신중히 사용하라.&lt;/h2&gt;

&lt;h2 id=&quot;53-가변-인수는-신중히-사용하라&quot;&gt;53. 가변 인수는 신중히 사용하라.&lt;/h2&gt;

&lt;h2 id=&quot;54-null-이-아닌-빈-컬렉션이나-배열을-반환하라&quot;&gt;54. null 이 아닌 빈 컬렉션이나 배열을 반환하라.&lt;/h2&gt;

&lt;h2 id=&quot;55-optional-반환은-신중히-하라&quot;&gt;55. Optional 반환은 신중히 하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;기존에는 특정 조건에서 반환 값을 리턴할 수 없을때 null 혹은 Exception을 리턴했다.&lt;/li&gt;
  &lt;li&gt;자바8에서는 Optional 이 추가되었다.
    &lt;ul&gt;
      &lt;li&gt;Optional&lt;T&gt;는 null이 아닌 T타입 참조를 하나 담거나, 혹은 아무것도 담지 않을 수 있다.&lt;/T&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;값을 반환하지 못할 가능성이 있고, 호출할 때마다 반환값이 없을 가능성을 염두에 둬야 하는 메소드라면 옵셔널을 반환해야 할 상황일 수 있다.
    &lt;ul&gt;
      &lt;li&gt;하지만 옵셔널에는 성능저하가 같이 오니 null, Exception을 고려하자.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Comparable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Optional&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Collection&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Comparable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;naturalOrder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// 옵셔널 활용 1ㄴㅇ&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lastWord&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;words&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;orElse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;단어없음&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// 옵셔널 활용 2&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Toy&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;toy&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;toys&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;orElseThrow&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;TemperTranException:&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// 옵셔널 활용 3&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Element&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;el&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Elements&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;NOBLE_GASES&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;56-공개된-api-요소에는-항상-문서화-주석을-작성하라&quot;&gt;56. 공개된 API 요소에는 항상 문서화 주석을 작성하라.&lt;/h2&gt;

&lt;h2 id=&quot;57-지역-변수의-범위를-최소화하라&quot;&gt;57. 지역 변수의 범위를 최소화하라.&lt;/h2&gt;

&lt;h2 id=&quot;58-전통적인-for문보다는-for-each-문을-사용하라&quot;&gt;58. 전통적인 for문보다는 for-each 문을 사용하라.&lt;/h2&gt;

&lt;h2 id=&quot;59-라이브러리를-익히고-사용하라&quot;&gt;59. 라이브러리를 익히고 사용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;아래 코드는 문제가 있다.
    &lt;ul&gt;
      &lt;li&gt;n 이 그리크지 않은 2의 제곱수라면 얼마 지나지 않아 같은 수열이 반복된다.&lt;/li&gt;
      &lt;li&gt;n 이 2의 제곱수가 아니라면 몇몇 숫자가 평균적으로 더 자주 반환된다.&lt;/li&gt;
      &lt;li&gt;n 값이 크면 이 현상은 두드러진다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;1차 개선은 Random.nextInt(n)에서 이루어졌다.&lt;/li&gt;
  &lt;li&gt;자바 8에서는 ThreadLocalRandom으로 대체하면 대부분 잘 동작한다. (속도도 빠르다)&lt;/li&gt;
  &lt;li&gt;자바 프로그래머라면 java.lang, java.util, java.io 와 그 하위 패키지는 익숙해야 한다.
    &lt;ul&gt;
      &lt;li&gt;컬렉션 라이브러리, 스트림 라이브러리, 동시성 라이브러리 (java.util.concurrent)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;바퀴를 다시 발명하지 말자.
    &lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;Static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Random&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rnd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Random&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rnd&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;nextInt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;60-정확한-답이-필요하다면-float-double은-피하라&quot;&gt;60. 정확한 답이 필요하다면, float, double은 피하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;System.out.println(1.03 - 0.42) = 0.6100000000001을 출력한다.&lt;/li&gt;
  &lt;li&gt;System.out.println(1.00 - 9 * 0.10) = 0.099999999999를 출력한다.&lt;/li&gt;
  &lt;li&gt;금융쪽 코드에는 BigDecimal을 사용하라.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;61-박싱된-기본-타입보다는-기본-타입을-사용하라&quot;&gt;61. 박싱된 기본 타입보다는 기본 타입을 사용하라.&lt;/h2&gt;

&lt;h2 id=&quot;62-다른-타입이-적절하다면-문자열은-피하라&quot;&gt;62. 다른 타입이 적절하다면 문자열은 피하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;문자열을 잘못사용하는 흔한 예로는 기본타입, 열거타입, 혼합타입이 있다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;63-문자열-연결은-느리니-주의하자&quot;&gt;63. 문자열 연결은 느리니 주의하자.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;String보다는 StringBuilder를 쓰자.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;64-객체는-인터페이스를-활용해-참조하자&quot;&gt;64. 객체는 인터페이스를 활용해 참조하자.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;다형성에 대한 이슈.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;65리플렉션보다는-인터페이스를-사용하라&quot;&gt;65.리플렉션보다는 인터페이스를 사용하라.&lt;/h2&gt;

&lt;h2 id=&quot;66-네이티브-메소드는-신중히-사용하라&quot;&gt;66. 네이티브 메소드는 신중히 사용하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;네이티브 메소드의 주요 쓰임새 3가지
    &lt;ul&gt;
      &lt;li&gt;레지스트리 같은 플랫폼 특화 기능을 사여ㅛㅇ한다.&lt;/li&gt;
      &lt;li&gt;네이티브 코드로 작성된 기존 라이브러리를 사용한다.&lt;/li&gt;
      &lt;li&gt;성능 개선을 목적으로 성능에 결정적인 영향을 주는 영역만 따로 네이티브 언어로 작성한다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;성능을 개선할 목적으로 네이티브 메소드를 사용하는 것은 권장하지 않는다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;67-최적화는-신중히-하라&quot;&gt;67. 최적화는 신중히 하라.&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;빠른 프로그램보다 좋은 프로그램을 작성하라.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;68-일반적으로-통용되는-명명규칙을-따라라&quot;&gt;68. 일반적으로 통용되는 명명규칙을 따라라.&lt;/h2&gt;

&lt;h2 id=&quot;69-예외는-진짜-예외-상황에서만-사용하라&quot;&gt;69. 예외는 진짜 예외 상황에서만 사용하라.&lt;/h2&gt;

&lt;h2 id=&quot;70-복구할-수-있는-상황에서는-검사-예외-불가능한-경우는-런타임-예외-활용&quot;&gt;70. 복구할 수 있는 상황에서는 검사 예외, 불가능한 경우는 런타임 예외 활용&lt;/h2&gt;

&lt;h2 id=&quot;71-필요없는-검사-예외-사용은-피하라&quot;&gt;71. 필요없는 검사 예외 사용은 피하라.&lt;/h2&gt;

&lt;h2 id=&quot;72-표준-예외를-사용하라&quot;&gt;72. 표준 예외를 사용하라,&lt;/h2&gt;

&lt;h2 id=&quot;73-추상화-예외-수준에-맞는-예외를-던져라&quot;&gt;73. 추상화 예외 수준에 맞는 예외를 던져라.&lt;/h2&gt;

&lt;h2 id=&quot;-예외-패스&quot;&gt;… 예외 패스&lt;/h2&gt;

&lt;h2 id=&quot;78-공유중인-가변-데이터는-동기화-해-사용하라&quot;&gt;78. 공유중인 가변 데이터는 동기화 해 사용하라.&lt;/h2&gt;

&lt;h2 id=&quot;79-과도한-동기화는-피하라&quot;&gt;79. 과도한 동기화는 피하라.&lt;/h2&gt;

&lt;h2 id=&quot;80-스레드보다는-executor-task-stream을-애용하라&quot;&gt;80. 스레드보다는 Executor, Task, Stream을 애용하라.&lt;/h2&gt;

&lt;h2 id=&quot;81-wait-notify-보다는-동시성-유틸리티를-애용하라&quot;&gt;81. wait, notify 보다는 동시성 유틸리티를 애용하라.&lt;/h2&gt;

&lt;h2 id=&quot;82-스레드-안정성-수준을-문서화-하라&quot;&gt;82. 스레드 안정성 수준을 문서화 하라.&lt;/h2&gt;

&lt;h2 id=&quot;83-lazy-initialization은-신중히-사용하라&quot;&gt;83. Lazy Initialization은 신중히 사용하라.&lt;/h2&gt;

&lt;h2 id=&quot;84-프로그램-동작을-스레드-스케쥴러에-기대지-말라&quot;&gt;84. 프로그램 동작을 스레드 스케쥴러에 기대지 말라.&lt;/h2&gt;

&lt;h2 id=&quot;85-자바-직렬화의-대안을-찾으라&quot;&gt;85. 자바 직렬화의 대안을 찾으라.&lt;/h2&gt;

&lt;h2 id=&quot;86-serializable을-구현할지는-신중히-선택하라&quot;&gt;86. Serializable을 구현할지는 신중히 선택하라.&lt;/h2&gt;

&lt;h2 id=&quot;87-커스텀-직렬화-형태를-고려해보라&quot;&gt;87. 커스텀 직렬화 형태를 고려해보라.&lt;/h2&gt;

&lt;h2 id=&quot;88-readobject-방어적으로-작성하라&quot;&gt;88. readObject() 방어적으로 작성하라.&lt;/h2&gt;

&lt;h2 id=&quot;89-인스턴스-수를-통제해야-한다면-readresolve보다는-열거-타입을-사용하라&quot;&gt;89. 인스턴스 수를 통제해야 한다면 readResolve보다는 열거 타입을 사용하라,&lt;/h2&gt;

&lt;h2 id=&quot;90-직렬화된-인스턴스-대신-직렬화-프록시-사용을-검토하라&quot;&gt;90. 직렬화된 인스턴스 대신 직렬화 프록시 사용을 검토하라.&lt;/h2&gt;

&lt;h1 id=&quot;reference&quot;&gt;Reference&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;이펙티브 자바 3판&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;history&quot;&gt;History&lt;/h1&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;날짜&lt;/th&gt;
      &lt;th&gt;정리 장수&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;2019-01-02&lt;/td&gt;
      &lt;td&gt;1~7장&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2019-01-04&lt;/td&gt;
      &lt;td&gt;8장&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2019-0106&lt;/td&gt;
      &lt;td&gt;제목만 일단 다 적는다.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
</description>
        <pubDate>Wed, 02 Jan 2019 00:00:00 +0000</pubDate>
        <link>https://simongs.github.io/2019/01/02/BOOK-effective-java-3E/</link>
        <guid isPermaLink="true">https://simongs.github.io/2019/01/02/BOOK-effective-java-3E/</guid>
        
        
        <category>JAVA</category>
        
        <category>BOOK</category>
        
      </item>
    
      <item>
        <title>Vue.js 핵심내용 정리하기</title>
        <description>&lt;h2 id=&quot;instance-vs-component&quot;&gt;Instance VS Component&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Vue Instance
    &lt;ul&gt;
      &lt;li&gt;뷰 인스턴시는 뷰로 화면을 개발하기 위해 필수적으로 생성하는 기본단위&lt;/li&gt;
      &lt;li&gt;
        인스턴스 생성 방법

        &lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 인스턴스&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'#app'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// el 속성&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;     &lt;span class=&quot;c1&quot;&gt;// data 속성&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Hello'&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
      &lt;li&gt;new Vue() 는 생성자
        &lt;ul&gt;
          &lt;li&gt;뷰 라이브러리를 로딩하고 나면 접근가능&lt;/li&gt;
          &lt;li&gt;el, data는 미리 정의되어 있는 속성&lt;/li&gt;
          &lt;li&gt;그 외에 template, methods, created 속성&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;new Vue() 후 인스턴스 옵션 적용 과정
    &lt;ul&gt;
      &lt;li&gt;Vue Library Loading&lt;/li&gt;
      &lt;li&gt;Create Instance&lt;/li&gt;
      &lt;li&gt;Attach Inmstance To Element&lt;/li&gt;
      &lt;li&gt;인스턴스 내용이 화면 요소로 변환&lt;/li&gt;
      &lt;li&gt;변환된 화면 요소를 사용자가 최종 확인&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Vue Instance 의 Life Cycle
    &lt;ul&gt;
      &lt;li&gt;크게 생성, 부착, 갱신, 소멸 상태를 거친다.&lt;/li&gt;
      &lt;li&gt;인스턴스 생성
        &lt;ul&gt;
          &lt;li&gt;이벤트 및 라이프사이클 초기화&lt;/li&gt;
          &lt;li&gt;beforeCreate
            &lt;ul&gt;
              &lt;li&gt;data, methods 속성은 아직 정의되지 않음&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
          &lt;li&gt;화면에 반응성 주입&lt;/li&gt;
          &lt;li&gt;created&lt;/li&gt;
          &lt;li&gt;el, template 속성 확인&lt;/li&gt;
          &lt;li&gt;template 속성 내용을 render()로 변환&lt;/li&gt;
          &lt;li&gt;beforeMount&lt;/li&gt;
          &lt;li&gt;$el 생성 후 el 속성 값을 대입&lt;/li&gt;
          &lt;li&gt;mounted&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;인스턴스를 화면에 부착
        &lt;ul&gt;
          &lt;li&gt;인스턴스의 데이터 변경&lt;/li&gt;
          &lt;li&gt;beforeUpdate&lt;/li&gt;
          &lt;li&gt;화면 재 랜더링 및 데이터 갱신&lt;/li&gt;
          &lt;li&gt;updated&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;인스턴스 내용 갱신
        &lt;ul&gt;
          &lt;li&gt;인스턴스 접근 가능&lt;/li&gt;
          &lt;li&gt;beforeDestory&lt;/li&gt;
          &lt;li&gt;컴포넌트, 인스턴스, 디렉티브 등 모두 해제&lt;/li&gt;
          &lt;li&gt;destoryed&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;인스턴스 소멸&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Tue, 25 Dec 2018 00:00:00 +0000</pubDate>
        <link>https://simongs.github.io/2018/12/25/FRONT-Vue.js-%EC%A0%95%EB%A6%AC%ED%95%98%EA%B8%B0/</link>
        <guid isPermaLink="true">https://simongs.github.io/2018/12/25/FRONT-Vue.js-%EC%A0%95%EB%A6%AC%ED%95%98%EA%B8%B0/</guid>
        
        
        <category>ETC</category>
        
        <category>DEV-TOOLS</category>
        
        <category>FRONT</category>
        
      </item>
    
      <item>
        <title>MAC에서 Vue.js 관련 개발환경 세팅하기</title>
        <description>&lt;h2 id=&quot;nodejs-설치&quot;&gt;NodeJS 설치&lt;/h2&gt;
&lt;h3 id=&quot;nvm-설치&quot;&gt;nvm 설치&lt;/h3&gt;
&lt;h3 id=&quot;nodejs-설치-1&quot;&gt;nodejs 설치&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;nvm use 명령어를 통해 node 버젼을 변경할 수 있다.&lt;/li&gt;
  &lt;li&gt;nvm install node
    &lt;ul&gt;
      &lt;li&gt;최신버젼 설치&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;nvm istall v10
    &lt;ul&gt;
      &lt;li&gt;v10 버젼대의 LTS 버젼 설치. /(ex.v10.42.2)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#가장최산버전 설치
➜  workspace-vue nvm install node
➜  workspace-vue nvm ls-remote
       v10.14.2   (Latest LTS: Dubnium)
        v11.0.0
        v11.1.0
        v11.2.0
        v11.3.0
        v11.4.0
-&amp;gt;      v11.5.0
➜  workspace-vue nvm install node v10.14.2
v11.5.0 is already installed.
Now using node v11.5.0 (npm v6.4.1)
➜  workspace-vue nvm install v10
Downloading and installing node v10.14.2...
Downloading https://nodejs.org/dist/v10.14.2/node-v10.14.2-darwin-x64.tar.gz...
######################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v10.14.2 (npm v6.4.1)
➜  workspace-vue nvm use v10
Now using node v10.14.2 (npm v6.4.1)
➜  workspace-vue nvm use v11
Now using node v11.5.0 (npm v6.4.1)
➜  workspace-vue nvm use v10
Now using node v10.14.2 (npm v6.4.1)

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;reference&quot;&gt;Reference&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;https://github.com/creationix/nvm&lt;/li&gt;
  &lt;li&gt;https://gist.github.com/TeddyH/57aadd2bd31edc2e7c6dc410b95548bc&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;visual-studio-code-세팅&quot;&gt;Visual Studio Code 세팅&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Vue를 쉽게 사용하기 위한 플러그인 설치 (vetur//)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;extension-program&quot;&gt;Extension Program&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;https://vuejs.github.io/vetur/
    &lt;ul&gt;
      &lt;li&gt;Vue 하이라이팅,&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 24 Dec 2018 00:00:00 +0000</pubDate>
        <link>https://simongs.github.io/2018/12/24/VUE-Mac-Vue.js-%EA%B0%9C%EB%B0%9C%ED%99%98%EA%B2%BD-%EC%84%B8%ED%8C%85%ED%95%98%EA%B8%B0/</link>
        <guid isPermaLink="true">https://simongs.github.io/2018/12/24/VUE-Mac-Vue.js-%EA%B0%9C%EB%B0%9C%ED%99%98%EA%B2%BD-%EC%84%B8%ED%8C%85%ED%95%98%EA%B8%B0/</guid>
        
        
        <category>ETC</category>
        
        <category>DEV-TOOLS</category>
        
      </item>
    
      <item>
        <title>[ETC] Docker with Mac</title>
        <description>&lt;h2 id=&quot;설치&quot;&gt;설치&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;공식 Reference Site 따라함&lt;/li&gt;
  &lt;li&gt;Download 링크
    &lt;ul&gt;
      &lt;li&gt;https://hub.docker.com/editions/community/docker-ce-desktop-mac&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;img src=&quot;http://prntscr.com/ly7aoo&quot; alt=&quot;Docker 상단 이미지&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;terminal&quot;&gt;Terminal&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;postgres 이미지 다운로드 및 컨테이너 실행
    &lt;ul&gt;
      &lt;li&gt;docker ps
        &lt;ul&gt;
          &lt;li&gt;현재 실행중인 Docker 프로세스를 보여준다.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;docker ps -a
        &lt;ul&gt;
          &lt;li&gt;현재 일시정지된 Docker 프로세스까지 보여준다.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;docker images
        &lt;ul&gt;
          &lt;li&gt;다운로드돤 이미지 파일들을 보여준다.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;docker run hello-world
        &lt;ul&gt;
          &lt;li&gt;현재 로컬에 있는 hello-world 이미지를 수행한다.&lt;/li&gt;
          &lt;li&gt;로컬에 해당 이미지가 없다면 Docker Remote Repository에 해당 이미지명의 가장 최신 이미지를 가져온다.&lt;/li&gt;
          &lt;li&gt;docker run –name demo -e POSTGRES_PASS=password -d postgres&lt;/li&gt;
          &lt;li&gt;docker run -p 5432:5432 -e POSTGRES_PASS=password -e POSTGRES_USER=simons -e POSTGRES_DB=springdata –name demo -d postgres&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;docker exec -it demo bash&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;postgresql-문법&quot;&gt;postgresql 문법&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;\d+ tablename
    &lt;ul&gt;
      &lt;li&gt;table 스키마 보기&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;\dt
    &lt;ul&gt;
      &lt;li&gt;table 리스트 보기&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;reference&quot;&gt;Reference&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 12 Nov 2018 00:00:00 +0000</pubDate>
        <link>https://simongs.github.io/2018/11/12/ETC-Docker-with-Mac/</link>
        <guid isPermaLink="true">https://simongs.github.io/2018/11/12/ETC-Docker-with-Mac/</guid>
        
        
        <category>ETC</category>
        
        <category>DEV-TOOLS</category>
        
      </item>
    
      <item>
        <title>[JAVA] Bootiful Spring Boot and React</title>
        <description>
Bootiful Development with Spring Boot and React

http https://start.spring.io/starter.zip dependencies=h2,data-jpa, data-rest, web -d

Reference
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=P6rwKHnXUJI&quot;&gt;Bootiful Development with Spring Boot and React&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;https://developer.okta.com/blog/2017/12/06/bootiful-development-with-spring-boot-and-react&lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Tue, 26 Jun 2018 00:00:00 +0000</pubDate>
        <link>https://simongs.github.io/2018/06/26/JAVA-Bootiful-Spring-Boot-and-React/</link>
        <guid isPermaLink="true">https://simongs.github.io/2018/06/26/JAVA-Bootiful-Spring-Boot-and-React/</guid>
        
        
        <category>JAVA</category>
        
        <category>SPRING</category>
        
      </item>
    
      <item>
        <title>[JAVA] BOM 그리고 POM</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#bom-bill-of-materials&quot; id=&quot;markdown-toc-bom-bill-of-materials&quot;&gt;BOM (Bill Of Materials)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#pom&quot; id=&quot;markdown-toc-pom&quot;&gt;POM&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#bom-sample&quot; id=&quot;markdown-toc-bom-sample&quot;&gt;BOM Sample&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#how-to-use-bom&quot; id=&quot;markdown-toc-how-to-use-bom&quot;&gt;How to use BOM&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#spring-bom-file&quot; id=&quot;markdown-toc-spring-bom-file&quot;&gt;Spring BOM File&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#how-to-use-pom&quot; id=&quot;markdown-toc-how-to-use-pom&quot;&gt;How to Use POM&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#gradle-의-dependency-관리&quot; id=&quot;markdown-toc-gradle-의-dependency-관리&quot;&gt;GRADLE 의 Dependency 관리&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#iospringdependency-management&quot; id=&quot;markdown-toc-iospringdependency-management&quot;&gt;io.spring.dependency-management&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#buildproperties&quot; id=&quot;markdown-toc-buildproperties&quot;&gt;build.properties&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#또-다른-bom-byte-order-mark-&quot; id=&quot;markdown-toc-또-다른-bom-byte-order-mark-&quot;&gt;또 다른 BOM (Byte Order Mark )&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#bom-정보&quot; id=&quot;markdown-toc-bom-정보&quot;&gt;BOM 정보&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#bom의-side-effect&quot; id=&quot;markdown-toc-bom의-side-effect&quot;&gt;BOM의 Side Effect&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#reference&quot; id=&quot;markdown-toc-reference&quot;&gt;Reference&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;bom-bill-of-materials&quot;&gt;BOM (Bill Of Materials)&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Bill Of Materials 의 약자&lt;/li&gt;
  &lt;li&gt;일종의 특별한 POM 파일&lt;/li&gt;
  &lt;li&gt;프로젝트에서 사용하는 Dependency들을 한 곳에서 관리하고 싶을 때 사용한다.&lt;/li&gt;
  &lt;li&gt;
    &lt;dependencyManagement&gt; 섹션을 사용함

&lt;/dependencyManagement&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;pom&quot;&gt;POM&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;프로젝트의 정보 및 설정을 담고 있는 XML 파일&lt;/li&gt;
  &lt;li&gt;프로젝트를 빌드하기 위한 Dependency 를 관리하는데 사용된다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;bom-sample&quot;&gt;BOM Sample&lt;/h2&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;project&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;modelVersion&amp;gt;&lt;/span&gt;4.0.0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/modelVersion&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;baeldung&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;Baeldung-BOM&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;0.0.1-SNAPSHOT&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;packaging&amp;gt;&lt;/span&gt;pom&lt;span class=&quot;nt&quot;&gt;&amp;lt;/packaging&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;name&amp;gt;&lt;/span&gt;BaelDung-BOM&lt;span class=&quot;nt&quot;&gt;&amp;lt;/name&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;description&amp;gt;&lt;/span&gt;parent pom&lt;span class=&quot;nt&quot;&gt;&amp;lt;/description&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependencyManagement&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependencies&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;test&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;a&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;1.2&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;test&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;b&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;1.0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
                &lt;span class=&quot;nt&quot;&gt;&amp;lt;scope&amp;gt;&lt;/span&gt;compile&lt;span class=&quot;nt&quot;&gt;&amp;lt;/scope&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependencies&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependencyManagement&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;how-to-use-bom&quot;&gt;How to use BOM&lt;/h2&gt;

▶ CASE 1

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;project&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;parent&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;baeldung&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;Baeldung-BOM&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;0.0.1-SNAPSHOT&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/parent&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

▶ CASE 2

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;dependencyManagement&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependencies&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;baeldung&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;Baeldung-BOM&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;0.0.1-SNAPSHOT&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;type&amp;gt;&lt;/span&gt;pom&lt;span class=&quot;nt&quot;&gt;&amp;lt;/type&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;scope&amp;gt;&lt;/span&gt;import&lt;span class=&quot;nt&quot;&gt;&amp;lt;/scope&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependencies&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependencyManagement&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;spring-bom-file&quot;&gt;Spring BOM File&lt;/h2&gt;
&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;dependencyManagement&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependencies&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-framework-bom&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;4.3.8.RELEASE&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;type&amp;gt;&lt;/span&gt;pom&lt;span class=&quot;nt&quot;&gt;&amp;lt;/type&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;&amp;lt;scope&amp;gt;&lt;/span&gt;import&lt;span class=&quot;nt&quot;&gt;&amp;lt;/scope&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependencies&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependencyManagement&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;how-to-use-pom&quot;&gt;How to Use POM&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;POM에서는 기정의된 Dependency Version이 존재하므로 Version 정보없이 기입가능&lt;/li&gt;
  &lt;li&gt;BOM에 명시된 Version 정보를 가져온다.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;dependencies&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-context&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-web&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;dependencies&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;gradle-의-dependency-관리&quot;&gt;GRADLE 의 Dependency 관리&lt;/h2&gt;

&lt;h3 id=&quot;iospringdependency-management&quot;&gt;io.spring.dependency-management&lt;/h3&gt;

&lt;h3 id=&quot;buildproperties&quot;&gt;build.properties&lt;/h3&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;buildscript &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    dependencies &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        classpath &lt;span class=&quot;s1&quot;&gt;'io.spring.gradle:dependency-management-plugin:$Version'&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

configure&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;allprojects&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    apply plugin: &lt;span class=&quot;s1&quot;&gt;'io.spring.dependency-management'&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;# MAVEN의 &amp;lt;dependencyManagement&amp;gt; 섹션과 동일한 역할&lt;/span&gt;
    dependencyManagement &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        imports &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            mavenBom &lt;span class=&quot;s1&quot;&gt;'io.spring.platform:platform-bom:$Version'&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;또-다른-bom-byte-order-mark-&quot;&gt;또 다른 BOM (Byte Order Mark )&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Byte Order Mark 의 약자&lt;/li&gt;
  &lt;li&gt;유니코드 인코딩에 여러가지 방식이 존재하여 생긴 이슈&lt;/li&gt;
  &lt;li&gt;문서 앞에 Signature 바이트를 넣는다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;bom-정보&quot;&gt;BOM 정보&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;인코딩 방식&lt;/th&gt;
      &lt;th&gt;Byte Order Mark(BOM)&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;UTF-8&lt;/td&gt;
      &lt;td&gt;EF BB BF&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;UTF-16 Big Endian&lt;/td&gt;
      &lt;td&gt;FE FF&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;UTF-16 Little Endian&lt;/td&gt;
      &lt;td&gt;FF FE&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;UTF-32 Big Endian&lt;/td&gt;
      &lt;td&gt;00 00 FE FF&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;UTF-32 Little Endian&lt;/td&gt;
      &lt;td&gt;FF FE 00 00&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;bom의-side-effect&quot;&gt;BOM의 Side Effect&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Windows 환경에서 작성한 파일을 Linux 환경으로 올렸을 때 Byte 수가 맞지 않는 경우 발생&lt;/li&gt;
  &lt;li&gt;Windows 의 NotePad 등은 UTF-8 파일을 생성할때 자동으로 BOM을 넣는다.&lt;/li&gt;
  &lt;li&gt;파일의 크기가 예상과는 다른 상황이 발생할 수 있다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;reference&quot;&gt;Reference&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.baeldung.com/spring-maven-bom&quot;&gt;Spring With Maven BOM&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://whiteship.tistory.com/1600&quot;&gt;기본적인 Managed Dependency 사용법&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.wystan.net/2007/08/18/bom-byte-order-mark-problem&quot;&gt;UTF-8 인코딩에서의 BOM(Byte Order Mark) 문제&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 27 Feb 2018 00:00:00 +0000</pubDate>
        <link>https://simongs.github.io/2018/02/27/JAVA-Bom-%EA%B7%B8%EB%A6%AC%EA%B3%A0-Pom/</link>
        <guid isPermaLink="true">https://simongs.github.io/2018/02/27/JAVA-Bom-%EA%B7%B8%EB%A6%AC%EA%B3%A0-Pom/</guid>
        
        
        <category>JAVA</category>
        
        <category>SPRING</category>
        
      </item>
    
      <item>
        <title>[JAVA] Servlet 3.X 와 Java 기반 설정</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#servlet&quot; id=&quot;markdown-toc-servlet&quot;&gt;Servlet&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#javaxservletservletcontainerinitializer&quot; id=&quot;markdown-toc-javaxservletservletcontainerinitializer&quot;&gt;javax.servlet.ServletContainerInitializer&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#spring에서-구현한-클래스-정보&quot; id=&quot;markdown-toc-spring에서-구현한-클래스-정보&quot;&gt;Spring에서 구현한 클래스 정보&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#text-file&quot; id=&quot;markdown-toc-text-file&quot;&gt;Text File&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#springservletcontainerinitializer&quot; id=&quot;markdown-toc-springservletcontainerinitializer&quot;&gt;SpringServletContainerInitializer&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#reference&quot; id=&quot;markdown-toc-reference&quot;&gt;Reference&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;servlet&quot;&gt;Servlet&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Servlet 3.0 이상부터 Java Based 설정을 제공한다.&lt;/li&gt;
  &lt;li&gt;web.xml 을 이용한 설정도 가능&lt;/li&gt;
  &lt;li&gt;web.xml 없이 자바코드만으로도 설정 가능&lt;/li&gt;
  &lt;li&gt;web.xml 은 ServletContext Object를 초기화하는데 사용하던 메타정보&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;javaxservletservletcontainerinitializer&quot;&gt;javax.servlet.ServletContainerInitializer&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;/META-INF/services/javax.servlet.ServletContainerInitializer 라는 텍스트 파일로 존재한다.&lt;/li&gt;
  &lt;li&gt;해당 파일안에는 구현클래스를 지정하게 된다.&lt;/li&gt;
  &lt;li&gt;web.xml이라는 표준 설정 파일을 없애므로써 클래스패스내의 기반 설정이 되어야 하는 파일을 찾아야 하는데 스캐닝 비용이 부담스러웠다.&lt;/li&gt;
  &lt;li&gt;그래서 명시적인 Text File로 설정 정보를 가지고 있는 구현클래스 정보를 담는다.&lt;/li&gt;
  &lt;li&gt;구현클래스에 @HandlesTypes 를 사용하면 @HandlesTypes 안에 지정한 타입의 클래스를 모조리 찾아서 onStartup()의 파라미터로 넣어준다&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;spring에서-구현한-클래스-정보&quot;&gt;Spring에서 구현한 클래스 정보&lt;/h2&gt;
&lt;h3 id=&quot;text-file&quot;&gt;Text File&lt;/h3&gt;
in /META-INF/services/javax.servlet.ServletContainerInitializer
&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;org.springframework.web.SpringServletContainerInitializer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;springservletcontainerinitializer&quot;&gt;SpringServletContainerInitializer&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;spring-web 컴포넌트에 존재한다.&lt;/li&gt;
  &lt;li&gt;WebApplicationInitializer Type의 클래스를 모조리 찾아서 SpringServletContainerInitializer의 onStartUp() 으로 전달한다.&lt;/li&gt;
  &lt;li&gt;SpringServletContainerInitializer는 직접적으로 ServletContext에 무언가를 등록하지 않는다.&lt;/li&gt;
  &lt;li&gt;모두 WebApplicationInitializer에 위임한다.&lt;/li&gt;
  &lt;li&gt;@Order로 실행순서를 조정하는 역할을 한다.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;org&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;springframework&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;web&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@HandlesTypes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WebApplicationInitializer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SpringServletContainerInitializer&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ServletContainerInitializer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

	&lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
	&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onStartup&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;?&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webAppInitializerClasses&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ServletContext&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;servletContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
			&lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ServletException&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

		&lt;span class=&quot;n&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WebApplicationInitializer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;initializers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LinkedList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WebApplicationInitializer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;();&lt;/span&gt;

		&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;webAppInitializerClasses&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;?&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;waiClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;webAppInitializerClasses&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
				&lt;span class=&quot;c1&quot;&gt;// Be defensive: Some servlet containers provide us with invalid classes,&lt;/span&gt;
				&lt;span class=&quot;c1&quot;&gt;// no matter what @HandlesTypes says...&lt;/span&gt;
				&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;waiClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isInterface&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Modifier&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isAbstract&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;waiClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getModifiers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;
						&lt;span class=&quot;n&quot;&gt;WebApplicationInitializer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isAssignableFrom&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;waiClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
					&lt;span class=&quot;k&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
						&lt;span class=&quot;n&quot;&gt;initializers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WebApplicationInitializer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;waiClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;newInstance&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
					&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
					&lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Throwable&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
						&lt;span class=&quot;k&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;ServletException&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Failed to instantiate WebApplicationInitializer class&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
					&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
				&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
			&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
		&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

		&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;initializers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;servletContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;No Spring WebApplicationInitializer types detected on classpath&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
			&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

		&lt;span class=&quot;n&quot;&gt;servletContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;initializers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot; Spring WebApplicationInitializers detected on classpath&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;AnnotationAwareOrderComparator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;initializers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WebApplicationInitializer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;initializer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;initializers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;initializer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onStartup&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;servletContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;reference&quot;&gt;Reference&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://hashmap27.tistory.com/6?category=664045&quot;&gt;Spring Java Base Configuration&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://toby.epril.com/?tag=webapplicationinitializer&quot;&gt;WebApplicationInitializer을 이용한 컨텍스트 초기화&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Wed, 17 Jan 2018 00:00:00 +0000</pubDate>
        <link>https://simongs.github.io/2018/01/17/JAVA-Servlet-3.X-%EA%B7%B8%EB%A6%AC%EA%B3%A0-Spring/</link>
        <guid isPermaLink="true">https://simongs.github.io/2018/01/17/JAVA-Servlet-3.X-%EA%B7%B8%EB%A6%AC%EA%B3%A0-Spring/</guid>
        
        
        <category>JAVA</category>
        
        <category>SPRING</category>
        
      </item>
    
      <item>
        <title>[JAVA] @Conditional</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#conditional&quot; id=&quot;markdown-toc-conditional&quot;&gt;@Conditional&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#xml-방식&quot; id=&quot;markdown-toc-xml-방식&quot;&gt;XML 방식&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#javaconfig-annotation&quot; id=&quot;markdown-toc-javaconfig-annotation&quot;&gt;JavaConfig, Annotation&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#enable&quot; id=&quot;markdown-toc-enable&quot;&gt;@Enable*&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#profile&quot; id=&quot;markdown-toc-profile&quot;&gt;@Profile&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#conditional-1&quot; id=&quot;markdown-toc-conditional-1&quot;&gt;@Conditional&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#conditional-적용-구조&quot; id=&quot;markdown-toc-conditional-적용-구조&quot;&gt;@Conditional 적용 구조&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#condition-interface&quot; id=&quot;markdown-toc-condition-interface&quot;&gt;Condition Interface&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#condition-활용예제&quot; id=&quot;markdown-toc-condition-활용예제&quot;&gt;Condition 활용예제&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#autoconfiguration&quot; id=&quot;markdown-toc-autoconfiguration&quot;&gt;AutoConfiguration&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#클래스-프록시-개선&quot; id=&quot;markdown-toc-클래스-프록시-개선&quot;&gt;클래스 프록시 개선&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;conditional&quot;&gt;@Conditional&lt;/h2&gt;

&lt;h4 id=&quot;xml-방식&quot;&gt;XML 방식&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;정적인 구조&lt;/li&gt;
  &lt;li&gt;동적스캔지원 (어노테이션)&lt;/li&gt;
  &lt;li&gt;커스텀 태그의 구현에 따른 일부 동적인 설정 (aop, transaction)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;javaconfig-annotation&quot;&gt;JavaConfig, Annotation&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;동적인 빈 등록, 설정&lt;/li&gt;
  &lt;li&gt;@Bean&lt;/li&gt;
  &lt;li&gt;@Enable*&lt;/li&gt;
  &lt;li&gt;@Profile&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;enable&quot;&gt;@Enable*&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;@Configuration 단위 구성&lt;/li&gt;
  &lt;li&gt;@Import 활용&lt;/li&gt;
  &lt;li&gt;해당 이름은 스프링 소스에서 관례적으로 붙은 이름&lt;/li&gt;
  &lt;li&gt;확장방법
    &lt;ul&gt;
      &lt;li&gt;@Configuration 오버라이딩&lt;/li&gt;
      &lt;li&gt;@Import + Metadata/Registry&lt;/li&gt;
      &lt;li&gt;@Configuration + 자바코드 Configurer&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;profile&quot;&gt;@Profile&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;빈 구성 그룹을 선택할 수 있도록 한다.&lt;/li&gt;
  &lt;li&gt;환경에 따라 다르게 적용되는 빈 구성이 가능하다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;conditional-1&quot;&gt;@Conditional&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;@Profile과 같이 특정 조건을 만족했을때 빈을 등록하는 기능을 일반화&lt;/li&gt;
  &lt;li&gt;적용대상
    &lt;ul&gt;
      &lt;li&gt;@Configuration&lt;/li&gt;
      &lt;li&gt;@Bean&lt;/li&gt;
      &lt;li&gt;스테레오 타입 어노테이션&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;세밀하고 동적인 설정 구성 가능&lt;/li&gt;
  &lt;li&gt;Spring Boot 에서 적극적으로 사용한다.
    &lt;ul&gt;
      &lt;li&gt;Spring Boot 에 적용되었던 기술이 Spring 4 로 들어온 케이스&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;conditional-적용-구조&quot;&gt;@Conditional 적용 구조&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;Spring은 @Conditional 의 결과를 보고 Bean 등록여부를 판단한다.&lt;/li&gt;
  &lt;li&gt;@Configuration Level에도 붙일수 있다. (해당 Configuration 하위의 Bean이 모두 대상이 된다.)&lt;/li&gt;
&lt;/ul&gt;

▶ 적용대상
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nd&quot;&gt;@Bean&lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@OnFlag&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;               &lt;span class=&quot;c1&quot;&gt;// 확장1 &lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@Conditional&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MyCondition&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 확장1 &lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@MyConditional&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;// 확장2 &lt;/span&gt;
&lt;span class=&quot;nd&quot;&gt;@MyConditional&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BeanB&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 확장3&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BeanA&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;bean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;BeanA&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

▶ 판단방법
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyCondition&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Condition&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;matches&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ConditionContext&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AnnotatedTypeMetadata&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;metadata&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        
        &lt;span class=&quot;c1&quot;&gt;// 확장1. return (Boolean)metadata.getAnnotationAttributes(OnFlag.class.getName()).get(&quot;value&quot;);&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// 확장2. return (Boolean)metadata.getAnnotationAttributes(MyConditional.class.getName()).get(&quot;value&quot;);&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// 확장3. Class&amp;lt;?&amp;gt; beanClass = (Class&amp;lt;?&amp;gt;)metadata.getAnnotationAttributes(MyConditional.class.getName()).get(&quot;value&quot;);&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;//        try {&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;//            BeanFactoryUtils.beanOfTypeIncludingAncestors(context.getBeanFactory(), beanClass);&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;//            return true;  &lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;//        } catch(NoSuchBeanDefinitionException e) {&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;//            return false;&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;//        }&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

▶ (확장1) OnFlag annotation 개발
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nd&quot;&gt;@Retention&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RetentionPolicy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;RUNTIME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 이 annotation이 언제까지 적용될 것인가? Default는 Class&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;OnFlag&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

▶ (확장2) MyConditional annotation 개발 (OnFlag 를 대체한다.)
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nd&quot;&gt;@Retention&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RetentionPolicy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;RUNTIME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; 
&lt;span class=&quot;nd&quot;&gt;@Conditional&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MyCondition&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Meta Annotation을 정의한다.&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MyConditional&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

▶ (확장3) MyConditional annotation 개발 (특정 Bean이 있을때만 등록한다.)
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nd&quot;&gt;@Retention&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RetentionPolicy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;RUNTIME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; 
&lt;span class=&quot;nd&quot;&gt;@Conditional&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MyCondition&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Meta Annotation을 정의한다.&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nd&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MyConditional&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;?&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;condition-interface&quot;&gt;Condition Interface&lt;/h4&gt;
▶ method code
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;matches&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ConditionContext&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AnnotatedTypeMetadata&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;metadata&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
     
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

▶ ConditionContext
&lt;ul&gt;
  &lt;li&gt;BeanFactory 등등 정보를 가짐&lt;/li&gt;
&lt;/ul&gt;

▶ AnnotatedTypeMetadata
&lt;ul&gt;
  &lt;li&gt;@Conditional 이 붙은 위치의 모든 annotation 정보를 가져온다.
    &lt;ul&gt;
      &lt;li&gt;위의 예제는 @Bean, @OnFlag, @Conditional 정보를 담고 있다.&lt;/li&gt;
      &lt;li&gt;RetentionPolicy.RUNTIME 만 실제 값을 가져올 수 있다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;condition-활용예제&quot;&gt;Condition 활용예제&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;@Profile&lt;/li&gt;
  &lt;li&gt;Spring Boot 프로젝트의 AutoConfiguration
    &lt;ul&gt;
      &lt;li&gt;OnBeanCondition : bean이 있느냐 없느냐&lt;/li&gt;
      &lt;li&gt;OnClassCondition : classpath에 있으냐 없느냐&lt;/li&gt;
      &lt;li&gt;OnExpressionCondition : SPEL 에 매칭이 되느냐&lt;/li&gt;
      &lt;li&gt;OnJavaCondition : Java Version 에 따라&lt;/li&gt;
      &lt;li&gt;OnPropertyCondition : Property Value 에 따라&lt;/li&gt;
      &lt;li&gt;OnResourceCondition : Resource의 존재유무&lt;/li&gt;
      &lt;li&gt;OnWebApplicationCondition : 현재 WEB 기반의 어플리케이션인지 판단한다.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;autoconfiguration&quot;&gt;AutoConfiguration&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;@Configuration 과 @Conditional 의 조합이다.&lt;/li&gt;
  &lt;li&gt;각종 조건 및 환경에 맞는 빈 구성 및 설정 정보&lt;/li&gt;
  &lt;li&gt;Default Bean 구성으로 빠르게 시작해서 점진적으로 설정을 추가 확장
    &lt;ul&gt;
      &lt;li&gt;@ConditionalOnMissingBean
        &lt;ul&gt;
          &lt;li&gt;개발자가 직접 등록한 빈이 있으면 사용하고 없으면 Default Bean을 등록한다.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;SpringBoot의 다양한 적용방법 참고&lt;/li&gt;
  &lt;li&gt;@Enable* 조합&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;클래스-프록시-개선&quot;&gt;클래스 프록시 개선&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;기존 클래스 프록시 방식의 단점
    &lt;ul&gt;
      &lt;li&gt;클래스 생성자 2번 호출 (proxy + target)&lt;/li&gt;
      &lt;li&gt;디폴트 생성자만 사용가능 (CGLib)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;개선된 클래스 프록시
    &lt;ul&gt;
      &lt;li&gt;클래스 생성자 1번만 호출&lt;/li&gt;
      &lt;li&gt;임의의 생성자 사용 가능&lt;/li&gt;
      &lt;li&gt;Objenesis와 확장된 CGLib&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Thu, 11 Jan 2018 00:00:00 +0000</pubDate>
        <link>https://simongs.github.io/2018/01/11/JAVA-@Conditional/</link>
        <guid isPermaLink="true">https://simongs.github.io/2018/01/11/JAVA-@Conditional/</guid>
        
        
        <category>JAVA</category>
        
        <category>SPRING</category>
        
      </item>
    
  </channel>
</rss>
