<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by 최인탁 on Medium]]></title>
        <description><![CDATA[Stories by 최인탁 on Medium]]></description>
        <link>https://medium.com/@itsnothingg?source=rss-cfb7ed030036------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*nZTSMEXIbEgxOM2F.</url>
            <title>Stories by 최인탁 on Medium</title>
            <link>https://medium.com/@itsnothingg?source=rss-cfb7ed030036------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 23:06:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@itsnothingg/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[So I was setting <table> column width wrong..]]></title>
            <link>https://itsnothingg.medium.com/so-i-was-setting-table-column-width-wrong-153fd6920940?source=rss-cfb7ed030036------2</link>
            <guid isPermaLink="false">https://medium.com/p/153fd6920940</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[최인탁]]></dc:creator>
            <pubDate>Tue, 27 Jun 2023 07:37:16 GMT</pubDate>
            <atom:updated>2023-06-27T23:25:05.968Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s say we have a table like this in our page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KQBWN3AWWsB50-JNVielKg.png" /><figcaption><a href="https://gist.github.com/itsnothingg/7f0d4170753c7a47952dea9d18964cad#file-first-html">https://gist.github.com/itsnothingg/7f0d4170753c7a47952dea9d18964cad#file-first-html</a></figcaption></figure><p>This table does not have any width configuration. No &lt;col&gt; tag or “width:” style.</p><p>Still, it looks neat. Even without manual width configuration, modern browser manages to find out optimal column width.</p><h4>But here’s the catch.</h4><p>There may be columns in which the length of the content can change dynamically. In our table above, the <strong>category</strong> column and the <strong>product</strong> column apply to that case.</p><p>For example, when category or product text gets longer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nWeCdpZN4Rl-AbL0og2WNw.png" /><figcaption><a href="https://gist.github.com/itsnothingg/7f0d4170753c7a47952dea9d18964cad#file-first-html">https://gist.github.com/itsnothingg/7f0d4170753c7a47952dea9d18964cad#file-second-html</a></figcaption></figure><p>We can see column widths have been readjusted according to its content. Therefore every column after product is right shifted.</p><p>So this is what’s gonna happen when we auto layout table columns. if length of the contents are consistent, we are good to go. But if the contents are something dynamic, things like user input values, it will have huge impact on user experience since such inconsistency highly decreases readability.</p><p>To solve the issue, we have to <strong>fix the table layout and set width for each column. </strong>And one of the common way to do so is by using the <strong>&lt;col&gt;</strong> tag.</p><pre>&lt;table style=&quot;{ table-layout: fixed; }&quot;&gt;<br>  &lt;colgroup&gt;<br>    &lt;col style=&quot;width:4%&quot; /&gt;   &lt;!-- Checkbox --&gt;<br>    &lt;col style=&quot;width:*&quot; /&gt;    &lt;!-- Product --&gt; &lt;!-- NOTE: Giving asterisk or empty width to col mean to occupy remaining space.--&gt;<br>    &lt;col style=&quot;width:13%&quot; /&gt;  &lt;!-- Category --&gt;<br>    &lt;col style=&quot;width:7%&quot; /&gt;   &lt;!-- Stock --&gt;<br>    &lt;col style=&quot;width:8%&quot; /&gt;   &lt;!-- Sales/Day --&gt;<br>    &lt;col style=&quot;width:9%&quot; /&gt;   &lt;!-- Sales/Month --&gt;<br>    &lt;col style=&quot;width:13%&quot; /&gt;  &lt;!-- Rating --&gt;<br>    &lt;col style=&quot;width:8%&quot; /&gt;   &lt;!-- Sales --&gt;<br>    &lt;col style=&quot;width:7%&quot; /&gt;   &lt;!-- Revenue --&gt;<br>    &lt;col style=&quot;width:10%&quot; /&gt;  &lt;!-- Last Update --&gt;<br>  &lt;/colgroup&gt;<br>  &lt;thead&gt;<br>      ...</pre><h4><strong>Note that percentage values here are not calculated automatically.</strong></h4><p>We have to divide 100 by number of column (here its 100 / 10), then we increase/decrease the value based on expected content length of the column.</p><p>Adding above configuration produces following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OA9Gx0aDHKw91p7p7o5Fgg.png" /><figcaption><a href="https://gist.github.com/itsnothingg/7f0d4170753c7a47952dea9d18964cad#file-first-html">https://gist.github.com/itsnothingg/7f0d4170753c7a47952dea9d18964cad#file-third-html</a></figcaption></figure><p>Looks even better. And for the current width configuration, no matter how long the content becomes, columns will stay fixed.</p><h3>lets take step further.</h3><p>Now we are required to add 4 more columns to our table. Columns we need to add are:</p><ol><li>Product Id</li><li>Manufacturer</li><li>Comments</li><li>Actions</li></ol><p>Let’s add those columns and fill some data. And<strong> for now let’s comment out &lt;colgroup&gt; and even out all column widths (keeping table layout fixed)</strong>. Then the table becomes like this:</p><pre>&lt;table&gt;<br>    &lt;!-- &lt;colgroup&gt;<br>      &lt;col /&gt;<br>      &lt;col /&gt;<br>      &lt;col /&gt;<br>      &lt;col /&gt;<br>      &lt;col /&gt;<br>      &lt;col /&gt;<br>      &lt;col /&gt;<br>      &lt;col /&gt;<br>      &lt;col /&gt;<br>      &lt;col /&gt;<br>      &lt;col /&gt;<br>      &lt;col /&gt;<br>      &lt;col /&gt;<br>      &lt;col /&gt;<br>    &lt;/colgroup&gt; --&gt;<br>...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PxSDVanL84BbsHhDsY58cw.png" /><figcaption><a href="https://gist.github.com/itsnothingg/7f0d4170753c7a47952dea9d18964cad#file-first-html">https://gist.github.com/itsnothingg/7f0d4170753c7a47952dea9d18964cad#file-fourth-html</a></figcaption></figure><p>Obviously, This is not how we wanna display our table. We have to set appropriate width to each column.</p><p>We have 14 columns now. What is the best way to divide 100% width into 14 columns? Maybe we can throw some arbitrary value based on some basic calculation (100/number of column) and keep adjusting from there. That is how I got the numbers on the third table on this post. And this is kind of work that we’re all frustrated to do.</p><p>And as you might have noticed, this is where I got totally wrong. I thought just like any other DOM, table columns also should add up to 100%. I learned only recently that</p><h3>When the table’s layout is fixed, Columns can have relative widths.</h3><p>For example, we might misunderstand following column as 2 columns having total of 20% of the table.</p><pre>&lt;colgroup&gt;<br>  &lt;col style=&quot;width: 10%&quot; /&gt;<br>  &lt;col style=&quot;width: 10%&quot; /&gt;<br>&lt;/colgroup&gt;</pre><h4>But in fact, each column occupied 50% of the table. Width is just relative value among the columns.</h4><p>After knowing that, it became super easy to adjust widths value to the columns.</p><p>Here’s the final version of the table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iW8-7EdOI0BaJhVpyH4STw.png" /><figcaption><a href="https://gist.github.com/itsnothingg/7f0d4170753c7a47952dea9d18964cad#file-first-html">https://gist.github.com/itsnothingg/7f0d4170753c7a47952dea9d18964cad#file-fifth-html</a></figcaption></figure><p>It didn’t even took me a 30 seconds to find out the optimized column width to the table.</p><p>First just set all the column widths to same arbitrary value (5% here). It will make every columns width even.</p><pre>&lt;colgroup&gt;<br>  &lt;col style=&quot;width: 5%&quot; /&gt;<br>  &lt;col style=&quot;width: 5%&quot; /&gt;<br>  &lt;col style=&quot;width: 5%&quot; /&gt;<br>  &lt;col style=&quot;width: 5%&quot; /&gt;<br>  &lt;col style=&quot;width: 5%&quot; /&gt;<br>  &lt;col style=&quot;width: 5%&quot; /&gt;<br>  ....<br>&lt;/colgroup&gt;</pre><p>And then all I have to think about is the width relative to that 5%. If I want column twice longer, 10%. Half shorter than 2.5%. It goes on.</p><p>That’s it.</p><p>Hopefully my life afterward is a lot going to be easier :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=153fd6920940" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[애플처럼 까리한 스크롤 기반 애니메이션을 맨들어보자!]]></title>
            <link>https://itsnothingg.medium.com/%EC%95%A0%ED%94%8C%EC%B2%98%EB%9F%BC-%EA%B9%8C%EB%A6%AC%ED%95%9C-%EC%8A%A4%ED%81%AC%EB%A1%A4-%EA%B8%B0%EB%B0%98-%EC%95%A0%EB%8B%88%EB%A9%94%EC%9D%B4%EC%85%98%EC%9D%84-%EB%A7%A8%EB%93%A4%EC%96%B4%EB%B3%B4%EC%9E%90-a76e27e295ad?source=rss-cfb7ed030036------2</link>
            <guid isPermaLink="false">https://medium.com/p/a76e27e295ad</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[최인탁]]></dc:creator>
            <pubDate>Thu, 24 Nov 2022 17:15:21 GMT</pubDate>
            <atom:updated>2022-11-24T17:15:21.432Z</atom:updated>
            <content:encoded><![CDATA[<h3>애플의 까리한 애니메이션:</h3><p><a href="https://www.apple.com/iphone-14/">https://www.apple.com/iphone-14/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*ZWN2GSOB8BVjlY1D-f2zig.gif" /></figure><h3>우리가 해볼거:</h3><p><a href="https://itsnothingg.github.io/scroll.html">@itsnothingg</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*uL9Nqsu4w8zUnUd35aFIog.gif" /></figure><h3>사용할 라이브뤄리:</h3><ol><li><strong>TailwindCSS</strong>: 레이아웃 잡는용</li><li><strong>GSAP</strong>: 스크롤 위치 감지용</li><li>끗</li></ol><h3>숴스 코드:</h3><p><a href="https://github.com/itsnothingg/apple-like-scroll-demo">GitHub - itsnothingg/apple-like-scroll-demo</a></p><h3>1. 기본 레이아웃</h3><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot; /&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;<br>    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/gsap.min.js&quot;&gt;&lt;/script&gt;<br>    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/ScrollTrigger.min.js&quot;&gt;&lt;/script&gt;<br>    &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.googleapis.com&quot; /&gt;<br>    &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot; crossorigin /&gt;<br>     &lt;script src=&quot;https://cdn.tailwindcss.com&quot;&gt;&lt;/script&gt;<br>    &lt;link<br>      href=&quot;https://fonts.googleapis.com/css2?family=Red+Hat+Display:wght@500;700;800;900&amp;display=swap&quot;<br>      rel=&quot;stylesheet&quot;<br>    /&gt;<br>    &lt;style&gt;<br>      body {<br>        font-family: &#39;Red Hat Display&#39;, sans-serif;<br>      }<br>    &lt;/style&gt;<br>  &lt;/head&gt;<br>  &lt;body class=&quot;transition-all duration-300&quot;&gt;<br>    &lt;div class=&quot;flex flex-col w-full&quot;&gt;<br>      &lt;div<br>        class=&quot;flex flex-row items-center justify-center w-full h-12 bg-blue-900/80&quot;<br>      &gt;<br>          &lt;h1  class=&quot;font-semibold text-[19px] opacity-[0.8] text-white&quot;&gt;<br>           Lorem <br>          &lt;/h1&gt;<br>      &lt;/div&gt;<br>      &lt;div class=&quot;sticky top-0 z-10 w-full h-12&quot;&gt;<br>        &lt;div class=&quot;flex flex-row items-center h-full px-4&quot;&gt;<br>          &lt;h1 id=&quot;title-logo&quot; class=&quot;font-semibold text-[19px] opacity-[0.8]&quot;&gt;<br>            @itsnothingg<br>          &lt;/h1&gt;<br>          &lt;div<br>            class=&quot;px-[11px] py-1 font-normal bg-blue-800/80 text-xs rounded-full text-white/90 text-center ml-auto&quot;<br>          &gt;<br>            LIKE<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>        &lt;div class=&quot;h-px bg-black/20&quot;&gt;&lt;/div&gt;<br>      &lt;/div&gt;<br>      &lt;div<br>        class=&quot;sticky top-0 flex flex-col items-center justify-center w-full h-screen overflow-hidden&quot;<br>      &gt;<br>        &lt;div<br>          id=&quot;logo&quot;<br>          class=&quot;text-5xl md:text-6xl font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-blue-900 to-purple-500/80 -mt-[96px] leading-[5rem]&quot;<br>        &gt;<br>         Lorem ipsum <br>        &lt;/div&gt;<br>        &lt;div<br>          id=&quot;section-1&quot;<br>          class=&quot;absolute flex flex-row w-full h-[300px] space-x-10 top-full text-4xl font-bold md:text-5xl&quot;<br>        &gt;<br>          &lt;div class=&quot;flex justify-end h-full grow basis-0 will-change-transform transform-gpu&quot;&gt;<br>            &lt;label class=&quot;absolute z-10 font-bold label1 top-5&quot;&gt;<br>              &lt;span class=&quot;flex skew-y-[7deg] -translate-x-8 md:translate-x-0&quot;&gt;<br>                Biggest<br>              &lt;/span&gt;<br>            &lt;/label&gt;<br>            &lt;label<br>              class=&quot;absolute z-10 transition-all duration-300 scale-0 label2 top-5&quot;<br>            &gt;<br>              &lt;span class=&quot;flex skew-y-[7deg] -translate-x-10&quot;&gt; Epic &lt;/span&gt;<br>            &lt;/label&gt;<br>            &lt;img<br>              src=&quot;img/8aee1a88-57f6-42e5-9e53-698b4202a20c.webp&quot;<br>              class=&quot;w-[180px] absolute z-20 will-change-transform transform-gpu&quot;<br>            /&gt;<br>          &lt;/div&gt;<br>          &lt;div class=&quot;flex justify-start h-full grow basis-0 will-change-transform transform-gpu&quot;&gt;<br>            &lt;label class=&quot;absolute z-10 font-bold label1 top-5&quot;&gt;<br>              &lt;span class=&quot;flex skew-y-[-7deg] translate-x-8&quot;&gt; Leap. &lt;/span&gt;<br>            &lt;/label&gt;<br><br>            &lt;label<br>              class=&quot;absolute z-10 font-bold transition-all duration-300 scale-0 top-5 label2&quot;<br>            &gt;<br>              &lt;span class=&quot;flex skew-y-[-7deg] &quot;&gt;Stunning.&lt;/span&gt;<br>            &lt;/label&gt;<br><br>            &lt;img<br>              src=&quot;img/c64c07c5-ca20-41b9-838f-d01a2caa1e47.webp&quot;<br>              class=&quot;w-[180px] absolute z-20 will-change-transform transform-gpu &quot;<br>            /&gt;<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>      &lt;div class=&quot;w-full h-screen mb-[100vh]&quot; id=&quot;ref-anim-1&quot;&gt;&lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>여기서 핵심은!</strong><br>1. 애니메이션이 될 컨텐츠는 <strong>sticky (position: sticky)</strong> div의 하위로 들어갔다는 것. (실제 스크롤이 되면 안되기 때문! <strong>translateY를 이용해 스크롤이 되는 것처럼 흉내</strong>를 내는 것)<br>2.스크롤 이벤트를 시뮬레이션 해줄 <strong>가상의 스크롤</strong> div 을 만들었다는 것</p><pre> &lt;div class=&quot;w-full h-screen mb-[100vh]&quot; id=&quot;ref-anim-1&quot;&gt;&lt;/div&gt;</pre><h3>2. 스크륍트</h3><pre>&lt;body&gt;<br> ... <br> &lt;script&gt;<br>      const section1 = document.querySelector(&quot;#section-1&quot;);<br>      const section1Labels1 = document.querySelectorAll(&quot;#section-1 .label1&quot;);<br>      const section1Labels2 = document.querySelectorAll(&quot;#section-1 .label2&quot;);<br>      ScrollTrigger.create({<br>        trigger: &quot;#logo&quot;,<br>        start: &quot;center center-=10%&quot;,<br>        end: &quot;center top&quot;,<br>        onUpdate(self) {<br>          self.trigger.style.transform = `translateY(-${<br>            self.end * self.progress<br>          }px)`;<br>          self.trigger.style.opacity = 1 - self.progress;<br>        },<br>      });<br>      const trigger1 = ScrollTrigger.create({<br>        trigger: &quot;#ref-anim-1&quot;,<br>        start: &quot;top bottom-=0%&quot;,<br>        end: &quot;top bottom-=40%&quot;,<br>        onUpdate(self) {<br>          section1.style.transform = `translateY(-${<br>            self.end * self.progress<br>          }px)`;<br><br>          for (let label of section1Labels1) {<br>            label.style.transform = `scale(${self.progress}) translateY(-${<br>              60 * self.progress<br>            }px)`;<br>          }<br>        },<br>      });<br>      const trigger2 = ScrollTrigger.create({<br>        trigger: &quot;#ref-anim-1&quot;,<br>        start: &quot;top bottom-=50%&quot;,<br>        end: &quot;top bottom-=80%&quot;,<br>        onUpdate(self) {<br>          section1.style.transform = `translateY(-${<br>            trigger1.end + ((self.end - trigger1.end) / 6) * self.progress<br>          }px)`;<br><br>          for (let label of section1Labels1) {<br>            label.style.transform = `scale(${<br>              1 - self.progress<br>            }) translateY(-60px)`;<br>          }<br>        },<br>      });<br><br>      const trigger3 = ScrollTrigger.create({<br>        trigger: &quot;#ref-anim-1&quot;,<br>        start: &quot;top bottom-=85%&quot;,<br>        end: &quot;top bottom-=110%&quot;,<br>        onEnterBack() {<br>          document.body.style.background = &quot;white&quot;;<br>          document.querySelector(&quot;#title-logo&quot;).style.color = &quot;black&quot;;<br>          for (let label of section1Labels2) {<br>            label.style.color = &quot;black&quot;;<br>          }<br>        },<br>        onLeave() {<br>          document.body.style.background = &quot;black&quot;;<br>          document.querySelector(&quot;#title-logo&quot;).style.color = &quot;white&quot;;<br>          for (let label of section1Labels2) {<br>            label.style.color = &quot;white&quot;;<br>          }<br>        },<br>        onUpdate(self) {<br>          const gone = trigger1.end + (trigger2.end - trigger1.end) / 6;<br>          section1.style.transform = `translateY(-${<br>            gone + ((self.end - gone) / 6) * self.progress<br>          }px)`;<br><br>          for (let label of section1Labels2) {<br>            label.style.transform = `scale(${self.progress}) translateY(-${<br>              60 * self.progress<br>            }px)`;<br>          }<br>        },<br>      });<br>    &lt;/script&gt;<br>&lt;/body&gt;</pre><p><strong>여기서 핵심은!</strong><br>1. ScrollTrigger를 이용하여 스크롤 이벤트를 받을 위치를 설정 (ScrollTrigger의 자세한 문서는 이곳 참조)<br>2. 스크롤 이벤트는 onUpdate로 불리는데, 인자인 self.progress는 0~1사이의 스크롤 위치를 나타낸다.<br>3. 따라서 self.progress를 기준으로 적절한 transform 값을 줘 각 원소를 움직여주면 끗.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a76e27e295ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git 커밋 메시지..명령문 vs 과거문]]></title>
            <link>https://itsnothingg.medium.com/git-%EC%BB%A4%EB%B0%8B-%EB%A9%94%EC%8B%9C%EC%A7%80-%EB%AA%85%EB%A0%B9%EB%AC%B8-vs-%EA%B3%BC%EA%B1%B0%EB%AC%B8-86d33abb0618?source=rss-cfb7ed030036------2</link>
            <guid isPermaLink="false">https://medium.com/p/86d33abb0618</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[최인탁]]></dc:creator>
            <pubDate>Tue, 02 Mar 2021 10:03:48 GMT</pubDate>
            <atom:updated>2021-03-02T10:03:48.400Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*8ZmyGWiKNUGbuxNv89D7mg.jpeg" /></figure><p>개발자로 산다는 것은 참으로..참으로 피곤한 일인 것이다.</p><p>새로운 저장소를 초기화하고 .gitignore 조차 없는 깨끗한 백지 상태의 폴더를 보고 있노라면..온갖 아이디어가 우리의 머리를 감싼다.</p><blockquote>이번엔 또 어떤 프레임워크 써보누? GraphQL이 뜬다던데 함 써볼까? Serverless 는 이제 좀 쓸만해졌을라나? 앱은 Hybrid로 할까 Native로 할까 ? 디비는 관계형 or NoSQL? 도커..는 아는데 LXD는 또 뭐꼬?</blockquote><p>우여곡절 끝에 필요한 보일러 플레이트 코드를 완성하여 Git 에 첫 커밋을 하려는 순간, 여기서 또 한번 고민에 빠진다.</p><p>“Initialized repository” vs “Initialize repository”</p><p>개발자란 많고 많은 건설적인 일들을 제쳐두고, 이런 하등 쓸모 없어 보이는 곳에 수십분을 낭비하곤 한다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2XCyw01eKGL-mkDXun7kXw.png" /><figcaption>고무적인 커밋들</figcaption></figure><p>어쨋건 우리의 시간은 소중하기에, 스택오버플로우나 레딧 등의 커뮤니티에서 베테랑 개발자들이 커밋 메시지에 대하여 어떤 생각을 갖고 있는지 간략하게 정리해보았다.</p><h3>명령문 파</h3><h4>근거 #1: 커밋은 패치다.</h4><p>Git은 분산 버전 관리 시스템이다. 잠재적으로 다수의 사람들이 코드에 관여를 하게된다. 고로 <em>너가 무엇을 했는지</em>를 적지 말고<em>, </em>사람들이 커밋을 적용했을 때 발생할 변화를 알기 쉽게 적어야한다.</p><p>“Removed the common prefix.” 보단 “Remove the common prefix.” 이</p><p>커밋을 적용하는 입장에서 훨씬 간결하게 와닿는다.</p><h4>근거 #2: 일관성을 고려하라.</h4><p>Git 자체 저장소의 커밋 가이드라인에 보면 명령문을 사용하라고 명시 되어있다. 그 영향으로 Git 에서 소스를 자동으로 병합할때 명령문을 사용한다.</p><blockquote>e.g) Merge branch ‘xxx’ into xxx</blockquote><p>이를 과거문으로 바꾸기 위해 번거롭게 작업할 가치가 있나?</p><p>더군다나 이슈/버그 트래킹의 경우 명령문으로 작성하는 것이 훨씬 자연스러운데, 여기서도 일관성을 유지할 수 있다.</p><h4>근거 #3: 명령문이 더 간결하다.</h4><p>대다수의 개발자가 커밋 메시지의 첫 줄을 <em>50자 미만</em>으로 쓰도록 권고하고 있다. (50/72 규칙) 한글자 한글자가 소중한데 과거형 동사를 써서 공간을 낭비하고 싶지 않다.</p><h3>과거문 파</h3><h4>근거 #1 커밋은 기록이다.</h4><p>대다수의 경우 저장소는 진정한 의미에서 분산되었다고 볼 수 없다. 너의 저장소는 <em>커밋을 선택적으로 골라 적용할 수 있는가? </em>아마 그렇지 못한 저장소들이 훨씬 더 많을 것이다. 커밋의 99%는 필수적일 것이며, 다른 팀원들은 그 커밋을 강제로 병합해야 한다. 그렇다면 커밋은 패치가 아닌 기록으로 봐야 더 옳을 것이다. 넌 기록을 적을때 명령문이나 현재형으로 적나?</p><h4>근거 #2 커밋의 독자가 누구인가?</h4><p>이것도 #1번과 맥락을 공유하는데, 대다수의 경우 커밋을 메시지를 읽는 사람은 코드를 작성한 본인이거나, 소수의 팀원들일 것이다. 고로 독자가 궁금해하는 것은 대게 “<em>여기서 어떤 일이 일어났지</em>” 에 대한 답이지 “<em>어떤 커밋을 적용해야 그 기능을 붙일 수 있을까</em>”가 아니다.</p><p>그 외에 파일 변경을 파일 변경을 추적하거나, 코드를 복기하는 것 모두 커밋을 기록으로써 읽는 것이다.</p><h3>결론</h3><p>역시 늘 그렇듯 이런 류의 논쟁에 정답은 없는 것 같다. 팀 규칙이 있다면 그게 가장 우선시 되어야 하고, 아니라면 본인이 생각하기에 설득력 있는 주장을 따르면 되겠지.</p><p>참..서두에서 언급했듯 개발하다보면 아무것도 아닌 문제로 시간을 낭비하게 되는데, 그럴땐 뺨한대 치고 실제로 중요한 것에 몰입하는게 최고인 것 같다.</p><p>고로 다음엔 REST API에서 단수형과 복수형중 무엇을 따를지 알아보자.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86d33abb0618" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1. GStreamer 튜토리얼 : Hello World]]></title>
            <link>https://itsnothingg.medium.com/1-gstreamer-%ED%8A%9C%ED%86%A0%EB%A6%AC%EC%96%BC-hello-world-d436cec45bd1?source=rss-cfb7ed030036------2</link>
            <guid isPermaLink="false">https://medium.com/p/d436cec45bd1</guid>
            <category><![CDATA[gstreamer]]></category>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[hello-world]]></category>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[최인탁]]></dc:creator>
            <pubDate>Tue, 26 May 2020 06:27:43 GMT</pubDate>
            <atom:updated>2020-05-26T06:27:43.072Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. GStreamer 튜토리얼 : Hello World</h3><p>본 포스트는 gstreamer 공식 사이트의 문서를 요약 및 번역한 것입니다.</p><p><a href="https://gstreamer.freedesktop.org/documentation/tutorials/basic/hello-world.html?gi-language=c">Basic tutorial 1: Hello world!</a></p><h4>목표</h4><p>새로운 라이브러리를 접할때<br>Hello World를 출력해보는 것만큼 좋은 게 없는 것 같습니다.</p><p>헌데 우리는 멀티 미디어 프레임워크를 다루고자 하니,<br>차라리 비디오를 출력해보기로 합시다.</p><p>아래의 긴 코드에 겁먹지 않아주셨으면 합니다.<br>실제 필요한 코드는 4줄 뿐이고 나머지는 변두리입니다.<br>C가 거추장스럽다는 건 잘 아실겁니다.</p><pre>#include &lt;gst/gst.h&gt;<br><br>int<br>main (int argc, char *argv[])<br>{<br>  GstElement *pipeline;<br>  GstBus *bus;<br>  GstMessage *msg;<br><br>  /* Initialize GStreamer */<br>  gst_init (&amp;argc, &amp;argv);<br><br>  /* Build the pipeline */<br>  pipeline =<br>      gst_parse_launch<br>      (&quot;playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm&quot;,<br>      NULL);<br><br>  /* Start playing */<br>  gst_element_set_state (pipeline, GST_STATE_PLAYING);<br><br>  /* Wait until error or EOS */<br>  bus = gst_element_get_bus (pipeline);<br>  msg =<br>      gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,<br>      GST_MESSAGE_ERROR | GST_MESSAGE_EOS);<br><br>  /* Free resources */<br>  if (msg != NULL)<br>    gst_message_unref (msg);<br>  gst_object_unref (bus);<br>  gst_element_set_state (pipeline, GST_STATE_NULL);<br>  gst_object_unref (pipeline);<br>  return 0;<br>}</pre><p>위 코드를 컴파일 하는 방법은 본문에서 다루지 않으니, 이 부분은 공식 문서를 참고해주시기 바랍니다.</p><p><a href="https://gstreamer.freedesktop.org/documentation/installing/on-linux.html">Installing on Linux</a></p><p><a href="https://gstreamer.freedesktop.org/documentation/installing/on-mac-osx.html">Installing on Mac OS X</a></p><p><a href="https://gstreamer.freedesktop.org/documentation/installing/on-windows.html">Installing on Windows</a></p><h4>설명</h4><p>코드를 차근 차근 분석해봅시다.</p><pre>/* Initialize GStreamer */<br>gst_init (&amp;argc, &amp;argv);</pre><p><a href="https://gstreamer.freedesktop.org/documentation/gstreamer/gst.html#gst_init">gst_init</a>()은 늘 다른 GStreamer 코드보다 우선으로 와야합니다.</p><p><a href="https://gstreamer.freedesktop.org/documentation/gstreamer/gst.html#gst_init">gst_init</a>()는:</p><ul><li>내부 구조체를 초기화</li><li>사용 가능한 plug-in 을 탐색</li><li>GStreamer에게 전달되어야할 command-line 옵션을 전달. 위와 같이 main의 argc and argv 를 그대로 gst_init에 전달하면, GStreamer 의 표준 command-line 옵션을 자동으로 적용할 수 있습니다.</li></ul><pre><br>/* Build the pipeline */<br>pipeline =<br>    gst_parse_launch<br>    (&quot;playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm&quot;,<br>    NULL);</pre><p>이 부분이 본 튜토리얼의 핵심입니다. 여기서 gst_parse_launch() 와 playbin이라는 두가지 키 포인트를 소개합니다.</p><h4>gst_parse_launch</h4><p>Gstreamer는 멀티미디어의 흐름을 제어하기 위해 고안된 프레임워크입니다.<br>미디어는 source 부터 sink 까지 여러 단계를 거쳐가며 이동합니다.<br>이렇게 연결된 요소들을 pipeline이라고 부릅니다.</p><p>GStreamer에서는 보통 여러 요소들을 조합하여 pipeline을 직접 구성히지만,<br>pipeline이 단순할때 사용할 수 있는 것이 gst_parse_launcher() 입니다.<br>이 함수는 pipeline 형식을 갖춘 문자열을, 실제 pipeline 으로 변환해줍니다.</p><h4>playbin</h4><p>그럼 우리가 gst_parse_launch() 를 통해 만들고자 하는 pipeline은 무엇일까요?<br>여기서 두번째 키포인트가 나옵니다.<br>playbin 이라는 단일 요소로 구성된 pipeline 입니다.</p><p>playbin은 source와 sink를 모두 수행하는, 그 자체로써 pipeline인 요소입니다.<br>내부적으로 미디어 재생에 필요한 요소들을 직접 만들고 연결하므로, 우리가 신경쓸 건 없습니다.</p><p>이는 pipeline을 직접 구성하는 것보다는 적은 자유도를 제공하지만,<br>대게의 어플리케이션에서 필요한 수준의 커스터마이징을 하기에는 충분합니다. 이 튜토리얼처럼 말입니다.</p><p>이 예제에서, 우리는 playbin에 재생을 원하는 미디어의 URI를 넘겼습니다.<br>URI를 원하는 걸로 병경해보세요.<br>playbin은 URI에 적절한 source를 자동으로 초기화해줍니다.</p><p>URI가 잘못되었거나, 필요한 Plug-in이 없는 등의 문제가 발생할 경우를 대비해<br>GStreamer는 다양한 알림 메커니즘을 갖추고 있는데,<br>본 예제에서는 오류가 났을시 바로 종료하기때문에, 상세한 피드백은 기대하지 않아야 합니다.</p><pre>/* Start playing */<br>gst_element_set_state (pipeline, GST_STATE_PLAYING);</pre><p>위 줄은 state라는 또 다른 흥미로운 컨셉을 소개합니다. <br>GStreamer의 모든 요소는 연관된 state가 있습니다.<br>마치 DVD 플레이어에서 재생/정지 버튼을 누르는 것과 유사하다고 생각하면 됩니다.<br>일단은 pipeline을 PLATING state로 전환하기 전까지는 재생이 시작되지 않는다는 것만 알아두세요.</p><p>이 줄에서, gst_element_set_state()는 pipeline을 PLAYING state로 전환합니다.<br>따라서 재생이 시작되는 것입니다.</p><pre>/* Wait until error or EOS */<br>bus = gst_element_get_bus (pipeline);<br>msg =<br>    gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,<br>    GST_MESSAGE_ERROR | GST_MESSAGE_EOS);</pre><p>이 줄들은 미디어 스트림이 끝나거나 오류가 발생하기 전까지 기다립니다.<br>gst_element_get_bus()는 pipeline의 bus를 받아오고,<br>gst_bus_timed_pop_filtered()은 bus에서 ERROR 또는 EOS(End-Of-Stream) 신호를 받기 전까지<br>block합니다.</p><p>이게 전부입니다. 이후부터는 GStreamer가 모든 것을 알아서 관리합니다.</p><h4>정리</h4><p>어플리케이션을 종료하기전에, 몇 가지를 확실하게 정리해야합니다.</p><pre>/* Free resources */<br>if (msg != NULL)<br>  gst_message_unref (msg);<br>gst_object_unref (bus);<br>gst_element_set_state (pipeline, GST_STATE_NULL);<br>gst_object_unref (pipeline);</pre><p>어떤 객체들을 free 해줘야할지는 documentation에 모두 나와있기때문에, 꼭 읽어보시기 바랍니다.</p><p>이 경우에는, gst_bus_timed_pop_filtered() 에서 반환되는 메시지를<br>gst_message_unref()로 free 해야합니다.</p><h4>결론</h4><p>이렇게 GStreamer의 첫번째 튜토리얼이 끝났습니다. 이 프레임워크가 얼마나 강력한지 조금이라도 전달이 되었으면 좋겠습니다</p><p>다시 정리하자면, 우리는 다음 점들을 다뤘습니다.</p><ul><li>gst_init을 사용한 Gstreamer 초기화</li><li>gst_parse_launch()를 통해 빠르게 pipeline을 구성하는 법</li><li>playbin 요소를 사용하여 자동으로 미디어 재생 pipeline을 만드는 법</li><li>gst_element_set_state 를 사용해 GStreamer에게 재생 시작 신호를 보내는 법</li><li>GStreamer가 모든 것을 처리하는 동안 gst_element_get_bus() 와 gst_bus_timed_pop_filtered() 를 통해 얌전히 기다리는 법</li></ul><p>다음 튜토리얼에서는 pipeline을 직접 구축하는 방법을 다뤄보도록 하겠습니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d436cec45bd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[안드로이드에서 MVP 하는 법]]></title>
            <link>https://itsnothingg.medium.com/%EC%95%88%EB%93%9C%EB%A1%9C%EC%9D%B4%EB%93%9C%EC%97%90%EC%84%9C-mvp-%ED%95%98%EB%8A%94-%EB%B2%95-cc038a6abfc7?source=rss-cfb7ed030036------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc038a6abfc7</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[mvp]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[최인탁]]></dc:creator>
            <pubDate>Tue, 17 Sep 2019 01:02:45 GMT</pubDate>
            <atom:updated>2019-09-17T01:05:16.752Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://blog.mindorks.com/essential-guide-for-designing-your-android-app-architecture-mvp-part-1-74efaf1cda40#.lkml1yggq">https://blog.mindorks.com/essential-guide-for-designing-your-android-app-architecture-mvp-part-1-74efaf1cda40#.lkml1yggq</a></p><p><a href="https://github.com/MindorksOpenSource/android-kotlin-mvp-architecture">https://github.com/MindorksOpenSource/android-kotlin-mvp-architecture</a></p><p>MVP 패턴을 따르면 코드가 더 느슨해져서 재사용 및 테스트가 용이해진다.<br>MVP는 애플리케이션을 3가지로 나눈다.</p><ol><li>Model — 데이터를 담당</li><li>View — 특정 데이터를 화면에 보여주는 것을 담당</li><li>Presenter — View와 Model의 중간다리.View의 instructor.</li></ol><p>MVP의 기본 원칙들</p><ol><li>View의 유일한 역할은 Presenter가 명령한대로 화면을 그리는 것. 가장 바보같은 역할을 담당한다</li><li>View는 모든 유저와의 상호작용을 Presenter에 위임한다</li><li>View는 절대 Model을 직접 조작하지 않는다.</li><li>Presenter는 View의 요구사항들을 Model에 전달하고 특정 이벤트가 일어날 경우 View를 제어한다</li><li>Model은 데이터를 어디서 부터론가 (서버, 데이터베이스, 파일 등) 가져오는 역할을 한다</li></ol><p>안드로이드에 적용해보자</p><ol><li>Activity, Fragment 및 Custom View들이 MVP의 View에 해당한다.</li><li>모든 View는 1:1로 Presenter를 갖고 있는다.</li><li>View는 Presenter와 Interface로 소통한다.</li><li>Model은 몇가지로 나뉜다. ApiHelper, PreferenceHelper, DatabaseHelper, and FileHelper. 이 helper들은 Datamanager를 통해서 사용된다.</li><li>Presenter는 interface를 통해 Datamanager 소통한다.</li><li>Datamanger는 요청받았을때만 동작한다</li><li>Presenter는 Android API에 접근 권한이 없다.</li></ol><h3>청사진</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zKssHNarEEUjsrYR2iclfw.png" /></figure><ul><li>View: Activity, CustomView, Fragment와 같은 실재 UI를 Render 하는 부분</li><li>MvpView: View가 구현하는 interface. Presenter에 함수를 노출시킨다</li><li>Presenter: View를 대신해 모든 결정을 내려주는 Pure Java class. Android APIs에 접근할 수 없다. View에서 유저의 상호작용을 받고 비즈니스 로직대로 처리한다. 결국엔 View에 어떤 처리를 할지 다시 전달(피드백). 또한 비즈니스 로직에 다라 Datamanger와 소통한다</li><li>MvpPresenter: Presenter에 의해서 구현되는 interface. View에 메소드를 노출시킨다</li><li>AppDbHelper: Database Management</li><li>DbHelper: AppDbHelper가 구현하는 interface. AppDbHelper를 플러그 앤 풀 가능하게 만든가</li><li>DataManager<strong>: </strong>AppDataManager가 구현하는 interface. 모든 helper 클래스들의 기능을 위임한다. Datamanger interface는 모든 helper interface를 extend 한다.</li><li>AppDataManager<strong>: </strong>Model에 접근할 수 있는 유일한 통로</li></ul><p>소통 패턴을 공식화 해보자</p><ul><li>애플리케이션 클래스에서 모든 핼퍼 클래스 및 AppDatamanger를 인스턴스화 시킨다.</li><li>View는 MvpPresenter reference를 통해서 Presenter를 초기화한다</li><li>Presenter는 MvpView를 통해 View를 받는다. Presenter는 Datamanger를 받는다</li><li>Datamanger는 싱글톤이다.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc038a6abfc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel 꿀팁 모음 (5.7+)]]></title>
            <link>https://itsnothingg.medium.com/laravel-%EA%BF%80%ED%8C%81-%EB%AA%A8%EC%9D%8C-5-7-ef7dcc454781?source=rss-cfb7ed030036------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef7dcc454781</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[최인탁]]></dc:creator>
            <pubDate>Thu, 29 Aug 2019 18:03:37 GMT</pubDate>
            <atom:updated>2019-08-29T18:03:37.437Z</atom:updated>
            <content:encoded><![CDATA[<p>본 포스트는 <a href="https://medium.com/u/fafe4d9ad699">Alex Renoki</a> 의 글을 간단하게 정리 및 번역 한 글입니다. 원문은 아래 링크를 참조하시기 바랍니다.</p><p><a href="https://medium.com/@alexrenoki/pushing-laravel-further-best-tips-good-practices-for-laravel-5-7-ac97305b8cac">Pushing Laravel further — best tips &amp; good practices for Laravel 5.7</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sW-OHuzP2r0xc2HpFlSnoQ.png" /></figure><h3>쿼리 날릴때 지역 스코프 사용</h3><p>흔히 아래와 같이 쿼리를 날렸을 것.</p><pre>$orders = Order::where(‘status’, ‘delivered’)-&gt;where(‘paid’, true)-&gt;get();</pre><p>지역 스코프를 사용하면 더 깔끔한 코드가 나옴.<br>위 코드를 예로들면, -&gt;where() 을-&gt;delivered() 나-&gt;paid() 로 대체할 수 있는 얘기.</p><p>그러기 위해선 Order 에 아래와 같이 메소드 추가.</p><pre>class Order extends Model<br>{<br>   ...<br>   public function scopeDelivered($query) {<br>      return $query-&gt;where(&#39;status&#39;, &#39;delivered&#39;);<br>   }   </pre><pre>   public function scopePaid($query) {<br>      return $query-&gt;where(&#39;paid&#39;, true);<br>   }<br>}</pre><p>scope 를 꼭 함수 앞에 붙임으로 지역 스코프임을 명시해야함.<br>$query 인자는 자동으로 주입되는 쿼리 빌더 객체임.<br>이제 아래와 같이 사용 가능.</p><pre>$orders = Order::delivered()-&gt;paid()-&gt;get();</pre><p>한층 더 동적인 지역 스코프를 원한다면 아래와 같이 구현 가능.</p><pre>class Order extends Model<br>{<br>   ...<br>   public function scopeStatus($query, string $status) {<br>      return $query-&gt;where(&#39;status&#39;, $status);<br>   }<br>}</pre><pre>$orders = Order::status(&#39;delivered&#39;)-&gt;paid()-&gt;get();</pre><h3>Requests 파일 사용하기</h3><p>흔히 아래와 같이 유효성을 검사했을 것.</p><pre>public function store(Request $request)<br>{<br>    $validatedData = $request-&gt;validate([<br>        &#39;title&#39; =&gt; &#39;required|unique:posts|max:255&#39;,<br>        &#39;body&#39; =&gt; &#39;required&#39;,<br>    ]);<br><br>    // The blog post is valid...<br>}</pre><p>이렇게 controller 파일에 꾸역 꾸역 넣지 말고 분리시켜보자.</p><pre>php artisan make:request StoreBlogPost</pre><p>app/Http/Requests/ 하위에 아래와 같은 파일이 생겼을 것.</p><pre>class StoreBlogPostRequest extends FormRequest<br>{<br>   public function authorize()<br>   {<br>      return $this-&gt;user()-&gt;can(&#39;create.posts&#39;);<br>   }   </pre><pre>   public function rules()<br>   {<br>       return [<br>         &#39;title&#39; =&gt; &#39;required|unique:posts|max:255&#39;,<br>         &#39;body&#39; =&gt; &#39;required&#39;,<br>       ];<br>   }<br>}</pre><p>controller 에서 위 클래스를 사용하도록 설정.</p><pre>use App\Http\Requests\StoreBlogPostRequest;</pre><pre>public function store(StoreBlogPostRequest $request)<br>{<br>    // The blog post is valid...<br>}</pre><h3>유용한 스코프 목록</h3><p>라라벨에는 미리 정의된 유용한 스코프들이 있다.</p><ol><li>최근 순으로 정렬 (created_at 컬럼 사용시)</li></ol><pre>User::latest()-&gt;get();</pre><p>2. 최근 순으로 정렬 (사용자 지정 컬럼)</p><pre>User::latest(&#39;last_login_at&#39;)-&gt;get();</pre><p>3. 랜덤 정렬</p><pre>User::inRandomOrder()-&gt;get();</pre><p>4. 결과가 참일경우만 쿼리 실행</p><pre>// 예를들어, 사용자가 news 페이지에 있고 목록을 최근 순으로 정렬하기를 원한다고 하자<br>// mydomain.com/news?sort=new</pre><pre>User::when($request-&gt;query(&#39;sort&#39;), function ($query, $sort) {<br>   if ($sort == &#39;new&#39;) {<br>      return $query-&gt;latest();<br>   }<br>   <br>   return $query;<br>})-&gt;get();</pre><p>when의 반대로 unless가 있음.</p><h3>적절한 관계문 사용</h3><p><a href="https://laravel.com/docs/5.7/eloquent-relationships">사용 가능한 관계문 목록 확인</a></p><h3>시간이 오래 걸리는 작업들은 Queue를 사용하기</h3><ol><li>이메일 전송</li><li>이미지 변환</li><li>메시지 푸싱</li></ol><p>등등..<br><a href="https://laravel.com/docs/5.7/queues">Queue 문서 확인</a></p><h3>데이터베이스 네이밍 규칙 지키기</h3><p>왜 지켜야 하는가?<br>그래야 더 나은 접근자(accessor)을 만들수 있기 때문.</p><p>접근자(accessor)는 모델에서 만드는 컬럼.<br>예를 들어, 데이터베이스에 first_name, last_name 컬럼이 각각 존재하는데, <br>보통 이름을 표시할때는 두 컬럼을 붙여서 보여주고 싶을 것.<br>그런 작업을 아래와 같이 접근자를 통해 처리.</p><pre>class User extends Model<br>{<br>   ...<br>   public function getNameAttribute(): string<br>   {<br>       return $this-&gt;first_name.&#39; &#39;.$this-&gt;last_name;<br>   }<br>}</pre><p>이후, $user-&gt;name을 통해 붙여진 이름을 가져올 수 있음.</p><p>혹은, 같은 맥락으로, 각각 이름을 가져올 때 첫 알파벳을 대문자로 바꾸고 싶을때 아래와 같이 할 수 있음</p><pre>class User extends Model<br>{<br>   protected $appends = [<br>      //<br>   ];</pre><pre>   public function getFirstNameAttribute($firstName): string<br>   {<br>       return ucfirst($firstName);<br>   }   <br>   public function getLastNameAttribute($lastName): string<br>   {<br>      return ucfirst($lastName);<br>   }</pre><pre>}</pre><h3>모델과 관련된 정적인 데이터를 config 파일에 넣지 않기</h3><p>이렇게 사용하는 대신에,</p><p>BettingOdds.php</p><pre>class BettingOdds extends Model<br>{<br>   ...<br>}</pre><p>config/bettingOdds.php</p><pre>return [<br>   &#39;sports&#39; =&gt; [<br>      &#39;soccer&#39; =&gt; &#39;sport:1&#39;,<br>      &#39;tennis&#39; =&gt; &#39;sport:2&#39;,<br>      &#39;basketball&#39; =&gt; &#39;sport:3&#39;,<br>      ...<br>   ],<br>];</pre><pre>config(’bettingOdds.sports.soccer’);</pre><p>이렇게 사용.</p><p>BettingOdds.php</p><pre>class BettingOdds extends Model<br>{<br>   protected static $sports = [<br>      &#39;soccer&#39; =&gt; &#39;sport:1&#39;,<br>      &#39;tennis&#39; =&gt; &#39;sport:2&#39;,<br>      &#39;basketball&#39; =&gt; &#39;sport:3&#39;,<br>      ...<br>   ];<br>}</pre><pre>BettingOdds::$sports[&#39;soccer&#39;];</pre><p>추후에 접근이 더 용이해지기 때문.</p><pre>class BettingOdds extends Model<br>{<br>   protected static $sports = [<br>      &#39;soccer&#39; =&gt; &#39;sport:1&#39;,<br>      &#39;tennis&#39; =&gt; &#39;sport:2&#39;,<br>      &#39;basketball&#39; =&gt; &#39;sport:3&#39;,<br>      ...<br>   ];   <br>   public function scopeSport($query, string $sport)<br>   {<br>      if (! isset(self::$sports[$sport])) {<br>         return $query;<br>      }<br>      <br>      return $query-&gt;where(&#39;sport_id&#39;, self::$sports[$sport]);<br>   }<br>}</pre><p>덤으로 지역 스코프까지 사용 가능</p><pre>BettingOdds::sport(&#39;soccer&#39;)-&gt;get();</pre><h4>배열 다룰 때 Collection 사용하기</h4><p>흔히 아래와 같이 배열을 다루곤 함.</p><pre>$fruits = [&#39;apple&#39;, &#39;pear&#39;, &#39;banana&#39;, &#39;strawberry&#39;];</pre><pre>foreach ($fruits as $fruit) {<br>   echo &#39;I have &#39;. $fruit;<br>}</pre><p>collection을 사용하면 배열을 조작하기가 훨씬 용이해짐.<br>예를 들어,</p><pre>$fruits = collect($fruits);<br>$fruits = $fruits-&gt;reject(function ($fruit) {<br>   return $fruit === &#39;apple&#39;;<br>})-&gt;toArray();</pre><pre>[&#39;pear&#39;, &#39;banana&#39;, &#39;strawberry&#39;]</pre><p>더 다양한 사용방법을 위해선 <a href="https://laravel.com/docs/5.7/collections">확인.</a></p><p>주의. QueryBuilder 와 Collection을 햇갈리지 말기.<br>QueryBuilder는 데이터를 받아오기 전 단계. <br>-&gt;get() 이후 데이터가 넘어오고 메모리가 소비되는 단계가 Collection.</p><p>주의2. 데이터 필터링은 최대한 QueryBuilder쪽에서 처리할 것. <br>Collection에서 할 시 이미 데이터가 넘어왔기 때문에 메모리를 너무 많이 사용할 수 있음.</p><h3>새로 만들지 말고, 이미 있는 패키지들을 최대한 활용할 것</h3><ul><li><a href="https://github.com/appstract/laravel-blade-directives">Laravel Blade Directives</a></li><li><a href="https://github.com/barryvdh/laravel-cors">Laravel CORS</a> (CORS 라우트 보안)</li><li><a href="https://github.com/beyondcode/laravel-tag-helper">Laravel Tag Helper</a> (Blade 에서 Html 태그 사용)</li><li><a href="https://github.com/cviebrock/eloquent-sluggable">Laravel Sluggable</a> (slugs 생성시 유용)</li><li><a href="https://github.com/flugger/laravel-responder">Laravel Responder</a> (JSON API를 더 쉽게 개발)</li><li><a href="https://github.com/intervention/image">Image Intervention</a> (이미지 처리)</li><li><a href="https://github.com/laravel/horizon">Horizon</a> (Queue를 간편하게 관리)</li><li><a href="https://github.com/laravel/socialite">Socialite</a> (소셜 미디어 로그인 연동)</li><li><a href="https://github.com/laravel/passport">Passport</a> (OAuth 인증 구현)</li><li><a href="https://github.com/spatie/laravel-activitylog">Spatie’s ActivityLog</a> (모델 작업 추적)</li><li><a href="https://github.com/spatie/laravel-backup">Spatie’s Backup</a> (파일 및 데이터베이스 백업)</li><li><a href="https://github.com/spatie/laravel-blade-x">Spatie’s Blade-X</a> (사용자 지정 Html 태그 생성, <a href="https://github.com/beyondcode/laravel-tag-helper">Laravel Tag Helper</a>와 함께 쓰면 좋음)</li><li><a href="https://github.com/spatie/laravel-medialibrary">Spatie’s Media Library</a> (모델에 파일 첨부 기능)</li><li><a href="https://github.com/spatie/laravel-responsecache">Spatie’s Response Cache</a> (컨트롤러에 캐싱)</li><li><a href="https://github.com/spatie/laravel-collection-macros">Spatie’s Collection Macros</a> (collection 에 유용한 기능들 추가)</li></ul><p><a href="https://medium.com/u/fafe4d9ad699">Alex Renoki</a> (글쓴이)가 직접 제작한 패키지들</p><ul><li><a href="https://github.com/rennokki/befriended">Befriended</a> (소셜미디어의 추가적인 기능들)</li><li><a href="https://github.com/rennokki/schedule">Schedule</a> (타임 테이블 생성)</li><li><a href="https://github.com/rennokki/rating">Rating</a> (모델 레이팅)</li><li><a href="https://github.com/rennokki/guardian">Guardian</a> (쉽게 사용 가능한 권한 시스템)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef7dcc454781" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[대규모 어플리케이션에도 Vue.js 를 사용해도 될까요?]]></title>
            <link>https://itsnothingg.medium.com/%EB%8C%80%EA%B7%9C%EB%AA%A8-%EC%96%B4%ED%94%8C%EB%A6%AC%EC%BC%80%EC%9D%B4%EC%85%98%EC%97%90%EB%8F%84-vue-js-%EB%A5%BC-%EC%82%AC%EC%9A%A9%ED%95%B4%EB%8F%84-%EB%90%A0%EA%B9%8C%EC%9A%94-f39c09db9c8c?source=rss-cfb7ed030036------2</link>
            <guid isPermaLink="false">https://medium.com/p/f39c09db9c8c</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[최인탁]]></dc:creator>
            <pubDate>Fri, 08 Feb 2019 02:43:42 GMT</pubDate>
            <atom:updated>2019-02-08T02:43:42.543Z</atom:updated>
            <content:encoded><![CDATA[<p>본 포스트는 <a href="https://medium.com/u/c01404998660">Anthony Gore</a> 의 <a href="https://medium.com/js-dojo/is-vue-js-a-good-choice-for-a-large-scale-application-908263e3a88">https://medium.com/js-dojo/is-vue-js-a-good-choice-for-a-large-scale-application-908263e3a88</a> 포스트를 번역한 것입니다. 오역에 대해선 언제든지 지적부탁드립니다 :)</p><p><a href="https://medium.com/js-dojo/is-vue-js-a-good-choice-for-a-large-scale-application-908263e3a88">Is Vue.js a good choice for a large-scale application?</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3dk_AFPcqQ5Ab-_vz7fzXg.png" /></figure><p>우선 제가 말하는 대규모 어플리케이션이란:</p><ul><li>대략 백개 이상의 컴포넌트가 필요합니다</li><li>컴포넌트간의 데이터 이동이 매우 복잡합니다</li><li>테스트가 잘 되어있어야 합니다.</li></ul><p>Vue는 의심의 여지 없이 제가 가장 좋아하는 자바스크립트 프레임워크지만,그것과 별개로 어떤 도구도 만능이 될수 없다는 사실을 기억해야합니다.</p><p>Vue가 다양한 규모의 어플리케이션에 적합한 이유가 몇가지 있습니다.싱글 파일 컴포넌트, 모듈 방식의 컴포넌트 인터페이스, Vue CLI 3를 이용한 스캐폴딩 등</p><p>그렇지만 대규모 어플리케이션을 개발하기 앞서 고려해야할 몇가지 단점이 있습니다.</p><ol><li>템플릿 상속의 부재</li></ol><p>수백개의 컴포넌트를 관리하기 위해선 때때로 “부모 컴포넌트”가 필요할 수 있습니다. 예를 들어 우선 BaseInput이라는 부모 컴포넌트를 만들고 EmailInput, NameInput 과 같은 자식 컴포넌트가 상속 받게끔 하는거죠. 데이터 모델은 mixin을 사용하면 상속이 가능하나, 템플릿은 상속이 불가능합니다. (Pug와 같은 전처리기를 사용하면 구현은 가능합니다만, 이상적인 방법은 아닙니다.)</p><p>2. 교묘한 반응형 시스템</p><p>Vue의 반응형 시스템은 아주 직관적이고 “99%”의 경우 올바로 작동합니다. 하지만 아주 간혹가다가, 1%의 경우 오작동을 하는데, 이 때 디버깅 하기가 어렵습니다. Getters와 Setters는 디버깅하기 매우 까다롭고 호출자 추적이 힘듭니다. 또한 중첩된 객체 구조에 예외 처리가 필요하고 Vue.set을 명시적으로 호출해야합니다.</p><p>3. 미숙한 테스팅</p><p>Vue의 공식 테스팅 프레임워크인, Vue Test Utils는 좋은 프레임워크지만, 아직 베타 단계입니다. 개인적으로 테스팅에 많은 시간을 소요했지만 잘 작동하지 않거나 프레임워크에서 별난 버그가 발생하는 경우가 있었습니다.</p><p>추신. 물론 그렇다고 꼭 다른 자바스크립트 프레임워크가 Vue 보다 더 우수하다는 의미는 아닙니다.</p><p>단지 여러분이 Vue로 대규모 어플리케이션을 개발하기 앞서 고려해야 할 몇가지 요소들을 알려드리고 싶었습니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f39c09db9c8c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unable to locate Attribute with the the given name [column] on this ManagedType [table]]]></title>
            <link>https://itsnothingg.medium.com/unable-to-locate-attribute-with-the-the-given-name-column-on-this-managedtype-table-aebd4836dfb1?source=rss-cfb7ed030036------2</link>
            <guid isPermaLink="false">https://medium.com/p/aebd4836dfb1</guid>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[error-handling]]></category>
            <dc:creator><![CDATA[최인탁]]></dc:creator>
            <pubDate>Sun, 01 Jul 2018 08:02:00 GMT</pubDate>
            <atom:updated>2018-07-01T08:02:00.724Z</atom:updated>
            <content:encoded><![CDATA[<p>Repository나 Spring JPA Query에서는 실제 table 명이나, column명을 확인하는 것이 아니라, 매핑된 POJO의 멤버 이름을 확인하는 것이다.</p><p>위 오류가 뜰때는 아래 두가지를 확인해봐야한다.</p><ol><li>NamingStrategy 확인</li></ol><pre>spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl</pre><pre>spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl</pre><p>2. 매핑된 POJO 멤버 이름 확인</p><p>예를 들어) repository 에서 exsistsByName(String name)이라는 abstract method를 선언했다면, 매핑된 POJO 에서도 String name 이라는 멤버가 있어야 하는 것이다. (String Name 과 같이 선언할 경우 오류 발생)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aebd4836dfb1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[도대체 Vuex가 뭐길래?]]></title>
            <link>https://itsnothingg.medium.com/%EB%8F%84%EB%8C%80%EC%B2%B4-vuex%EA%B0%80-%EB%AD%90%EA%B8%B8%EB%9E%98-ad5bc15f2371?source=rss-cfb7ed030036------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad5bc15f2371</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[최인탁]]></dc:creator>
            <pubDate>Tue, 15 May 2018 23:29:08 GMT</pubDate>
            <atom:updated>2018-05-15T23:29:08.755Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*2AmZJmCbAzmwJLpz9jFQBA.jpeg" /></figure><p>본 포스트는 <a href="https://medium.com/u/c01404998660">Anthony Gore</a> 의 <a href="https://vuejsdevelopers.com/2017/05/15/vue-js-what-is-vuex/">https://vuejsdevelopers.com/2017/05/15/vue-js-what-is-vuex/</a> 포스트를 요약 및 번역한 것입니다. 오역에 대해선 언제든지 지적부탁드립니다 :)</p><p>Vuex. “Vewks”라고 읽으시나요, 아니면”Veweks”라고 읽으시나요? 아니면 혹시 프랑스 스타일의 조용한 “x”로 발음되는 “vew”라는 읽어야 하는 것일까요?단어를 읽는 법부터 햇갈리기 시작합니다.</p><p>저는 열렬한 Vue 개발자이기 때문에, Vuex가 실제로 무엇인지 몰라도 그것이 Vue 생태계의 중요한 부분은 차지하는 것임을 인지할 만큼 충분히 들어왔습니다.</p><p>결국 호기심에 지쳐서 Vuex의 간단한 정의라도 알고자 Vuex 공식 문서를 훑어보게 되었습니다.</p><p>유감스럽게도 저는 문서에서 “state management pattern”,”global singleton”,”source of truth”와 같은 낯선 용어들을 접하게 되었습니다. 이 용어들은 이 개념에 대해 이미 알고 있는 사람이라면 친근했을 법한 단어들이었지만, 저에게는 아니었습니다.</p><p>그래도 제가 알게 된 한가지는, Vuex가 Flux와 Redux와 관련이 있다는 것이었습니다. 물론 전 이것들도 Vuex와 마찬가지로 전혀 감이 안잡혔지만, 공부해보면 도움이 될 것 같았습니다.</p><p>약간의 연구와 끈기를 갖고 공부해보니, 복잡한 전문 용어 뒤의 숨어있던 개념들이 이해되기 시작했습니다. 이것들을 이해하고 난 후에 다시 Vuex 문서로 돌아가 보니 Vuex가 정말 쩐다는 사실을 알게되었습니다.</p><p>아직도 Vuex를 읽는 법은 잘 모르지만, Vuex는 제가 Vue 어플리케이션을 짜는데 필수적인 부분이 되었습니다. 여러분도 아마 한번쯤은 확인해 볼 가치가 있을 것 같습니다. 이것이 제가 Vuex의 간단한 입문서를 작성하게 된 계기입니다.</p><h3>Vuex가 해결할 수 있는 문제들</h3><p>Vuex를 이해하려면 먼저 이것이 어떤 문제를 해결하기 위해 고안되었는지를 찾아봐야합니다.</p><p>채팅 앱을 개발했다고 가정해 봅시다. UI에는 현재 보고 있지 않은 다른 사용자의 읽지 않은 메시지를 사용자에게 알리기 위한 사용자 목록, 개인 채팅 창, 채팅 기록이 있는 받은 편지함 및 알림 표시줄이 있습니다.</p><p>수백만명의 사용자들이 매일 당신의 앱을 통해 수백만명의 다른 사용자들과 채팅을 하고 있습니다. 그러나 사용자들에게서 알림 표시줄에서 잘못된 알림을 보내는 경우가 있다고 보고를 받습니다. 사용자들이 이미 읽은 메시지를 읽지 않은 메시지라고 표시한다는 것이죠.</p><p>제가 설명한 것은 페이스북 채팅 시스템에서 실제로 발생했던 문제입니다. 이 문제를 해결하는 과정에서 개발자들은 “플럭스(flux)”라는 애플리케이션 아키텍처를 구축하게 되었습니다. 플럭스는 Vuex, Redux및 기타 유사 라이브러리의 기초를 이룹니다.</p><h3>Flux</h3><p>페이스북 개발자들은 얼마 동안 이 “좀비 알림”과 씨름했습니다. 그들은 결국 그것이 단순한 버그 이상의 것임을 깨닫게 되었습니다. 애플리케이션 아키텍처의 몇가지 근본적인 결함이 있었던 것입니다.</p><p>이 결함은 추상적으로 설명하자면 이러합니다. 애플리케이션을 데이터를 공유하는 구성 요소가 여러개 있으면, 그 구성 요소들이 복잡하게 상호 작용할수록 데이터의 상태를 더 이상 예측할 수 없거나 이해할 수 없는 지점까지 증가합니다. 결국 애플리케이션을 확장하거나 유지 관리할 수 없는 상황이 발생할 수 있습니다.</p><p>Flux 의 개념은 이러한 결함을 충분히 완화시키는 확장 가능한 아키텍처를 설명하는 일련의 가이드 원칙들을 만드는 것이었습니다. 비단 채팅 앱뿐만 아니라 구성 요소 및 공유 데이터 상태가 있는 복잡한 UI앱에서도 적용되는 개념입니다.</p><h3>Flux는 라이브러리가 아니라 패턴입니다.</h3><p>Github에 가서 Flux를 다운 받을 수는 없습니다. 이것은 MVC와 같은 디자인 패턴입니다. Vuex 및 Redux와 같은 라이브러리는 마치 여러 프레임워크들이 MVC 패턴을 구현하듯이, Flux 패턴을 구현한 것입니다.</p><p>사실 Vuex는 Flux의 모든 패턴을 구현하지는 않습니다. 단지 하위의 일부분을 구현할 뿐이죠. 이 부분은 지금 신경쓰지 말고 대신 패턴의 주요 원칙을 이해하는 데 초점을 맞춥시다.</p><h3>원칙 #1: Single Source of Truth (단일 데이터 소스)</h3><p>컴포넌트들은 자기만 신경쓰면 될 로컬 데이터들을 갖고 있습니다. 예를 들어 사용자 목록 컴포넌트의 스크롤 막대 위치는 다른 컴포넌트들에서는 관심이 없는 데이터입니다.</p><p><strong>그러나 컴포넌트들 간에 공유해야 하는 데이터(예:애플리케이션 데이터)는 이를 사용하는 컴포넌트와는 별도로 단일 위치에 보관해야 합니다.</strong></p><p>이 단일 위치를 “store”(저장소)라고 합니다. 컴포넌트는 이 위치에서 애플리케이션 데이터를 읽어야 하며 충돌이나 불일치를 방지하기 위해 복사본을 자체적으로 보관해서는 안 됩니다.</p><pre>// &quot;store&quot;를 초기화합니다.</pre><pre>const store = new Vuex.Store({<br>  <br>  //&quot;state&quot;는 구성 요소들이 관찰할 애플리케이션 데이터입니다.<br>  state: {     <br>    myValue: 0   <br>  }<br>});</pre><pre>// 컴포턴트들은 computed 속성에서 store의 state를 가져올 수 있습니다.</pre><pre>const MyComponent = {   <br>  template: `&lt;div&gt;{{ myValue }}&lt;/div&gt;`,<br>  computed: {<br>    myValue () {<br>      return store.state.myValue;<br>    }   <br>  } <br>};</pre><h3>원칙 #2: Data is Read-Only (데이터는 읽기만 해야합니다.)</h3><p>컴포넌트들은 저장소에서 데이터를 자유롭게 읽을 수 있습니다.그러나 직접 변경할 수는 없습니다.</p><p>대신에 데이터를 변경할 것이라는 것을 store에 알려야 하며, store은 “mutations”이라고 하는 정의된 함수들을 통해 변경을 완수해야할 책임이 있습니다.</p><p>왜 이렇게 번거롭게 접근을 할까요? 이렇게 데이터 변경 로직을 중앙 집중화하면 데이터에 불일치가 일어나거나 데이터에 다른 문제들이 생겼을 때 여러 곳을 일일이 뒤져볼 필요가 없습니다. 이것은 어떤 익명의 컴포넌트(아마도 써드 파티 모듈)가 예상치 못한 방식으로 데이터를 변경할 가능성을 최소화 해줍니다.</p><pre>const store = new Vuex.Store({ <br>  state: { <br>    myValue: 0<br>  }, <br>  mutations: { <br>    increment (state, value) { <br>      state.myValue += value;<br>    }<br>  } <br>});</pre><pre>// 값을 업데이트 해야할 상황이 생겼나요?</pre><pre>// 틀렸습니다! 직접 store 데이터에 접근하지 마세요.<br>store.myValue += 10;</pre><pre>// 그렇죠! 적절한 mutation을 호출해야합니다.<br>store.commit(&#39;increment&#39;, 10);</pre><h3>원칙#3:Mutations Are Synchronous (Mutation은 동기적이다)</h3><p>위에 두가지 원칙을 지키는 애플리케이션에서 데이터를 디버그 하는 것이 훨씬 쉽습니다. mutation의 commit을 기록하고 응답 상태가 어떻게 변경되는지 관찰할 수 있습니다. (Vue Devtools에서 Vuex를 사용할 때 실제로 그렇게 디버그할 수 있습니다.)</p><p>그러나 만약 우리의 “mutation”이 비동기적으로 일어난다면 그런 방식의 디버그는 불가능할것입니다. commit이 언제 발생했는지는 알 수 있어도, commit안에 콜백이나 Promise 같은 것들이 들어간다면 추적이 불가능해집니다.</p><p>mutation이 동기적으로 일어나는 것, 데이터가 예측할 수 없는 이벤트의 순서와 시간에 종속되지 않도록 보장합니다.</p><h3>마지막으로, 결국 Vuex는 뭔가요?</h3><p>방금 다룬 몇가지 배경 지식을 통해서 마침내 이 질문에 어느정도 단서를 찾을 수 있습니다.</p><p>Vuex는 Vue 애플리케이션에서 Flux 아키텍처를 구현하는 데 도움이 되는 라이브러리입니다. 위에서 설명한 원칙들을 적용함으로써 Vuex는 여러 컴포넌트에서 데이터를 공유하는 경우에도 애플리케이션 데이터를 투명하고 예측 가능한 상태로 유지합니다.</p><p>Vuex를 구현하기 위해서는 store, mutators 가 포함되며 store에서 데이터를 읽는 모든 컴포넌트를 자동으로 업데이트합니다.</p><p>또한 핫 모듈 리로딩(실행 중인 애플리케이션에서 모듈 업데이트)및 시간 이동 디버깅(버그 추적을 위한 mutation 이벤트 역추적)과 같은 멋진 개발 기능을 제공합니다.</p><h3>그거 쩌네요. 몇가지 질문이 있습니다만..</h3><p>아마도 여러분의 앱에 Vuex가 필요한지 아닌지 궁금하실 겁니다. 어떻게 하면 디버깅을 할 수 있는건지 혹은 어떻게 비동기로 데이터를 변경 할 수 있는지..여러가지 궁금증들이 있을 수 있습니다.</p><p>이 포스트에서 저의 목적은 단지 여러분에서 Vuex에 대한 간결한 개념을 설명하는 것이었습니다. 이 포스트를 읽고 <a href="https://vuex.vuejs.org/kr/">Vuex 공식 문서</a>를 쭉 읽어보시면, 아마 지금 여러분들이 갖고 있는 여러가지 궁금증들을 대부분 해결하실 수 있을 것이라 생각합니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad5bc15f2371" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[오 이런, 당신이 만든 API 좀 보세요!]]></title>
            <link>https://itsnothingg.medium.com/%EC%98%A4-%EC%9D%B4%EB%9F%B0-%EB%8B%B9%EC%8B%A0%EC%9D%B4-%EB%A7%8C%EB%93%A0-api-%EC%A2%80-%EB%B3%B4%EC%84%B8%EC%9A%94-98877936b10c?source=rss-cfb7ed030036------2</link>
            <guid isPermaLink="false">https://medium.com/p/98877936b10c</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[최인탁]]></dc:creator>
            <pubDate>Sun, 22 Apr 2018 09:28:33 GMT</pubDate>
            <atom:updated>2018-04-22T09:28:33.755Z</atom:updated>
            <content:encoded><![CDATA[<p>해당 포스트는 <a href="https://medium.com/u/ac6a1c581fc3">Alexey Kuznetsov</a>의 Oh Man, Look at Your API! 포스트를 번역한 것입니다.</p><p><a href="https://medium.com/pixelpoint/oh-man-look-at-your-api-22f330ab80d5">Oh Man, Look at Your API!</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*UYZJ3-2Dmxr-0IbJ8NqJEg@2x.png" /></figure><p>세상을 좀 더 나은 곳으로 만들기 위한 저의 작은 노력이 여기 있습니다. API를 구축하고 있거나 기존의 API를 개선하고 싶은 마음이 있는 분들에게 유용하리라 생각합니다. 여기 나오는 조언들은 제가 작업했던 수 많은 API들에서 겪은 괴로운 경험에 기초하고 있습니다. 치를 떨만큼 싫은 API나, 능력을 개발하는 데 도움이 되기도 하는 API들이 있었지만, 대부분은 좌절감과 허망한 웃음정도 밖에 남기지 않았습니다. 보다시피 다뤄야 할 것들이 많으니 시작해봅시다!</p><h3>잘 만들어진 API는 심심합니다. 예외는 없습니다.</h3><p>어떠한 새로운 것을 개발해내려 하지 마세요. 시스템의 성질은 어디서나, 어떤 단계든지 동일해야합니다. API 끝점 구성 및 데이터 입력/출력 형식에 모두 적용되는 원리입니다. 우리는 심심한 표준 API오류 메시지와 요청/응답 헤더가 필요합니다. 모든 데이터 타입의 필드는 항상 입력/출력 형식이 동일해야 합니다. 공백인 필드는 모두 동일하게 표시되어야 합니다. API 프로세스를 프로그래밍하는 것은 거짓말하는 것과 매우 유사합니다. 많은 것들이 쌓이면 쌓일수록, 나중에 여러분들이나 사용자분들이 감당해야 할 것들도 많아집니다. 다른 말로 하면, API가 더 심심하게 설계 될 수록 사용자분들의 만족도는 올라가게 되어있다는 것입니다.</p><p>아, 이 조언은 전체 정보 시스템을 설계 할 때도 적용되니, 마음에 새겨두는 것이 좋습니다.</p><h3>문서화</h3><p>우리는 늘 API를 문서화 하라는 조언을 듣지만, 대부분의 사람들은 이 일을 하기 싫어합니다. 문서화 할 시간이 충분해 보이는 사람이 아무도 없다는 것을 이해하지만, 문서는 API의 얼굴입니다. 코딩을 잠시 멈추고, 문서를 작성하는 데 시간을 투자하는 것이 더 가치 있을 수 있습니다. 문서화를 위한 몇가지 기본 팁이 있습니다.</p><ul><li>동작하는 HTTP 요청 및 응답 예제나, 실제로 사용되고 있는 코드를 제공해야합니다.</li><li>문서는 API 자체 만큼이나 일관성있게 서식화 되어야 합니다.</li><li>API의 기본 원칙을 명확하고 자세히 설명해야 합니다.</li><li>Swagger, Apiary 또는 Postman과 같은 API프레임워크를 사용해야 합니다.</li></ul><p><strong>좋은 문서를 제공하지 않는 API를 사용하는 것은, 마치 복잡한 퍼즐을 조각 조각 맞추는 것과 유사한 경험을 겪게합니다.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*VzvWMugN_qazr2xeIkcrrQ@2x.jpeg" /><figcaption>Postman API 문서 예</figcaption></figure><h3>오류 처리</h3><p>문서화가 잘 되어 있지 않더라도 오류 메시지가 잘 되어있다면 그것에 의존하여 꽤 많은 것들을 처리 할 수 있습니다. 사용자 경험에 있어서 명확하고 정확한 오류 메시지를 전달 받는 것이 굉장히 중요하다는 것은 두말하면 입아픈 사실입니다. 마찬가지로 API 개발자들에도 좋은 오류 메시지는 작업에 대한 자신감을 높여 주고 오류에 신속하게 대응할 수 있도록 해 줍니다.</p><p><strong>잘못된 오류:</strong></p><pre>HTTP/1.1 422 Unprocessable Entity</pre><pre>{<br>    “error”: Invalid Attribute<br>}</pre><p><strong>좋은 오류:</strong></p><pre>HTTP/1.1 422 Unprocessable Entity<br>Content-Type: application/vnd.api+json</pre><pre>{<br>    &quot;errors&quot;: [<br>        {<br>            &quot;status&quot;: &quot;422&quot;,<br>            &quot;source&quot;: { &quot;pointer&quot;: &quot;/data/attributes/first-name&quot; },<br>            &quot;title&quot;: &quot;Invalid Attribute&quot;,<br>            &quot;details&quot;: &quot;First name must contain min three chars.&quot;<br>        }<br>    ]<br>}</pre><h3>Authorization</h3><p>오직<strong> 표준화</strong> 된 Authorization 만이 사용 가치가 있습니다. 부디 이를 망치지 말아주세요. Authorization 프로세스가 너무 독특하거나 너무 취약하면 심각한 문제가 됩니다. OAuth를 예로 들어봅시다. OAuth는 액세스 토큰이 업데이트 될 때마다 리프레시 토큰을 발급합니다. 또한 액세스 토큰에는 만료 시간도 있어야 합니다. 제 생각에 이건 너무 과다한 것 같습니다. 첫째로 사용자가 요구하는 보안 수준을 파악해보고, 만료되지 않는 토큰을 사용해도 되는 지 판단해 볼 필요가 있습니다. 둘째로 프로세스를 단순화 시켜야 합니다. 많은 훌륭한 API들이 정적인 리프레시 토큰을 사용합니다. 보안성과 복잡성이 동의어는 아닙니다.</p><h3>데이터 형식</h3><p>새로운 데이터 형식을 구성할 생각조차 하지 말아주세요! 고유한 데이터 형식을 사용하는 API를 몇 번 본적있었는데, 늘 엉망이었습니다. 고유한 데이터 형식을 사용하면 작업 속도가 크게 저하되고 처리할 일이 많아집니다. 물론, 이런 이상한 생각들이 쏟아질 때 여러분들의 창조성을 억누르기는 힘들다는 것을 알고 있고, 힘들게 개발한 작업물을 그냥 던져 버리는 것이 매우 어렵다는 것도 잘 알고 있지만, 꼭 저항해야합니다. 우리에게는 이미 JSON, XML과 다른 모든 것들이 있습니다. 그렇죠? 그것들이면 충분합니다.</p><p>JSON API와 같은 좋은 사양을 이용해야합니다. JSON API는 Stripe, Braintree등의 많은 회사에서 이미 성공적으로 사용하고 있습니다. JSON은 보기에 좋으며, 구조화된 데이터 형식을 사용하기 쉽고, 이미 대중화 되어 표준 규격으로 자리 잡았습니다.</p><p>아 그리고, 다중 데이터 형식을 지원할 필요가 없습니다. 모든 프로그래밍 언어 및 기술은 이미 모든 표준 유형에 대해 데이터 형식 지정 및 구문 분석을 지원하기 때문에 사용자들은 일반적으로 어떤 표준 데이터 형식을 사용하는지 크게 관심이 없습니다. 다중 데이터 형식을 지원 하면 API 및 문서 유지 관리 속도만 느려집니다.</p><h3>HTTP 상태 코드</h3><p>HTTP 상태는 200인데, 메시지는 내부 API 오류를 전달하는 것은 개발자들에게 혼란을 야기합니다. 이런 일은 개발을 지연시킵니다. HTTP 상태 코드는 오류 메시지 역할을 대신할 수 있습니다. 다음과 같은 일반적인 코드 목록이 있습니다.</p><pre><strong>200 (OK)</strong> — success, handle responded data.</pre><pre><strong>500 (Internal Server Error)</strong> — something went wrong, ask for API system technical support.</pre><pre><strong>400 (Bad Request)</strong> — wrong API request, check documentation.</pre><pre><strong>401 (Unauthorized)</strong> — wrong client credentials, recheck them or if API key token has expired, then refresh.</pre><pre><strong>403 (Forbidden)</strong> — unpermitted action, current user does not have enough access rights.</pre><pre><strong>404 (Not Found)</strong> — record not found, maybe it doesn’t exist anymore or wrong record ID was used.</pre><pre><strong>405 (Method Not Allowed)</strong> — this API method is not allowed anymore.</pre><pre><strong>406 (Not Acceptable)</strong> — not acceptable action, probably from attempt to save invalid data.</pre><p><a href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_errors">위키피디아</a>에서 남은 코드 목록들을 확인해 보면 틀림없이 언제나 적절한 코드를 찾을 수 있을 것입니다.</p><h3>Content-type</h3><p>매우 간단한 조언입니다. 변경해야 할 특별한 이유가 없다면 Content-type은 항상 같아야 합니다. 사용자 아키텍처의 일관성을 유지시키고 개발 프로세스를 가속화 및 단순화할 수 있도록 도움이 됩니다. 끝점에 대해 여러개의 Content-type 을 지원하지 마세요. 끝점을 사용하여 작업하는 개발자는 이 때문에 혼란스러울 수 있습니다. 예를 들어 끝점”A”는 정상적으로 작동하지만 끝점”B”는 동일한 방식으로 사용하더라도 잘못된 요청 오류를 반환 하는 경우가 생길 수 있습니다. Content-type을 변경하는 것은 명확한 해결책으로 보이지 않습니다.</p><h3>객체 구조</h3><p>사용자 입장에서 볼 때, 객체가 실제로 어떤 개체들을 포함 하는지 알 수 있는 것은 매우 도움이 됩니다. API에 전체 개체 필드 맵을 반환하는 특수한 끝점이 있다면 완벽합니다. 그런 끝점이 없다면 최소한 객체를 호출할 때, 개체가 비어 있는 경우에도 모든 필드를 반환하도록 보장해야합니다. 여기서 역동성과 간결함은 요구되지 않습니다.</p><pre>{<br>    &quot;id&quot;: &quot;9c7fd1e5-97f0-4b6a-979c-1d7adf5bda16&quot;,<br>    &quot;email&quot;: &quot;<a href="/service/mailto:example@gmail.com">example@gmail.com</a>&quot;,<br>    &quot;firstname&quot;: &quot;John&quot;,<br>    &quot;lastname&quot;: &quot;Smith&quot;,<br>    &quot;timezone&quot;: <strong>null</strong>,<br>    &quot;phone_code&quot;: &quot;RU&quot;,<br>    &quot;phone&quot;: null,<br>    &quot;created_at&quot;: &quot;2018-03-27T05:40:31.929Z&quot;,<br>    &quot;updated_at&quot;: &quot;2018-04-08T09:24:39.683Z&quot;,<br>    &quot;citizenship&quot;: <strong>null</strong><br>}</pre><h3>Pagination</h3><p>제가 한 유명한 CRM시스템에서 API Connector를 만들고 있을 때, 그 시스템에 Pagination 리코드가 없는 것을 발견하여 관련해서 기술 지원에 문의를 한 적이 있습니다. ”불행하게도 포함되지 않는 기능입니다. 하지만 좋은 아이디어네요” 와 같은 믿을 수 없는 답변을 들어야 했습니다. 저는 여러분 모두가 왜 우리가 모든 데이터를 동시에 로딩할 수 없는지 명확하게 이해하고 있다는 것을 알고 있기 때문에, 제 관점에서 무엇이 완벽한 Pagination인지 설명해 드리겠습니다.</p><ul><li>페이지 크기를 제어할 수 있는 것은 유용합니다. 사용자가 스스로 요청의 양과 품질 사이에서 선택할 수 있도록 기회를 제공해줍니다.</li><li>얼마나 많은 레코드를 갖고 있는지 이해하도록 메타 정보를 가지고 있습니다. 모든 레코드를 로딩하는 경우 진행 상황을 파악하는 데 큰 도움이 됩니다. 또한 레코드 수를 계산하는데 모든 페이지를 로딩할 필요가 없으므로, 시간과 돈을 아낄 수 있습니다.</li><li>명확하고 일관성있는 pagination 변수명이 선언됩니다. (예:page_number-현재 페이지 번호, page_size — 페이지 단위, pages_total_count — 총 페이지 수 등).</li></ul><h3>이미지 및 파일</h3><p>당연한 것이지만, 응답 데이터에 파일이나 영상 본문을 포함해서는 안 됩니다. 임시 업로드 링크를 반환하는 것이 훨씬 낫습니다.</p><h3>시간과 날짜</h3><p>사용되는 표준 시간대를 명시적으로 지정하는 것이 정말 중요하다는 것을 짚고 싶습니다. 문서에 명시할 수도 있고, 데이터 형식에 명시할 수도 있습니다. 시간대를 어떻게 사용해야하는지는 여기서 다룰 만한 내용이 아니지만, 간단하게 말하자면: 유닉스 시간을 반환하면 됩니다. 유닉스 시간은 UTC 시간대를 기준으로 하기 때문에, 모든 사용자들은 이 유닉스 시간을 받아 자신에게 알맞은 형식과 시간대로 변환 할 수 있습니다.</p><pre>{<br>  ...<br>  &quot;created_at&quot; =&gt; article.created_at.utc.to_i <br>}.to_json</pre><pre>#=&gt; { ..., created_at: 1523556863 }</pre><h3>결제 구상</h3><p>미결제 사용자가 결제를 필요하는 끝점을 사용하려고 할 때 HTTP상태 코드를 사용하여 사용자에게 결제가 필요하다는 것을 알려야 합니다. 때로 사용자는 무엇이 잘못된 줄 모르고 애꿎은 곳에 시간을 낭비하는 경우가 생길 수 있습니다. 여기에는 402 “Payment Required” HTTP상태 코드를 사용하시기를 권합니다. 사용자에게 명확하게 전달만 된다면 어떤 HTTP 상태 코드를 사용하는지는 크게 상관 없습니다. API문서에도 이러한 끝점 사용 조건에 사항이 명시 되어 있어야 합니다.</p><h3>API 요청 제한</h3><p>API에 요청 제한을 두기를 원하신다면, 한계에 도달했을 때 명확한 오류 메시지가 표시되어야 합니다. 이상적으로, 이러한 제한 관련 정보를 포함하는 특수 끝점이 있다면 좋습니다. 사용자가 API요청 수를 계산할 필요가 없어야 합니다. API 쪽에서 모든 정보를 이미 갖고 있기 때문입니다. HTTP응답 해더에 사용 가능한 API호출에 대한 정보를 제공하는 것이 좋습니다. 예를 들어:</p><pre>X-RateLimit-Limit - Request limit per hour</pre><pre>X-RateLimit-Remaining - The number of requests left for the time window</pre><p><a href="https://www.zoho.eu/crm/help/api/api-limits.html#API_Limit">Example of API Limits in ZohoCRM</a></p><h3>논리적인 측면</h3><p>API를 개발하는 동안 시행할 수 있는 좋은 아이디어 중 하나는, 자신을 사용자와 동일한 자리에 올려 놓는 것입니다. 이렇게 하면 초기 단계에서 많은 유용한 것들을 발견할 수 있습니다. 예를 들어 저는 일부 API에서 동일한 레코드를 두 번 삭제해도 똑같은 응답이 나타난다는 것을 발견했습니다. 제 생각에 이 응답은 사용자가 레코드를 다시 제거했거나 다른 레코드를 제거했다는 잘못된 인식을 갖게 하기 때문에 좋지 않습니다. 기록이 이미 삭제된 경우 404 HTTP상태 코드를 반환하여 고객이 실수를 알아차릴 수 있도록 해 주어야 합니다.</p><h3>API에 대한 고찰</h3><p>이상한 API 끝점이 있다는 것은 나쁜 프로젝트 설계의 징후일 수 있습니다. 그러니, facades나 adapter를 만드는 데 뛰어들지 말고, 잠시 코드에서 눈을 때고 큰 그림을 둘러보세요. 리팩터링의 좋은 기회가 되어 API 인터페이스를 단순화하고, 프로젝트 구조를 개선 시킬 수 있는 좋은 기회가 될 가능성이 있습니다.</p><h3>마치며</h3><p>뛰어난 품질과 사용하기 쉬운 API를 만들어 내는 모든 개발자들에게 큰 감사를 전하고 싶습니다! 여러분들은 주로 자기만의 인식과 감각에 기인하여 행동한다는 것을 알고 있습니다. 얼핏 보면, 이러한 투자는 단기적으로 명백한 이익을 내지 못하는 것처럼 보일 수 있지만, 점점 늘어나는 고객 충성도를 통해 장기적인 효과를 거둘 것이라고 믿고 있습니다. 이 고된 일을 부지런한 하는 개발자들에게 행운이 있기를!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98877936b10c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>