<?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 Ardi Imawan on Medium]]></title>
        <description><![CDATA[Stories by Ardi Imawan on Medium]]></description>
        <link>https://medium.com/@masardee?source=rss-767a9d05cb44------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3W6tsF71HQoAnKDV.jpg</url>
            <title>Stories by Ardi Imawan on Medium</title>
            <link>https://medium.com/@masardee?source=rss-767a9d05cb44------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 10:49:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@masardee/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[Less is More]]></title>
            <link>https://blog.dot.co.id/less-is-more-eb81748db4d3?source=rss-767a9d05cb44------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb81748db4d3</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <dc:creator><![CDATA[Ardi Imawan]]></dc:creator>
            <pubDate>Thu, 17 Sep 2020 10:36:00 GMT</pubDate>
            <atom:updated>2020-09-17T10:36:00.071Z</atom:updated>
            <content:encoded><![CDATA[<p>Pernah kan kita terjebak dalam sebuah <em>project</em> turunan yang <em>legacy-code</em> nya panjangnya minta ampun sampai malas baca? Atau malah itu <em>code</em> milik mu sendiri sampai kamu sendiri bingung g paham maksudnya?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1hUwa21BVpVkxnIaBbYHDQ.png" /></figure><p>Ya, <em>line of codes</em> yang panjang bisa jadi penyebab code kurang <em>readable</em>. Tak hanya susah dibaca, tapi bikin malas untuk membaca, bahkan capek. Padahal kalau dilihat-lihat cuma gitu-gitu doank? bener ga?</p><p>Berikut ada beberapa tips buat <em>make our codes simpler</em> &amp; lebih <em>readable</em>.</p><h3>1. Grouping Code-Block yang Pattern-nya Sama</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*Bi47dkw3iQ-HJoh8aEOSKQ.png" /><figcaption>A. Less Simple Code</figcaption></figure><p>Coba bandingkan antara Code A diatas dengan Code B di bawah. Outputnya akan menghasilkan <em>value</em> yang sama, tapi Code B terlihat lebih simple. Code B merangkum line code 7–15 pada Code A menjadi lebih pendek, karena pattern yang digunakan adalah sama, kita bisa kelompokkan dan manfaatkan <em>variable</em> untuk mengisi part yang dinamis. Silahkan dilihat sekali lagi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*jMN-qqiBgYHaG_Hz3vjkfw.png" /><figcaption>B. Simpler Code</figcaption></figure><h3>2. Manfaatkan Array/Dict Data Structure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*MuxcIhymbOxcX8v26tSCmw.png" /><figcaption>A. Less Simple Code</figcaption></figure><p>Bagaimana kalau variable yang ada tidak bisa langsung digunakan? maka kita bisa mengolahnya lebih dahulu. Disini kita bisa manfaatkan array/dict data structure untuk mapping data dinamis-nya. Silahkan simak Code B di bawah, bandingkan dengan Code A di atasnya. Lebih enak mana?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*CfvARUFD_nlVvyNtVr9Gvg.png" /><figcaption>B. Simpler Code</figcaption></figure><h3>3. Gunakan built-in Fitur dari Bahasa Pemrograman</h3><p>Setiap bahasa pemrograman biasanya memiliki syntax / expresion tertentu yang dapat mempersingkat suatu code.</p><p><strong>3.a Ternary Operator</strong></p><p>Ternary Operator hampir ada di setiap programming language. Fitur ini bisa digunakan untuk membuat <em>inline conditional assignment</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*bHS6T5tAZvEUNww22iXivw.png" /></figure><p><strong>3.b Null Coalescing Operator</strong></p><p>Operator ini juga bisa digunakan untuk <em>inline conditional assignment</em>. Jika value sebelah kiri tidak <em>null</em> atau tidak <em>undefined</em>, maka value kiri yang di <em>assign</em>, jika tidak maka value kanan yang di assign. Perhatikan contoh di bawah:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*Mce2yGkAvoBtKeFttQeWfg.png" /><figcaption>Normal if-else VS Null Coalescing Operator</figcaption></figure><p><strong>3.c Object /Array Destructing Assignment</strong></p><p>Fitur ini ada pada Javascript. Bisa digunakan untuk assign property dari sebuah object atau items sebuah array ke beberapa individual variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*RYVuL_cZUWXGKno-Io37lA.png" /><figcaption>Destructing Assignment on Object</figcaption></figure><p>atau juga bisa digunakan dengan array:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*lV8lF6jy94OKaTazN-7jOQ.png" /><figcaption>Destructing Assignment on Array</figcaption></figure><h3>But, Sometimes Less is Worse</h3><p>Tujuan utama tips-tips di atas adalah agar code kita lebih <em>readable</em>, bukan agar semata-mata tidak panjang <em>line of codes</em> nya. Kalau sampai kita memaksakan cara diatas sampai code kita menjadi kurang readable, mungkin kita butuh ngopi dulu :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*wwlF2qwwY6X9uIJShGqWoQ.png" /><figcaption>Contoh Buruk Penggunaan Ternary Operator</figcaption></figure><blockquote><strong>Bagaimanapun yang berlebihan adalah tidak baik.<br>Jadi, bijak-lah dalam coding!</strong></blockquote><p>Ada lagi tips versimu?<br>Tulis di kolom komentar bawah👇👇👇</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb81748db4d3" width="1" height="1" alt=""><hr><p><a href="https://blog.dot.co.id/less-is-more-eb81748db4d3">Less is More</a> was originally published in <a href="https://blog.dot.co.id/">DOT Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Install Sentry for Laravel-Zero]]></title>
            <link>https://blog.dot.co.id/how-to-install-sentry-for-laravel-zero-f37a39db9460?source=rss-767a9d05cb44------2</link>
            <guid isPermaLink="false">https://medium.com/p/f37a39db9460</guid>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[sentry]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[laravel-zero]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <dc:creator><![CDATA[Ardi Imawan]]></dc:creator>
            <pubDate>Fri, 03 Jul 2020 06:21:33 GMT</pubDate>
            <atom:updated>2020-07-03T10:21:44.847Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>This article is talking about <a href="https://laravel-zero.com/">Laravel-Zero</a>, a microframework for console-application, not Laravel framework itself.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hvcAcWi1dWL63dOpX4uzQw.png" /></figure><p>As we know <a href="https://sentry.io/">Sentry</a> has good support for the Laravel framework. You can read the full documentation <a href="https://docs.sentry.io/platforms/php/laravel/">here</a>. However, we need more efforts to make Sentry works well in Laravel step-brother: Zero (Laravel-Zero).</p><p><em>Note: I have tried this method successfully with this environment :</em></p><pre>composer.json :</pre><pre>&quot;laravel-zero/framework&quot;: &quot;5.8.*&quot;,<br>&quot;sentry/sentry-laravel&quot;: &quot;^1.8&quot;</pre><h4>So let’s make a step!</h4><h3>1. Follow Default Installation Steps</h3><p>Try to follow all of the installation steps written in <a href="https://docs.sentry.io/platforms/php/laravel/">Sentry’s documentation</a>.<br>Make sure you have written your custom Exception Handler.</p><h3>2. Enable Custom Exception Handler on Zero</h3><p>As mentioned in <a href="https://laravel-zero.com/docs/exception-handler/">Zero’s documentation</a> about Exception Handler, there is an additional step to make our custom handler works well.</p><p>Open file bootstrap/app.php, then find and replace related lines to these:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DbmekEvOF_t_LqfDNBHKlA.png" /><figcaption>file bootstrap/app.php</figcaption></figure><h3>3. Manually Register Service Provider</h3><p>We need to register 3rd party service provider manually in config/app.php. Make sure you register Sentry correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bvpf_NorCNL0MYaGe7vR1A.png" /><figcaption>file config/app.php</figcaption></figure><h3>4. Install Zero’s Component Log</h3><p>If you have done the step above correctly, you might get this such error message when you try to run the app :</p><pre>Class log does not exist</pre><p>Sentry needs to utilize Laravel’s Class log, but Zero doesn’t provide it. So we need to install it manually. Make sure you follow this step based on <a href="https://laravel-zero.com/docs/logging/">Zero’s documentation</a>.</p><pre>php &lt;your-app-name&gt; app:install log</pre><h3>5. Register Zero’s Component Log Manually</h3><p><strong>This is the tricky part! </strong>Since Class logstill not defined in Sentry registration process, again we need to register it manually in providers list inside config/app.php , <strong>just before Sentry</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A4MBioPkWAzjWwqVOLh-xg.png" /><figcaption>config/app.php</figcaption></figure><h3>Test it!</h3><pre>php {your-app-name} sentry:test</pre><p>Done!<br>I hope you can smile in this step :)</p><p><strong><em>Helpful? give me some claps 👏 </em></strong><a href="https://emojipedia.org/people/"><strong><em>😃</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f37a39db9460" width="1" height="1" alt=""><hr><p><a href="https://blog.dot.co.id/how-to-install-sentry-for-laravel-zero-f37a39db9460">How to Install Sentry for Laravel-Zero</a> was originally published in <a href="https://blog.dot.co.id/">DOT Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Database Optimization #1 : Indexing]]></title>
            <link>https://blog.dot.co.id/database-optimization-1-indexing-649e7837a22a?source=rss-767a9d05cb44------2</link>
            <guid isPermaLink="false">https://medium.com/p/649e7837a22a</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[index]]></category>
            <category><![CDATA[experiment]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Ardi Imawan]]></dc:creator>
            <pubDate>Wed, 29 Aug 2018 12:32:27 GMT</pubDate>
            <atom:updated>2022-04-05T00:58:03.390Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fYBZa96LJZZeSpIHnADKow.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@qwitka?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Maksym Kaharlytskyi</a> on <a href="https://unsplash.com/s/photos/index?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Semua software developer pasti pernah menggunakan salah satu fitur di database bernama “<em>index</em>”. Belum pernah mencoba?? Hmm,, paling tidak pernah mendengarnya. Belum juga pernah dengar??? Ya paling tidak sekarang sudah dengar dari paragraf pertama artikel ini hehe.</p><blockquote>Artikel ini akan menjelaskan apa itu <em>index dan bagaimana index bekerja </em>secara general, sebagai salah satu teknik dalam mengoptimalkan database. Bahasan ini tidak bergantung pada salah satu brand database, tapi kita akan fokus ke penggunaan salah satu jenis database, yaitu Relational DB Management System (RDBMS) agar lebih mudah dimengerti. Jadi, jika belum tahu konsep RDBMS, silahkan pelajari artikel lain terlebih dahulu.</blockquote><h3>Pendahuluan</h3><h4>Table</h4><p><em>Table</em> di RDBMS berfungsi untuk menyimpan kumpulan data (<em>dataset</em>) dengan jenis &amp; skema yang sama. Seperti gambar di bawah, ini merupakan contoh <em>table</em> dengan nama m_customers untuk menyimpan data diri <em>customer</em> sebuah website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*mEbvCwgDA3BYECabkyhYgg.png" /><figcaption>Table m_customers</figcaption></figure><h4>Query</h4><p>Sedangkan <em>query</em> adalah metode pengambilan data dari satu atau lebih <em>table</em>. Di RDBMS, kita mengenal SQL (<em>Structured Query Language</em>) sebagai “bahasa” yang terstruktur untuk melakukan <em>query</em>.</p><p>Perhatikan <em>SQL statement</em> di bawah ini :</p><pre>Select * From m_customers Where lastname =  &#39;Dare&#39;</pre><p>Apa yang sebenarnya terjadi jika <em>SQL statement</em> di atas dijalankan?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*B5QifH2zJjvSV5Z59Ew-lg.png" /><figcaption>Ilustrasi proses query pada table m_customers</figcaption></figure><p>Secara sederhana, ketika <em>SQL statement</em> di atas dijalankan, maka RDBMS akan melakukan eksplorasi seluruh data di <em>table</em> m_customers , dari data pertama sampai terakhir dan melakukan filter (mencari data dengan lastname = ‘Dare’) di setiap baris. Baris data yang memenuhi persyaratan akan dikumpulkan sebagai hasil.</p><h3>Problem</h3><h4>Problem #1 : Data Size</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*-5RC_zFuoo381MtuRzEaNA.png" /><figcaption>Ilustrasi grafik response time v.s data volume</figcaption></figure><p>Dengan data yang relatif kecil proses <em>query</em> terlihat sangat cepat. Tapi, dengan metode sederhana diatas, apakah proses <em>query</em> akan memerlukan waktu (<em>query time</em>) yang sama jika jumlah baris yang perlu dieksplor menjadi berkali — (ratusan bahkan juataan)-kali lipat ? Tentu tidak. <em>Query time</em> (<em>response time</em>) akan berbanding lurus dengan besar data.</p><blockquote><strong>Semakin besar data, semakin besar query time-nya</strong>.</blockquote><h4>Problem #2 : Data is unsorted</h4><p>Pada dasarnya, data yang disimpan pada database adalah tidak berurutan (<em>unsorted</em>). Ilustrasi di bawah akan menjelaskan bagaimana proses pencarian data menjadi tidak efektif jika data tidak berurutan :</p><blockquote>Terdapat dua (2) dataset yang memiliki ukuran dan data yang sama, yaitu 12 bilangan bulat. Bedanya, <strong><em>dataset-1</em></strong> tidak berurutan sedangkan <strong><em>dataset-2</em></strong> berurutan.</blockquote><p><strong>Dataset-1 : Unsorted</strong></p><pre>2,1,3,4,1,5,1,7,9,8,4,6</pre><p><strong>Dataset-2 : Sorted</strong></p><pre>1,1,1,2,3,4,4,5,6,7,8,9</pre><p>Pada <strong><em>dataset-1</em></strong> kita <strong>membutuhkan 12 langkah</strong> untuk mencari bilangan 5 (lima). Pencarian harus dilakukan dari awal sampai akhir untuk memastikan tidak ada lagi angka 5 yang tersisa (meskipun angka 5 hanya ada satu dan posisinya berada di tengah-tengah <em>dataset</em>).</p><p>Sedangkan pada <strong><em>dataset-2</em></strong>, hanya <strong>dibutuhkan 9 langkah</strong> pencarian. Berawal dari angka 1 dan berhenti di angka 6.</p><blockquote>Kenapa bisa begitu? <strong><em>karena kita tidak perlu melanjutkan pencarian jika sudah tahu kalau angka selanjutnya pasti lebih besar</em></strong>.</blockquote><h4>Problem 3: Disk I/O</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*3Nhy1qVIc3MkONnBfXa0aA.png" /><figcaption>Data MYSQL tersimpan di file fisik pada harddisk komputer.</figcaption></figure><p>Seluruh data pada database tersimpan di harddisk. Gambar berikut menunjukkan bagaimana data pada database MySQL tersimpan.</p><p>Seperti yang kita ketahui, bahwa salah satu <em>cost</em> pada komputasi yang paling besar adalah disk I/O (lihat gambar di bawah). Proses menulis / membaca sebuah file di harddisk membutuhkan waktu &amp; resource yang besar.</p><blockquote><strong><em>Jika proses pencarian data dilakukan dengan membaca file secara langsung, maka bisa dibayangkan berapa lama </em>query<em> </em>time<em> yang dibutuhkan untuk ukura</em>n <em>data yang besar</em></strong>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*V3NMFUFNalNei2nRvPgLZQ.png" /><figcaption>Ilustrasi perbandingan <em>cost</em> komputasi.</figcaption></figure><p>Dari ke tiga masalah di atas, kita bisa menyimpulkan bahwa proses <em>query</em> sederhana di atas akan menjadi sangat tidak efektif jika problem-problem di atas tidak bisa diselesaikan dengan cara yang lebih optimal.</p><h3>Solusi : Index</h3><p>RDBMS sudah memiliki <em>built-in</em> <em>solution</em> untuk problem di atas, yaitu fitur <strong><em>Index</em></strong>.</p><h4>Apa itu Index?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*e2IJOv145veQSRUcXSwqcA.png" /><figcaption>Buku yellowpages</figcaption></figure><p>Masih ingat buku kuning besar “<em>Yellowpages</em>” jika kita berlangganan telpon rumah? Atau pernah buka kamus bahasa? Yap, kita tidak perlu susah-susah menelusuri kata per kata di seluruh buku untuk mencari sebuah konten. Cukup telusuri “tanda” yang disediakan di pojok / samping halaman, kita akan diarahkan ke halaman yang konten-nya dimulai dengan huruf atau kata sesuai “tanda” tersebut. Begitulah penjelasan sederhana bagaimana index bekerja.</p><h4>Database Index</h4><p>Pada database, index merupakan sebuah struktur data yang berisi kumpulan <em>keys</em> beserta referensinya ke <em>actual data</em> di table. Tujuannya untuk mempercepat proses penentuan lokasi data tanpa melakukan pencarian secara penuh ke seluruh data (full scan).</p><h4>Benefit</h4><p>Fitur ini bisa menjawab 3 problem yang disampaikan sebelumnya dengan benefit-benefit berikut :</p><ol><li><strong>Sorted &amp; Less</strong></li></ol><p>Jumlah data pada index jauh lebih kecil daripada data aslinya (tergantung kondisi datanya). Dan data-data ini juga tersimpan secara berurutan dalam bentuk struktur apapun (bisa <em>linear list</em>, <em>tree, </em>dsb). Tentu ini menjawab <em>problem #1</em> &amp; <em>problem #2</em>.</p><p>Dengan index, pencarian dimulai dengan menelusuri data pada index (yang jauh lebih kecil &amp; terurut), kemudian index akan memberikan referensi ke posisi data yang asli. Dari posisi tersebut, pencarian pada <em>dataset</em> asli akan menjadi lebih singkat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*nGP2gkIHfrpuWXlnHPycEg.png" /><figcaption>Ilustrasi index pada database | Source : Wikipedia</figcaption></figure><p><strong>2. (Mostly) Stored in Memory (RAM)</strong></p><p>Dengan ukuran <em>dataset</em> yang jauh lebih kecil, index besar kemungkinan dapat disimpan di RAM, dimana cost untuk baca/tulis pada RAM jauh lebih kecil daripada pada Harddisk. Sehingga tidak bisa dipungkiri proses pencarian <em>keys</em> pada index sangatlah cepat.</p><h3>Eksperimen</h3><p>Pada <em>section</em> ini, saya melakukan eksperimen kecil untuk menunjukkan performa <em>query</em> pada <em>table</em> dengan index dan tanpa index.</p><h4>Dataset</h4><p>Data Size : 2.904.824 records.</p><p>Skema <em>table</em> seperti gambar dibawah ini :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*qh80eoA6vFHUcMI82uoQMg.png" /></figure><h4>Spesifikasi Komputer &amp; Software</h4><ul><li>Macbook Pro Retina Core I-5</li><li>RAM 8G</li><li>SSD 256 GB</li><li>MySQL RDBMS</li></ul><h4>Indexes</h4><p>Saya membuat 3 <em>tables</em> dengan skema &amp; data yang sama, tetapi memiliki index yang berbeda :</p><ul><li>Table student | indexes = id (PK)</li><li>Table student_index_gender | indexes = id (PK), gender</li><li>Table student_indexed | indexes = id (PK), firstname, lastname</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*BRy2Q1RjPD0sutUFGI_Y3A.png" /><figcaption>3 tables dengan index yang berbeda.</figcaption></figure><h4>Index Size</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*TbqV3Po0nsbPQrt5fb8DHw.png" /></figure><p>Gambar di atas menunjukkan besar data asli &amp; index di setiap <em>table</em>. Informasi di atas dapat dihasilkan dengan <em>query</em> berikut :</p><pre>SELECT table_name AS ‘Table’, <br>round(((data_length) / 1024 / 1024), 2) ‘Data Size in MB’ ,<br>round(((index_length) / 1024 / 1024), 2) ‘Index Size in MB’ ,<br>round(((data_length + index_length) / 1024 / 1024), 2) ‘Total Size in MB’<br>FROM information_schema.TABLES<br>WHERE table_schema = “YOUR_TABLE_NAME”;</pre><h4>Eksperimen #1</h4><p>Pada ekseperimen ini saya menjalankan sebuah query sederhana dengan <em>where statement</em> pada kolom gender. Seperti yang terlihat pada gambar di bawah, table student_index_gender yang memiliki index pada kolom gender memiliki <em>query time</em> yang jauh lebih cepat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*2jw0cBXY9Qstz4AMBpWu2w.png" /></figure><h4>Eksperimen #2</h4><p>Pada ekseperimen ini saya menjalankan sebuah query sederhana dengan <em>where statement</em> pada kolom lastname. Seperti yang terlihat pada gambar di bawah, table student_indexed yang memiliki index pada kolom firstname&amp;lastname memiliki <em>query time</em> yang jauh lebih cepat dari <em>table</em> lainnya.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*zsr5DoN7VozaLe9Z2wtFWg.png" /></figure><h3>Kesimpulan</h3><p>Fitur index sangat membantu dalam mengoptimalkan proses <em>query</em>, terutama dengan data yang besar. Satu-satunya <em>additional cost</em> pada penggunaan fitur index adalah bertambahnya ukuran data secara total, karena index memiliki ukuran data tersendiri , meskipun relatif jauh lebih kecil daripada data asli.</p><p>Semoga artikel ini bermanfaat bagi kita dalam memahami bagaimana index pada database bekerja. Silahkan sampaikan pendapatmu di kolom komentar jika ada saran/kritik maupun tambahan informasi. Terimakasih.</p><blockquote>Ohya, kalau kamu tertarik bekerja dengan teknologi semacam ini, silahkan buka website career DOT Indonesia <a href="https://career.dot.co.id/">https://career.dot.co.id</a>. Kami sedang membuka lowongan untuk beberapa posisi software developer. Join with us!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=649e7837a22a" width="1" height="1" alt=""><hr><p><a href="https://blog.dot.co.id/database-optimization-1-indexing-649e7837a22a">Database Optimization #1 : Indexing</a> was originally published in <a href="https://blog.dot.co.id/">DOT Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why am I considering StencilJS after falling in love with VueJS?]]></title>
            <link>https://blog.dot.co.id/why-am-i-considering-stenciljs-after-falling-in-love-with-vuejs-86c8cc473d2f?source=rss-767a9d05cb44------2</link>
            <guid isPermaLink="false">https://medium.com/p/86c8cc473d2f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[stenciljs]]></category>
            <dc:creator><![CDATA[Ardi Imawan]]></dc:creator>
            <pubDate>Tue, 01 May 2018 22:46:15 GMT</pubDate>
            <atom:updated>2018-08-21T03:17:10.684Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r8MHwUslYAX_liKOtzuf-A.jpeg" /><figcaption><em>Photo by </em><a href="https://unsplash.com/photos/EZSm8xRjnX0?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"><em>NordWood Themes</em></a><em> on </em><a href="https://unsplash.com/search/photos/developer?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"><em>Unsplash</em></a></figcaption></figure><p>Recently I worked with vuejs due to some requirements to build SPA (Single Page Application). Beside that, we did some research to build web based form generator as well. Thus, I was looking for a platform/framework which can create a custom web component.</p><h4>Why vuejs?</h4><p>Here are the 3 most important points I’ve considered to decide using vuejs.</p><ol><li>Simple</li><li>Less breaking changes (if you compare with <em>Angularjs</em>)</li><li>Compatible with pure HTML</li></ol><p>The most important reason for me is the 3rd point. For efficiency reason (in term of research &amp; learning), we are looking for a web component technology/platform/framework that can be used in both SPA or traditional website. So I can re use my web component in my traditional HTML template.</p><h4>First Problem in Vuejs</h4><p>Everything worked well until I faced a problem in Vuejs. I realized that you can’t handle an event triggered by your custom vuejs component in vanilla js (outside the Vue instance).</p><pre>&lt;my-vue-button @click=&quot;onClickHandler&quot;&gt;&lt;/my-vue-button&gt;<br><br>&lt;script type=&quot;text/javascript&quot;&gt;<br>    // written in Vanilla JS (outside the Vue instance)<br>    <strong>function </strong>onClickHandler(e) {<br>        // do something<br>    }<br>&lt;/script&gt;</pre><p>The code above will not work. Based on documentation,</p><p><a href="https://vuejs.org/v2/guide/events.html#Method-Event-Handlers">Event Handling - Vue.js</a></p><p>vuejs can call method inside Vue instance only.</p><p>Yap, there is no silver bullet.</p><h4>StencilJS &amp; the interesting feature</h4><p>I don’t really remember how I ended up with <a href="https://stenciljs.com/">StencilJS website</a>.</p><p><a href="https://stenciljs.com/">Stencil</a></p><p>But, from the documentation, I found that it can solve my problem about handling custom event of my custom web component from vanilla JS.</p><p>StencilJS is a tool to build a custom web component that is compatible with vanilla JS. Although it can handle a data binding, please forget about replacing a popular SPA platform (vuejs/angularjs/reactjs) with this one. If you familiar with reactjs, you will familiar with stenciljs code style as well.</p><p><em>p.s: I am still writing &amp; reviewing a post “8 hours with StencilJS”.</em></p><pre><strong>import </strong>{ Component, EventEmitter, Event } <strong>from </strong>&#39;@stencil/core&#39;;<br><br>@Component({<br>    tag: &#39;test-component&#39;,<br>})<br><strong>export class </strong>TestComponent {<br><br>    @Event() onCustomClicked: EventEmitter;<br><br>    handleOnClick(e){<br>        <strong>this</strong>.onCustomClicked.emit(e);<br>    }<br><br>    render() {<br>        <strong>return </strong>(<br>            &lt;p onClick={<strong>this</strong>.handleOnClick.bind(<strong>this</strong>, <strong>this</strong>)}&gt;Click Me!&lt;/p&gt;<br>        );<br>    }<br>}</pre><p>This code is my TestComponent source code, a web component defined in StencilJS . You can see that it will dispatch my custom event onCustomClicked when the component is clicked.</p><pre>...</pre><pre>&lt;script src=&quot;./build/app.js&quot;&gt;&lt;/script&gt;</pre><pre>...</pre><pre>&lt;test-component&gt;&lt;/test-component&gt;</pre><pre>...</pre><pre>&lt;script type=&quot;text/javascript&quot;&gt;</pre><pre>    <strong>const </strong>elem = document.querySelector(&quot;test-component&quot;);<br>    elem.addEventListener(&#39;onCustomClicked&#39;, <strong>function </strong>(e) {<br>        // do something...<br>    }, <strong>false</strong>);<br><br>&lt;/script&gt;</pre><pre>...</pre><p>In other file, I call my web component in a pure html file. As you can see in the javascript section above, the code listens an event called onCustomClicked for a&lt;test-component&gt; element.</p><p>The result is, when you click &lt;test-component&gt; element in browser, onCustomClick event will be dispatched from StencilJS component and handled in html file above (// do something... section).</p><p>Again, no silver bullet! From this experiment, I decide to use stencil JS if I need to build a custom web component for vanilla JS. Further more, I need more experiment to know if stencil JS is compatible to be implemented in popular SPA platform (vuejs/angularjs/reactjs).</p><h4>Conclusion</h4><p>I did a little experiment in both of vuejs &amp; stenciljs about how to handle custom event from a custom web component in a vanilla js. From the result and the documentation, vanilla js can’t recognize a custom event declared inside Vue instance. Otherwise, stencil js can perform that. For some reason I mentioned above, I preferred stencil js to just create a custom web component to be implemented in both SPA or traditional web application (pure HTML &amp; vanilla js).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86c8cc473d2f" width="1" height="1" alt=""><hr><p><a href="https://blog.dot.co.id/why-am-i-considering-stenciljs-after-falling-in-love-with-vuejs-86c8cc473d2f">Why am I considering StencilJS after falling in love with VueJS?</a> was originally published in <a href="https://blog.dot.co.id/">DOT Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Functional Programming Paradigm]]></title>
            <link>https://blog.dot.co.id/functional-programming-paradigm-73b8607744c2?source=rss-767a9d05cb44------2</link>
            <guid isPermaLink="false">https://medium.com/p/73b8607744c2</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[programming-paradigms]]></category>
            <dc:creator><![CDATA[Ardi Imawan]]></dc:creator>
            <pubDate>Wed, 28 Dec 2016 07:21:05 GMT</pubDate>
            <atom:updated>2016-12-28T07:21:05.370Z</atom:updated>
            <content:encoded><![CDATA[<p>In recent years, <em>functional programming</em> (later we call it <strong>FP</strong>) was a common term that has been discussed in many places, you can see in many articles spread on the internet. So, let’s jump to the next section. I don’t want to know there’s still some programmers that don’t have any idea about FP in 2016 :)</p><h3>What is Functional Programming</h3><p>Functional Programming is a programming paradigm, you can say it as programming concept/style. Just for illustration, you can compare it with OOP (Object Oriented Programming) or Structured Programming concept, not with Java or C++ or any programming language (<em>we don’t talk about FP language yet</em>).</p><p>Although there are some people said about novelty of the FP, I rather agree with Wikipedia’s article. It’s said that FP treats computation as the <strong>evaluation of mathematical function</strong> which avoid changing state and mutable data. There is no new technique nor a new dependency library. It’s just turn back programming style into a basic one, readable and concentrates on computing result rather than on performing action.</p><p><strong># Code Snippet A</strong> : ( <em>FUNCTIONAL PROGRAMMING</em> )</p><pre>function Array multiplyScores(Array oldScores, int multiplier){<br>    Array newScores = [];<br>    foreach(oldScores as score){<br>        newScores.push( score * multiplier );<br>    }<br>    return newScores;<br>}</pre><p><strong># Code Snippet B</strong> :<strong> </strong>( <em>NOT FUNCTIONAL PROGRAMMING </em>)</p><pre>function void multiplyScores(int multiplier){<br>    Array scores = GlobalVars.getScores();<br>    foreach(scores as score){<br>        score.val = score.val*multipler; <br>    }<br>    GlobalVars.storeScores(scores);<br>}</pre><h4>No Mutable Data</h4><p>This means that you should not modify the data input directly in your function. As seen on <strong>code A</strong>, the output is a new variable which contains new data produced by multiplying each data on old variable. It doesn’t modify old variable at all. If the data was an object, just clone it, then you could modify it.</p><h4>No Side Effects</h4><p>Everything should be declared well, no hidden input / output. How many input does function in code A has ? Yes, there are 2 inputs : <em>oldScores</em> and <em>multiplier</em>. And according to the syntax, function in code B has 1 input and no output. But the fact is it has 2 inputs and 1 output. The first one is declared in the function and another one is a hidden input. Yes <em>scores</em> is a hidden input, it’s depends on something. And obviously, it did something as hidden output, no direct return value. Now we can call these hidden inputs/outputs as “<em>side effects</em>”. <em>Side effect</em> is about hidden relationship with the outside world.</p><h4><strong>Is it bad?</strong></h4><p>While it works as programmer expected, <em>side effect</em> is not a matter. But there is no guarantee what <em>side effect</em> will do. Thus it’s better to write a code that can easily be expected, it’s much more readable.</p><h3>Pros &amp; Cons</h3><h4>Pros</h4><ul><li><strong>No side effect</strong>, your code will be more readable, obviously.</li><li><strong>Simple</strong>, it’s about relationship between inputs and outputs.</li><li><strong>Easy to test</strong>, whatever how many times you test it with the same inputs, it will return the same output.</li></ul><h4>Cons</h4><ul><li><strong>Effective-less.</strong> As we use immutable input variable, it will consumes more memory for making the output. It will be matter if your input size is big enough.</li><li><strong>Looks more complex</strong>. <em>Hmmm…., actually no</em>. If you put everything in your function and cause a side effect, it will make your code less readable. <em>Does it make more complicated huh…?</em></li></ul><h3>Functional Programming Languages</h3><p>As a programming paradigm, it’s actually can be implemented on any programming languages. I wrote the codes above with <em>you-can-say-anything</em> programming language (just to make easy to read and compare). In fact, you can categorize the functional programming languages in two categories : <strong>Pure</strong> and <strong>Impure</strong>. It’s been explained well in <a href="https://en.wikipedia.org/wiki/List_of_programming_languages_by_type#Functional_languages">here</a> (Wikipedia article)</p><h3>Conclusion</h3><p>As should we remember, nowadays programming is not only a job activity nor hobby. Programming is a life style also, which in a life style there is always a trend. And FP is one of trends on programming life style which has certain purpose, it also has pros and cons. For me, FP is not more than a preference, you can use as you need or as you want.</p><h3>References</h3><ul><li><a href="https://en.wikipedia.org/wiki/Functional_programming">https://en.wikipedia.org/wiki/Functional_programming</a></li><li><a href="http://cryto.net/~joepie91/blog/2015/05/04/functional-programming-in-javascript-map-filter-reduce/">http://cryto.net/~joepie91/blog/2015/05/04/functional-programming-in-javascript-map-filter-reduce/</a></li><li><a href="http://blog.jenkster.com/2015/12/what-is-functional-programming.html">http://blog.jenkster.com/2015/12/what-is-functional-programming.html</a></li><li><a href="https://en.wikipedia.org/wiki/Declarative_programming">https://en.wikipedia.org/wiki/Declarative_programming</a></li><li><a href="https://www.quora.com/Why-is-there-so-much-hype-about-functional-programming">https://www.quora.com/Why-is-there-so-much-hype-about-functional-programming</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73b8607744c2" width="1" height="1" alt=""><hr><p><a href="https://blog.dot.co.id/functional-programming-paradigm-73b8607744c2">Functional Programming Paradigm</a> was originally published in <a href="https://blog.dot.co.id/">DOT Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CSS Ellipsis, did you know?]]></title>
            <link>https://medium.com/@masardee/css-ellipsis-did-you-know-4d9cfacfa7dd?source=rss-767a9d05cb44------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d9cfacfa7dd</guid>
            <category><![CDATA[css3]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[tricks]]></category>
            <category><![CDATA[ellipsis]]></category>
            <dc:creator><![CDATA[Ardi Imawan]]></dc:creator>
            <pubDate>Sat, 05 Nov 2016 11:48:22 GMT</pubDate>
            <atom:updated>2016-11-05T13:14:08.087Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*numhq1IWq2ffodIdUEuKqw.png" /></figure><p><em>Test… test… Uhuk.. Everybody calm down please, this is my first post :)</em></p><p>Well, ini adalah benar-benar tulisan pertama saya di Medium, setelah beberapa lama menjadi silent reader. Saya harap semua berjalan dengan baik :D</p><p>Materi yang saya pilih disini adalah tentang fitur CSS bernama “Ellipsis”. Bukan tanpa alasan, karena memang setelah sekian lama menjadi web developer (backend/frontend), saya baru tau ada css property / fitur seperti ini yang sebenarnya sering saya butuhkan dari dahulu. (<em>Come on Ardi,,, kemana saja kamu?</em>)</p><h3>What is Ellipsis?</h3><p>Secara bahasa, <em>ellipsis</em> berarti tanda pengganti (terjemahan google translate). Pada konteks kali ini, <em>ellipsis</em> adalah sebuah tanda pengganti akhir dari sebuah <em>limited short description</em>. Sering kita temukan pada halaman <em>article list </em>ada penjelasan singkat suatu konten yang diakhiri oleh tanda “…” pada akhir kalimatnya. Ya, itu yang disebut <em>ellipsis. </em>Sudah paham ya?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*30ze8zBwcgJCwXufoVTxkQ.png" /><figcaption>Ellipsis on Medium post list</figcaption></figure><h4><strong>Old School Solution</strong></h4><p>Saya yakin ada banyak orang yang masih menggunakan PHP untuk memotong sebuah <em>short description</em> , entah berdasarkan jumlah <em>characters</em> ataupun jumlah <em>words </em>nya. Apakah itu efektif? Sebenarnya tidak. Kenapa? karena ukuran tiap <em>character</em> / <em>word</em> bisa berbeda-beda. Sehingga, bisa jadi kalimat yang kita potong tidak benar-benar memenuhi sebuah <em>container, </em>bisa kurang dan bisa jadi lebih. Dan alasan kedua, di zaman <em>responsive-html</em> saat ini, ukuran container seharusnya menyesuaikan dengan ukuran device-nya. Sehingga susah untuk memprediksi berapa batasan <em>characters</em> / <em>words </em>yang harus ditentukan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6JLT4bgChEwYSVj2aCK6_A.png" /></figure><h3>Pure CSS Solution</h3><p>Sebenarnya, dengan <em>pure CSS</em> kita sudah bisa mengantisipasi masalah ini dengan efektif. Ada beberapa teknis <em>ellipsis</em> yang bisa digunakan. Kamu bisa lihat contohnya disini : <a href="http://codepen.io/masardee/pen/gLbYWq">http://codepen.io/masardee/pen/gLbYWq</a></p><h4>Text-overflow property</h4><p>Teknik ini bisa digunakan di semua modern browser, tapi hanya mampu memotong satu baris kalimat.</p><pre>.ellipsis-single-line{<br>  white-space: nowrap;<br>  overflow: hidden;<br>  text-overflow: ellipsis;<br>}</pre><h4>-Webkit-line-clamp property</h4><p>Seperti judulnya, teknik ini hanya bisa digunakan pada browser yang mendukung <em>webkit</em> <em>property</em>. Kelebihannya adalah, teknik ini bisa digunakan untuk memotong beberapa baris kalimat. Kita hanya tinggal mendefinisikan berapa jumlah baris yang dibutuhkan ke dalam <em>-webkit-line-clamp property</em>. Pada contoh code dibawah, short description akan dibatasi dalam 2 baris kalimat. Jika kalimat tersebut sebenarnya muncul dalam lebih dari 2 baris, maka pada baris kedua di akhir kalimat akan dipotong dengan <em>ellipsis</em> <em>characters</em> “…” . Jika kurang dari 2 baris, maka <em>ellipsis</em> tidak akan muncul.</p><pre>.ellipsis-two-lines{<br>  display: -webkit-box;<br>  white-space: normal;<br><strong>  -webkit-line-clamp: 2;</strong><br>  -webkit-box-orient: vertical;<br>  overflow: hidden;<br>}</pre><h4>Opera -o-ellipsis-lastline property</h4><p>CSS property ini hanya didukung oleh browser Opera. Terus terang, saya belum pernah mencobanya. Tapi fitur ini berfungsi sama seperti <em>-webkit-line-clamp property</em>.</p><h3>There is No One-Size-Fits-All Solution</h3><p>Pada saat ini, hanya text-overflow property yang bisa dimanfaatkan untuk teknik ini, meskipun hanya mampu membatasi kalimat dalam 1 baris. Jika kamu tidak mempermasalahkan fitur ini tidak berjalan pada Firefox &amp; IE, kamu bisa menggunakan <em>-webkit-line-clamp property &amp; -o-ellipsis-lastline property </em>untuk membatasi kalimat dalam beberapa baris<em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d9cfacfa7dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>