<?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 Kien Nguyen on Medium]]></title>
        <description><![CDATA[Stories by Kien Nguyen on Medium]]></description>
        <link>https://medium.com/@kiennguyen88?source=rss-554cda741a01------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XctMYvETU4AW1x-I_yDtqg.jpeg</url>
            <title>Stories by Kien Nguyen on Medium</title>
            <link>https://medium.com/@kiennguyen88?source=rss-554cda741a01------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 19:39:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kiennguyen88/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[[Windows, Docker] ENOENT: no such file or directory, open /home/node/app/package.json]]></title>
            <link>https://medium.com/@kiennguyen88/windows-docker-enoent-no-such-file-or-directory-open-home-node-app-package-json-6eb2b6291866?source=rss-554cda741a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/6eb2b6291866</guid>
            <dc:creator><![CDATA[Kien Nguyen]]></dc:creator>
            <pubDate>Tue, 21 Jan 2020 04:07:56 GMT</pubDate>
            <atom:updated>2020-01-21T04:07:56.531Z</atom:updated>
            <content:encoded><![CDATA[<p>On Windows’s Docker, sometime you will see the error like this when using Docker compose</p><blockquote>Creating network “test_default” with the default driver<br>Creating test_node_1 …<br>Creating test_node_1 … done<br>Attaching to test_node_1<br>node_1 | npm ERR! path /home/node/app/package.json<br>node_1 | npm ERR! code ENOENT<br>node_1 | npm ERR! errno -2<br>node_1 | npm ERR! syscall open<br>node_1 | npm ERR! enoent ENOENT: no such file or directory, open ‘/home/node/app/package.json’<br>node_1 | npm ERR! enoent This is related to npm not being able to find a file.<br>node_1 | npm ERR! enoent<br>node_1 |<br>node_1 | npm ERR! A complete log of this run can be found in:<br>node_1 | npm ERR! /home/node/.npm/_logs/2018–03–05T10_57_04_874Z-debug.log<br>test_node_1 exited with code 254</blockquote><p>One of the issue with Windows is that after you change Windows password, you will need to share the folder from Windows — Docker again to re-apply the file permission to Docker.</p><p>I found the answer here and it’s solve my issue, take a note if someone need it</p><p><a href="https://github.com/nodejs/docker-node/issues/533">https://github.com/nodejs/docker-node/issues/533</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6eb2b6291866" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Java core] BufferedReader vs Scanner]]></title>
            <link>https://medium.com/@kiennguyen88/bufferedreader-vs-scanner-aeda8f2c115c?source=rss-554cda741a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/aeda8f2c115c</guid>
            <category><![CDATA[regex]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[core-java]]></category>
            <dc:creator><![CDATA[Kien Nguyen]]></dc:creator>
            <pubDate>Wed, 12 Apr 2017 02:37:18 GMT</pubDate>
            <atom:updated>2017-04-12T02:38:01.250Z</atom:updated>
            <content:encoded><![CDATA[<p>A note of BufferedReader vs Scanner</p><p><strong>BufferedReader</strong></p><ul><li>Introduced since JDK 1.1</li><li>Synchronized -&gt; can be shared between threads</li><li>8KB buffer -&gt; to read long string file is good</li><li>Just read until end-of-line appeared in regular reader mode and do nothing after data is read</li><li>Because of synchronous it a little slower than Scanner, but because of Scanner used regex and conversion so at the end, BufferedReader is slightly faster than Scanner</li></ul><p><strong>Scanner</strong></p><ul><li>Asynchronous -&gt; should’t be directly share between threads</li><li>Introduced since Java 1.5, newer than BufferedReader &amp; more utility power</li><li>1KB buffer -&gt; to read short input &amp; input rather than String</li><li>Scanner use regular expression to read data for nextXXX and do conversion after data is read into Java primitive types (like nextInt, nextFloat…) -&gt; more power</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aeda8f2c115c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Pattern: Singleton Pattern, pros & cons]]></title>
            <link>https://medium.com/@kiennguyen88/design-pattern-singleton-pattern-d5f600dcca0b?source=rss-554cda741a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5f600dcca0b</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Kien Nguyen]]></dc:creator>
            <pubDate>Fri, 02 Dec 2016 03:32:59 GMT</pubDate>
            <atom:updated>2016-12-02T04:03:42.904Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week we discussed about Factory Pattern which is one of the creational pattern group. Today I will make a note about another simple pattern.</p><p>Singleton provide one of the best way to create an object. This pattern come by using a class to making sure only one instance of class can be created by provide way to access on the object directly without need to instantiate the object of the class.</p><p>The concept is about to make class have a private constructor and an static instance of itself. Like this</p><pre>public class SingleObject {<br><br>   //create an object of SingleObject<br>   private static SingleObject instance = new SingleObject();<br><br>   //make the constructor private so that this class cannot be<br>   //instantiated<br>   private SingleObject(){}<br><br>   //Get the only object available<br>   public static SingleObject getInstance(){<br>      return instance;<br>   }<br><br>   public void showMessage(){<br>      System.out.println(&quot;Hello World!&quot;);<br>   }<br>}</pre><p><strong>Example</strong></p><ul><li>Log file, you don’t want to just abandon a single log file. You want to flush, sync and close it properly. This is an example of a single shared resource that has to be managed.</li><li>Hardware is also an example. Embedded systems have lots of hardware that might use singletons — or maybe one big one</li></ul><p><strong>Disadvantages</strong></p><p><em>Misko Hevery, from Google: </em><strong>It’s make unit testing goes crazy :D</strong></p><p>Singletons are nothing more than global state. Global state makes it so your objects can secretly get hold of things which are not declared in their APIs, and, as a result, Singletons make your APIs into pathological liars.</p><p><a href="https://www.youtube.com/watch?v=-FRm3VPhseI">https://www.youtube.com/watch?v=-FRm3VPhseI</a></p><p><a href="http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/">Singletons are Pathological Liars</a></p><p><a href="https://www.tutorialspoint.com/design_pattern/singleton_pattern.htm">https://www.tutorialspoint.com/design_pattern/singleton_pattern.htm</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5f600dcca0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HashMap vs ConcurrentHashMap]]></title>
            <link>https://medium.com/@kiennguyen88/hashmap-vs-concurrenthashmap-da2c2bb68f0b?source=rss-554cda741a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/da2c2bb68f0b</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Kien Nguyen]]></dc:creator>
            <pubDate>Fri, 02 Dec 2016 02:38:03 GMT</pubDate>
            <atom:updated>2016-12-02T02:38:32.514Z</atom:updated>
            <content:encoded><![CDATA[<ol><li><strong>Thread Safe</strong></li></ol><p>ConcurrentHashMap is thread-safe and only allow access from one thread at the same time which is HashMap not. HashMap allow multithread to access.</p><p><strong>2. Synchronization method</strong></p><p>HashMap can be synchronised by using synchronizedMap(HashMap). So every modification on Map is locked by the Map Object. But remember this is different to ConcurrentHashMap caused synchronizedMap make the lock to be on the object but the ConcurrentHashMap using lock on the bucket level. So usually ConcurrentHashMap is faster than synchronizedMap in case of thread-safe, they are not equal at all</p><p><strong>3. NULL key</strong></p><p>HashMap allow only one NULL key but ConcurrentHashMap is not</p><p><strong>4. Performance</strong></p><p>In multiple threaded environment HashMap is usually faster than ConcurrentHashMap . As only single thread can access the certain portion of the Map and thus reducing the performance.</p><p>While in HashMap any number of threads can access the code at the same time</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da2c2bb68f0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Daily design pattern] Day 0: What is that]]></title>
            <link>https://medium.com/@kiennguyen88/daily-design-pattern-day-0-what-is-that-35e66f7bde52?source=rss-554cda741a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/35e66f7bde52</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Kien Nguyen]]></dc:creator>
            <pubDate>Thu, 15 Sep 2016 03:12:41 GMT</pubDate>
            <atom:updated>2016-09-15T03:12:55.436Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Creational Patterns</strong></p><p>These design patterns provide a <strong>way to create objects</strong> while hiding the creation logic, rather than instantiating objects directly using new opreator. This gives program more flexibility in deciding which objects need to be created for a given use case.</p><p><strong>Structural Patterns</strong></p><p>These design patterns concern <strong>class and object composition</strong>. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.</p><p><strong>Behavioral Patterns</strong></p><p>These design patterns are specifically concerned with <strong>communication between objects</strong>.</p><p><strong>J2EE Patterns</strong></p><p>These design patterns are specifically concerned with the <strong>presentation tier</strong>. These patterns are identified by <strong>Sun Java Center</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35e66f7bde52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Daily design pattern] Day 1: Factory Pattern]]></title>
            <link>https://medium.com/@kiennguyen88/daily-design-pattern-day-1-factory-pattern-3c06b3279f1f?source=rss-554cda741a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c06b3279f1f</guid>
            <category><![CDATA[software-architect]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Kien Nguyen]]></dc:creator>
            <pubDate>Thu, 15 Sep 2016 03:05:57 GMT</pubDate>
            <atom:updated>2016-09-15T03:07:57.203Z</atom:updated>
            <content:encoded><![CDATA[<ol><li><strong>What is that?</strong></li></ol><p>One of most used design pattern in Java. Create object <strong>without exposing the creation logic to the client</strong> and refer to newly created object using a <strong>common interface</strong></p><p><strong>2. How</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*xaDe3AsrsUn_fxb2m-fedg.png" /></figure><pre>shapeFactory.getShape(&quot;SQUARE&quot;)<br>shapeFactory.getShape(&quot;CIRCLE&quot;)<br>shapeFactory.getShape(&quot;RECTANGLE&quot;)</pre><p><strong>3. Pros &amp; cons</strong></p><p>PROS</p><p>Allows you to <strong>hide implementation</strong> of an application seam (the core interfaces that make up your application)</p><p>Allows you to <strong>easily test</strong> the seam of an application (that is to mock/stub) certain parts of your application so you can build and test the other parts</p><p>Allows you to change the design of your application more readily, this is known as <strong>loose coupling</strong></p><p>CONS</p><p>Makes code more <strong>difficult to read</strong> as all of your code is behind an abstraction that may in turn hide abstractions</p><p>Can be classed as an <strong>anti-pattern</strong> when it is incorrectly used, for example some people use it to wire up a whole application when using an IOC container, instead use Dependency Injection.</p><p><strong>Too much abstract</strong></p><p>4. Where to use in TCBS?</p><p>PricingEngine.getEntry(product, time)/PricingEngine.getExit(order)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c06b3279f1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hệ thống cũng như xã hội ngoài đời thực]]></title>
            <link>https://medium.com/@kiennguyen88/h%E1%BB%87-th%E1%BB%91ng-c%C5%A9ng-nh%C6%B0-x%C3%A3-h%E1%BB%99i-ngo%C3%A0i-%C4%91%E1%BB%9Di-th%E1%BB%B1c-2545fdf71435?source=rss-554cda741a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/2545fdf71435</guid>
            <category><![CDATA[lunar-new-year]]></category>
            <dc:creator><![CDATA[Kien Nguyen]]></dc:creator>
            <pubDate>Thu, 10 Mar 2016 04:29:45 GMT</pubDate>
            <atom:updated>2016-03-10T04:29:45.878Z</atom:updated>
            <content:encoded><![CDATA[<p>Học suốt nhiều năm kể từ ngay ra trường/ra đường kiếm ăn, không phải lúc nào cũng ghi nhớ trong đầu, nhưng vô cùng tâm đắc, và luôn cố gắng để theo nó. Hầu hết với người Việt Nam thì nó rất khó chấp nhận, nhưng để phát triển, thì cần phải có một thứ, đó là “chấp nhận sự khác biệt&quot;</p><p>Một hệ thống chạy ngoài đời thật không bao giờ tránh khỏi được việc thiếu thông tin, nhưng cái cách giải quyết không phải đi sửa tất cả các dữ liệu đấy để dữ liệu trông đẹp như một điểm 10 tròn trĩnh. Trước giờ người ta vẫn thích số 9 hơn là như thế.</p><p>Cần học cách chấp nhận rằng hệ thống có chứa những thông tin không đầy đủ, những khách hàng thuộc lớp thông tin không đầy đủ này trở thành một tập khách hàng riêng, cũng cần có những phương pháp xử lý. Nếu như hệ thống của bạn không thống kê được “người dùng có mấy con&quot;, hoặc là “single hay là không&quot; thì hãy đối xử với người ta như một lớp người dùng “chưa hiểu rõ thông tin&quot; và sử dụng các phương pháp truyền thông riêng tiếp cận họ.</p><p>Hãy chấp nhận có một loại người dùng đang thiếu thông tin (so với tiêu chuẩn của bạn), nếu họ chỉ có email thì hãy email cho họ, nếu họ chỉ có phone thì hãy gọi cho họ.</p><p>Nếu họ đăng nhập bằng Facebook thì hãy chấp nhận rằng họ không bao giờ đưa CMND lên Facebook, hãy chấp nhận rằng có người public trạng thái hôn nhân, và có rất nhiều người không, bù lại họ có danh sách bạn bè để khai thác. Nhưng người khác không có danh sách bạn bè nào thì họ không phải lỗi của hệ thống, họ chỉ là “lớp người dùng thiếu thông tin&quot; mà thôi. Fundamental của chăm sóc khách hàng cũng đơn giản là “phân lớp được khách hàng&quot;. Nếu họ thiếu thông tin mà bạn cần, bạn muốn biết, vui lòng bật popup và yêu cầu họ giúp đỡ bạn bổ xung thông tin.</p><p><strong>Hãy chấp nhận user cũng có tầng lớp như xã hội, hãy có chính sách cho từng tầng lớp user, đừng cố ghép họ vào tầng lớp này hay tầng lớp kia. Họ không thuộc về nơi đấy!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2545fdf71435" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RabbitMQ delay retry/schedule with Dead Letter Exchange]]></title>
            <link>https://medium.com/@kiennguyen88/rabbitmq-delay-retry-schedule-with-dead-letter-exchange-31fb25a440fc?source=rss-554cda741a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/31fb25a440fc</guid>
            <dc:creator><![CDATA[Kien Nguyen]]></dc:creator>
            <pubDate>Tue, 03 Nov 2015 09:47:18 GMT</pubDate>
            <atom:updated>2015-11-03T09:51:04.710Z</atom:updated>
            <content:encoded><![CDATA[<p>Java source code</p><p><a href="https://dl.dropboxusercontent.com/u/6255973/RetryHandler.java">https://dl.dropboxusercontent.com/u/6255973/RetryHandler.java</a></p><p>Sometimes you don’t want messages in the queue to be read immediately. For example, you have a message that can’t be proceed <em>right now</em> but you want to requeue it and try again in 5 minutes. Unfortunately, <a href="http://www.rabbitmq.com/">RabbitMQ</a> doesn’t come with native support for delayed or scheduled messages. Fortunately, RabbitMQ 2.8.0 introduced <a href="http://www.rabbitmq.com/dlx.html">Dead Letter Exchanges</a> (DLX), which allows us to simulate message scheduling.</p><h4>Dead what?</h4><p>When you create a queue (A) bound to an exchange (X), you can also specify an exchange (DLX) to redirect expired and rejected messages to. This is the dead letter exchange. Then you have another queue (B) bound to this dead letter exchange (DLX) to consume messages as they drop off the original queue (A).</p><p>In practice, if we wanted to enable retry on failure every 5 minutes, the flow would look like this:</p><ol><li>Create WorkQueue bound to WorkExchange</li><li>Create RetryQueue bound to RetryExchange</li></ol><ul><li>Set x-dead-letter-exchange to WorkExchange</li><li>Set x-message-ttl to 300000 ms (5 minutes)</li></ul><ol><li>Publish message to WorkQueue</li><li>Client reads message from WorkQueue and attempts to process it</li><li>Process fails and client publishes to RetryQueue</li><li>Messages sits in RetryQueue for 5 minutes</li><li>When message expires, it is requeued to WorkQueue for another attempt at processing</li><li>Repeat steps 4–7</li></ol><p>Here’s how you do it in C#:</p><h4>Create the WorkQueue</h4><pre><em>// using RabbitMQ.Client;</em></pre><pre><strong>private</strong> <strong>const</strong> <strong>string</strong> WORK_QUEUE = &quot;WorkQueue&quot;;<br><strong>private</strong> <strong>const</strong> <strong>string</strong> WORK_EXCHANGE = &quot;WorkExchange&quot;; <em>// dead letter exchange</em></pre><pre>ConnectionFactory factory = <strong>new</strong> ConnectionFactory();<br>factory.HostName = &quot;localhost&quot;;<br> <br>IConnection connection = factory.CreateConnection();<br>IModel channel = connection.CreateModel();<br> <br>channel.ExchangeDeclare(WORK_EXCHANGE, &quot;direct&quot;);<br>channel.QueueDeclare(WORK_QUEUE, <strong>true</strong>, <strong>false</strong>, <strong>false</strong>, <strong>null</strong>);<br>channel.QueueBind(WORK_QUEUE, WORK_EXCHANGE, <strong>string</strong>.empty, <strong>null</strong>);</pre><h4>Create the RetryQueue</h4><pre><strong>private</strong> <strong>const</strong> <strong>string</strong> RETRY_EXCHANGE = &quot;RetryExchange&quot;;<br><strong>private</strong> <strong>const</strong> <strong>string</strong> RETRY_QUEUE = &quot;RetryQueue&quot;;<br><strong>private</strong> <strong>const</strong> <strong>int</strong> RETRY_DELAY = 300000; <em>// in ms</em></pre><pre><em>// Messages will drop off RetryQueue into WorkExchange for reprocessing</em><br><em>// All messages in queue will expire at same rate</em><br><strong>var</strong> queueArgs = <strong>new</strong> Dictionary&lt;<strong>string</strong>, <strong>object</strong>&gt; {<br>    { &quot;x-dead-letter-exchange&quot;, WORK_EXCHANGE },<br>    { &quot;x-message-ttl&quot;, RETRY_DELAY }<br>};</pre><pre>channel.ExchangeDeclare(RETRY_EXCHANGE, &quot;direct&quot;);<br>channel.QueueDeclare(RETRY_QUEUE, <strong>true</strong>, <strong>false</strong>, <strong>false</strong>, queueArgs);<br>channel.QueueBind(RETRY_QUEUE, RETRY_EXCHANGE, <strong>string</strong>.empty, <strong>null</strong>);</pre><h4>Read from WorkQueue</h4><pre>QueueingBasicConsumer consumer = <strong>new</strong> QueueingBasicConsumer(channel);<br>channel.BasicConsume(WORK_QUEUE, <strong>true</strong>, consumer);</pre><pre><strong>while</strong> (<strong>true</strong>) {<br>    BasicDeliverEventArgs e = (BasicDeliverEventArgs) consumer.Queue.Dequeue();<br>    channel.BasicAck(e.DeliveryTag);</pre><pre>    <strong>var</strong> message = Encoding.UTF8.GetString(e.Body);<br>    <strong>if</strong> (!DoSomething(message)) {<br>        TryAgainLater(message);<br>    }<br>}</pre><h4>Publish to RetryQueue on failure</h4><pre><strong>var</strong> data = Encoding.UTF8.GetBytes(message)<br>channel.BasicPublish(RETRY_EXCHANGE, <strong>string</strong>.empty, <strong>null</strong>, data);</pre><p>The code above will keep retrying indefinitely. It’s a good idea to check against some sort of MAX_RETRY constant. If your messages are JSON strings, it’s easy to encode the retry count in the message itself.</p><h4>Notes</h4><p>There are some things worth mentioning:</p><p>Several different ways to make the message drop into the DLX</p><ul><li>In a RetryQueue consumer, reject the message and set requeue = false</li><li>Set per-queue message TTL when declaring a queue</li><li>Set per-message TTL when publishing a message</li></ul><p>If using per-message TTL, the expired message won’t be sent to the DLX until it reaches the front of the queue. See <a href="http://www.rabbitmq.com/ttl.html">rabbitmq.com/ttl.html</a> for more information</p><p>Credit</p><h4>Yoeun Pen</h4><p><a href="http://yuserinterface.com/dev/2013/01/08/how-to-schedule-delay-messages-with-rabbitmq-using-a-dead-letter-exchange/">http://yuserinterface.com/dev/2013/01/08/how-to-schedule-delay-messages-with-rabbitmq-using-a-dead-letter-exchange/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31fb25a440fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Episode 1: Design pattern series — Singleton]]></title>
            <link>https://medium.com/@kiennguyen88/episode-1-design-pattern-series-singleton-69640db5c47a?source=rss-554cda741a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/69640db5c47a</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Kien Nguyen]]></dc:creator>
            <pubDate>Tue, 18 Aug 2015 07:37:13 GMT</pubDate>
            <atom:updated>2015-08-18T07:37:13.884Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently talked to one of my friend who currently working @Coccoc, a Vietnamese giant in browser and searching technologies about his company coding style and coding quality. One big point I learned from this talk is about coding pattern, so that I dicided to write a series of posts about this topic, to remind me about it and share it to you guys.</p><p>First post will mostly focus on the basic and very simple pattern called Singleton</p><p>Singleton pattern restricts the instantiation of a class and ensures that only one instance of the class exists in the memory of the compilers like JVM. The singleton class must provide a global access point to get the instance of the class. Singleton pattern is used for logging, drivers objects, caching and thread pool</p><p>I’m going to listed here a few style of Singleton that implemented in Java programing language.</p><h4>Eager initialization</h4><p>In eager initialization, the instance of Singleton Class is created at the time of class loading, this is the <strong>easiest</strong> method to create a singleton class but it has a drawback that instance is <strong>created even though client application might not be using it</strong></p><pre>package com.journaldev.singleton; <br>public class EagerInitializedSingleton { <br>    private static final EagerInitializedSingleton instance = new EagerInitializedSingleton();<br>    private EagerInitializedSingleton(){} <br>    public static EagerInitializedSingleton getInstance(){ <br>        return instance; <br>    } <br>}</pre><p>}</p><p>}</p><p>}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69640db5c47a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>