<?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 Hans Sagita Soegiarto on Medium]]></title>
        <description><![CDATA[Stories by Hans Sagita Soegiarto on Medium]]></description>
        <link>https://medium.com/@hanssagita?source=rss-9a96264a7232------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*VI9v0q-qizcPs2MtFUbghw.jpeg</url>
            <title>Stories by Hans Sagita Soegiarto on Medium</title>
            <link>https://medium.com/@hanssagita?source=rss-9a96264a7232------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 17:06:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hanssagita/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[Rapid Front-end Development at Blibli.com]]></title>
            <link>https://medium.com/bliblidotcom-techblog/rapid-front-end-development-at-blibli-com-e0f62fcd21aa?source=rss-9a96264a7232------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0f62fcd21aa</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-development]]></category>
            <dc:creator><![CDATA[Hans Sagita Soegiarto]]></dc:creator>
            <pubDate>Mon, 10 May 2021 02:03:15 GMT</pubDate>
            <atom:updated>2021-05-10T02:03:15.589Z</atom:updated>
            <content:encoded><![CDATA[<h4>How Blibli.com front-end team boost development speed with API mock using axios mock adapter</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*hYXV6-ppNPZ7tztcORt8yw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@i_am_g">Guillaume Jaillet</a> on <a href="https://unsplash.com/photos/Nl-GCtizDHg">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>In this modern startup boom era, every business requirement needs to be delivered fast and reliable. Most of the time every requirement needs to have changes in both the back-end and front-end side. So our big problem here is how to make back-end development and front-end development work together and have seamless integration when we deploy it in the lower and production environment.</p><p>One of the best solutions out there is by using the API mock feature. API mock helps the front-end team to do the development even when the backend is not ready yet, and it’s very simple to customize to fit our test case and all the flow business requirement because we can easily create or update our mock data as we want.</p><h3>Hands on configure and using API mock</h3><h4>Installing Axios and Axios Mock Adapter</h4><p>First, we need to install <a href="https://github.com/axios/axios">axios</a> and <a href="https://www.npmjs.com/package/axios-mock-adapter">axios-mock-adapter</a> library. For the axios we both need in development and production mode, so have to install it as depedencies. For axios-mock-adapter we need only in development mode, so we have to install it as dev depedencies.</p><pre>npm install --save axios<br>npm install --save-dev axios-mock-adapter</pre><h4>Creating Axios utility</h4><p>After installing axios as dependencies, to make it easier and readable, we need to create a helper or a utility. We combine the future promise approach with a callback approach to make it simpler and easier to use in our components.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e169f97a9f96b52ef0c7b76ded89754/href">https://medium.com/media/1e169f97a9f96b52ef0c7b76ded89754/href</a></iframe><h4>API mock foldering guidance</h4><p>After preparing our axios utility, now let’s deep dive into the api-mock implementation. First, here is an example template foldering in Blibli. Inside our src folder we create the api-mock folder. In the api-mock folder there is a index.js file that has configuration for creating our data mock implementation and for the modules folder contains all the modules api that we want to create. Usually we create several modules based on the backend microservice, for example, search.js, product.js, member.js or etc.</p><pre>// Blibli.com API mock foldering guidance</pre><pre>📂 src<br>  📂 api-mock<br>    📂 modules<br>      └ search.js  // API mock for search microservice<br>      └ product.js // API mock for product microservice<br>      └ member.js  // API mock for member microservice<br>    index.js</pre><p>For the following example to make it easier to explain and understand our API mock foldering and file will be like this below</p><pre>// This example API mock foldering structure</pre><pre>📂 src<br>  📂 api-mock<br>    📂 modules<br>      └ routes.js<br>    index.js</pre><h4>API mock modules</h4><p>Here’s are example of routes.jsthis file contains array of object, each object has API spec configuration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/58e86ecc767767770fc6603bc79fb858/href">https://medium.com/media/58e86ecc767767770fc6603bc79fb858/href</a></iframe><h4>API mock initialise and configuration</h4><p>Here’s are example of index.jsthis file is the core of axios mock adapter setup file. This file contains configuration for creating each mock and concat all the modules that we have define earlier.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/193696b4576b25d1ff3d365451bb41e6/href">https://medium.com/media/193696b4576b25d1ff3d365451bb41e6/href</a></iframe><h4>Importing API mock configuration file in our app</h4><p>After creating API mock modules and setup configuration file. We need to import the configuration file in our index JavaScript file. Usually it will look like this. We need to make sure that we are not creating API mock in production mode.</p><pre><em>// Make sure the API mock only imported in non production mode</em></pre><pre><em>if</em>(process.env.NODE_ENV !== &#39;production&#39;) {<br>  require(&#39;./api-mock&#39;)<br>}</pre><p>In VueJs we need to put it in the main.js file, and place it before creating a new Vue App.</p><pre><em>if</em>(process.env.NODE_ENV !== &#39;production&#39;) {<br>  require(&#39;./api-mock&#39;)<br>}</pre><pre><em>new </em>Vue({<br>  render: h =&gt; h(App)<br>}).$mount(&#39;#app&#39;)</pre><p>In ReactJs we need to put it in the index.js file, and place it before creating a React DOM.</p><pre><em>if </em>(process.env.NODE_ENV !== &#39;production&#39;) {<br>  <em>require</em>(&#39;./api-mock/&#39;)<br>}</pre><pre><em>const </em>root = &lt;App /&gt;<br><em>const </em>rootElement = document.getElementById(&#39;root&#39;)<br>ReactDOM.render(root, rootElement)</pre><h4>Accessing API mock from our app or component</h4><p>After configuring and import it in our index.js file, our axios mock adapter should be ready to use. Here’s are some example to accessing using different setup like using query params, using request body or using it both.</p><p><strong>Example accessing API mock with Get method</strong></p><p>routes.js configuration</p><pre>{<br>  url: &#39;/api/test-without-query-params&#39;,<br>  method: &#39;GET&#39;,<br>  code: 200,<br>  response: {<br>    data: &#39;Mock comes from Get Method without query params&#39;<br>  }<br>}</pre><p>Component example</p><pre><em>import </em>httpApi <em>from </em>&#39;./utils/http-api&#39;<br><br>httpApi.get(&#39;/api/test-without-query-params&#39;,response =&gt; {<br>  <em>console</em>.log(&#39;success: &#39;, response)<br>}, response =&gt; {<br>  <em>console</em>.log(&#39;Fail: &#39;, response)<br>})</pre><p>Response result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*tyQ0k1bkFqEKriY2pHqO_w.png" /><figcaption>Get Method Response</figcaption></figure><p><strong>Example accessing API mock with Get method and query param</strong></p><p>routes.js configuration</p><pre>{<br>  url: &#39;/api/test-with-query-params&#39;,<br>  method: &#39;GET&#39;,<br>  code: 200,<br>  queryParams: {<br>    searchTerm: &#39;samsung&#39;<br>  },<br>  response: {<br>    data: &#39;Mock comes from Get Method with query params&#39;<br>  }<br>},</pre><p>Component example</p><pre><em>import </em>httpApi <em>from </em>&#39;./utils/http-api&#39;</pre><pre>httpApi.get(&#39;/api/test-with-query-params?searchTerm=samsung&#39;,response =&gt; {<br>  <em>console</em>.log(&#39;success: &#39;, response)<br>}, response =&gt; {<br>  <em>console</em>.log(&#39;Fail: &#39;, response)<br>})</pre><p>Response result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*nxsiXX10UvU8WX6U-LNV_w.png" /><figcaption>Get Method with query params Response</figcaption></figure><p><strong>Example accessing API mock with Get method but returning fail response</strong></p><p>routes.js configuration</p><pre>{<br>  url: &#39;/api/test-fail&#39;,<br>  method: &#39;GET&#39;,<br>  code: 400,<br>  queryParams: {},<br>  response: {<br>    data: &#39;Mock comes from Get Method with fail handler&#39;<br>  }<br>},</pre><p>Component example</p><pre><em>import </em>httpApi <em>from </em>&#39;./utils/http-api&#39;</pre><pre>httpApi.get(&#39;/api/test-fail&#39;,response =&gt; {<br>  <em>console</em>.log(&#39;success: &#39;, response)<br>}, response =&gt; {<br>  <em>console</em>.log(&#39;Fail: &#39;, response)<br>})</pre><p>Response Result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*2UGFNYqAwsNhZt9d2knE6A.png" /><figcaption>Get Method fail Response</figcaption></figure><p><strong>Example accessing API mock with Post method with request param (request body)</strong></p><p>routes.js configuration</p><pre>{<br>  url: &#39;/api/test-with-request-params&#39;,<br>  method: &#39;POST&#39;,<br>  code: 200,<br>  params: {<br>    username: &#39;username&#39;,<br>    password: &#39;123&#39;<br>  },<br>  response: {<br>    data: &#39;Mock comes from Post Method with request params&#39;<br>  }<br>},</pre><p>Component example</p><pre><em>const </em>requestParam = {<br>  username: &#39;username&#39;,<br>  password: &#39;123&#39;<br>}<br>httpApi.post(&#39;/api/test-with-request-params&#39;,response =&gt; {<br>  <em>console</em>.log(&#39;success: &#39;, response)<br>}, response =&gt; {<br>  <em>console</em>.log(&#39;Fail: &#39;, response)<br>}, requestParam)</pre><p>Response Result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*DQngjIFYbBQiStVin9uoHg.png" /><figcaption>Post Method with request params Response</figcaption></figure><p><strong>Example accessing API mock with Post method with request param (request body) and query params</strong></p><p>routes.js configuration</p><pre>{<br>  url: &#39;/api/test-with-request-params-and-query-params&#39;,<br>  method: &#39;POST&#39;,<br>  code: 200,<br>  queryParams: {<br>    searchTerm: &#39;samsung&#39;<br>  },<br>  params: {<br>    username: &#39;username&#39;,<br>    password: &#39;123&#39;<br>  },<br>  response: {<br>    data: &#39;Mock comes from Post Method with request params and query params&#39;<br>  }<br>}</pre><p>Component example</p><pre>httpApi.post(&#39;/api/test-with-request-params-and-query-params?searchTerm=samsung&#39;,response =&gt; {<br>  <em>console</em>.log(&#39;success: &#39;, response)<br>}, response =&gt; {<br>  console.log(&#39;Fail: &#39;, response)<br>}, requestParam)</pre><p>Response Result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*qw-u8fBxBaRnKEIgHghj0w.png" /><figcaption>Post Method with request params and query params Response</figcaption></figure><p><strong>Example accessing API mock with Put method with request param (request body)</strong></p><p>routes.js configuration</p><pre>{<br>  url: &#39;/api/test-with-request-params&#39;,<br>  method: &#39;PUT&#39;,<br>  code: 200,<br>  params: {<br>    name: &#39;name edit&#39;,<br>    address: &#39;address edit&#39;<br>  },<br>  response: {<br>    data: &#39;Mock comes from PUT Method with request params&#39;<br>  }<br>}</pre><p>Component example</p><pre><em>const </em>requestParamPut = {<br>  name: &#39;name edit&#39;,<br>  address: &#39;address edit&#39;<br>}<br><br>httpApi.put(&#39;/api/test-with-request-params&#39;,response =&gt; {<br>  <em>console</em>.log(&#39;success: &#39;, response)<br>}, response =&gt; {<br>  <em>console</em>.log(&#39;Fail: &#39;, response)<br>}, requestParamPut)</pre><p>Response Result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*hSC3NWRki6HhHCIJa3a7IQ.png" /><figcaption>Put Method with request params Response</figcaption></figure><p><strong>Example accessing API mock with Delete method</strong></p><p>routes.js configuration</p><pre>{<br>  url: &#39;/api/test-delete&#39;,<br>  method: &#39;DELETE&#39;,<br>  code: 200,<br>  response: {<br>    data: &#39;Mock comes from DELETE Method&#39;<br>  }<br>}</pre><p>Component example</p><pre>httpApi.del(&#39;/api/test-delete&#39;,response =&gt; {<br>  <em>console</em>.log(&#39;success: &#39;, response)<br>}, response =&gt; {<br>  console.log(&#39;Fail: &#39;, response)<br>})</pre><p>Response Result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*7EMvzO9MBIbhLs_zUh0tFQ.png" /><figcaption>Delete Method Response</figcaption></figure><h4><strong>Reference</strong></h4><p>You can see my full example code here — <a href="https://github.com/hanssagita/api-mocking-example">https://github.com/hanssagita/api-mocking-example</a></p><p>Axios — <a href="https://www.npmjs.com/package/axios">https://www.npmjs.com/package/axios</a></p><p>Axios mock adapter — <a href="https://www.npmjs.com/package/axios-mock-adapter">https://www.npmjs.com/package/axios-mock-adapter</a></p><p>Callback function — <a href="https://developer.mozilla.org/en-US/docs/Glossary/Callback_function">https://developer.mozilla.org/en-US/docs/Glossary/Callback_function</a></p><h3>Conclusion</h3><p>Axios and Axios mock adapter are a powerful, easy and reliable tool to rapid our front-end development. This library and structure in the example above are used in Blibli for every UI repository. With them we can develop our front-end application even when the backend is not available.</p><p>That’s it and if you found this article helpful, let us know in the comments. You can also follow me on <a href="https://medium.com/@hanssagita">Medium</a> and <a href="https://www.linkedin.com/in/hans-sagita/">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0f62fcd21aa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bliblidotcom-techblog/rapid-front-end-development-at-blibli-com-e0f62fcd21aa">Rapid Front-end Development at Blibli.com</a> was originally published in <a href="https://medium.com/bliblidotcom-techblog">Blibli.com Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Multi-language Vue Applications with Vue I18n]]></title>
            <link>https://javascript.plainenglish.io/create-multi-language-vue-applications-with-vue-i18n-60a0e3595193?source=rss-9a96264a7232------2</link>
            <guid isPermaLink="false">https://medium.com/p/60a0e3595193</guid>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Hans Sagita Soegiarto]]></dc:creator>
            <pubDate>Fri, 09 Apr 2021 19:17:11 GMT</pubDate>
            <atom:updated>2021-04-09T19:17:11.236Z</atom:updated>
            <content:encoded><![CDATA[<h4>Step by step example installing and using Vue I18n in your Vue applications.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lCHglqaWN_JoLJaRdPYirQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@kylejglenn">Kyle Glenn</a> on <a href="https://unsplash.com/photos/nXt5HtLmlgE">Unsplash</a></figcaption></figure><h4>Introduction</h4><p>This article will explore the best practice of creating multi-language for your <a href="https://vuejs.org/">Vue App</a>. This article is based on and inspired by <a href="https://kazupon.github.io/vue-i18n/">Vue-I18n official docs</a>, my work experience, and the Internet documentations.</p><p>For the rest of the article, let us assume that we are building a simple Vue app with Vue-I18n library that will display Vue core feature like in official docs with available language in English, Bahasa Indonesia, Chinese and Japanese.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RLVOICaXIw6UKIcR6TB0Pw.gif" /><figcaption><a href="https://github.com/hanssagita/vue-i18n-example">My Github demo example</a></figcaption></figure><h4>Deep Dive how to Initialize Vue-I18n</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*kChMgut6cHowUvyHlcGmRw.png" /><figcaption>Vue I18n step by step initialization</figcaption></figure><p>First of all, you need to install the Vue-I18n library.</p><p>For Npm User</p><pre>npm install vue-i18n</pre><p>For Yarn User</p><pre>yarn add vue-i18n</pre><p>After success installing the library to your Vue app, I recommend creating a new folder inside your src with this template to make it simple and clean. You can choose either above or bottom recommendation. For this demo I personally use the first folder template.</p><pre>📂 localization<br>  └ id.js<br>  └ en.js<br>  └ cn.js<br>  └ jp.js<br>  └ <em>index</em>.js</pre><pre>OR</pre><pre>📂 localization<br>  └📁 lang<br>    └ id.js<br>    └ en.js<br>    └ cn.js<br>    └ jp.js<br>  └ <em>index</em>.js</pre><p>Here’s an example of one of the languages file, it’s en.js file. All we need is only the return of an object. I recommended the key name is the <strong>section location</strong> or the <strong>section context</strong>. Value of the field is the language that you want to show in your UI.</p><pre><em>export default </em>{<br>  welcomeMessage: &#39;The Progressive JavaScript Framework&#39;,<br>  highlights: {<br>    approachable: &#39;Approachable&#39;<br>  }<br>}</pre><p>After creating all the other languages, we need to bundle that all in one file, which is in our index.js file.</p><pre>import VueI18n from &#39;vue-i18n&#39;<br><br>Vue.use(VueI18n)</pre><pre>// import all the language we have been define<br>import ID from &#39;./id&#39;<br>import EN from &#39;./en&#39;<br>import JP from &#39;./jp&#39;<br>import CN from &#39;./cn&#39;<br><br>export default new VueI18n({<br>  locale: &#39;EN&#39;, <em>// set default </em>language<em><br>  </em>messages:{<br>    ID,<br>    EN,<br>    JP,<br>    CN<br>  } <em>// feed all the messages with the tall </em>language<em><br></em>})</pre><p>Some extra tips, we can also save and read the user’s preferences earlier with the help from localStorage. Here’s an example, how to read the default language from localStorage and set it as the default language.</p><pre>const DEFAULT_LANGUAGE_LOCAL_STORAGE_KEY =<br>&#39;defaultLanguageVuei18nExample&#39;<br>const defaultLang = localStorage(DEFAULT_LANGUAGE_LOCAL_STORAGE_KEY)</pre><pre>export default new VueI18n({<br>  locale: defaultLang,<em><br>  ......<br></em>})</pre><p>After bundle it all into 1 file, lastly we need to add it in main.js and place it when we create a new Vue.</p><pre>import Vue from &#39;vue&#39;<br>import App from &#39;./App.vue&#39;<br>import i18n from &#39;@/localization&#39;</pre><pre>new Vue({<br>  render: h =&gt; h(App),<br>  i18n<br>}).$mount(&#39;#app&#39;)</pre><h4>Deep dive displaying the language in Vue</h4><p>From the template we only need to need to wrap it in double curly braces as if we were accessing a JavaScript variable or methods. We add $t and write the the object key.</p><pre>&lt;template&gt;<br>  &lt;div&gt;<br>    {{ $t(&#39;welcomeMessage&#39;) }}<br>    {{ $t(&#39;highlights.approachable&#39;) }}<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>From JavaScript it’s a bit similar like in the template, but we need to add this when accessing the <strong>$t</strong>.</p><pre>computed: {<br>  welcomeMessage () {<br>    <em>return this</em>.$t(&#39;welcomeMessage&#39;)<br>  },<br>  firstCoreFeature () {<br>    <em>return this</em>.$t(&#39;highlights.approachable&#39;)<br>  }<br>}</pre><h4>Deep Dive Changing the language</h4><pre><em>// </em>override<em> the $i18n.locale value</em></pre><pre><em>this</em>.$i18n.locale = selectedLanguage</pre><p>For this example, I combine the v-model in select option with the Vue watch. It will watch the v-model value, so when the user changes the selectedLangunage, it will automatically trigger some code that changes the value of $i18n.locale. You can combine it also with <a href="http://twitter.com/click">@click</a> and methods.</p><pre>data () {<br>  <em>return </em>{<br>    selectedLanguage: &#39;EN&#39;<br>  }<br>},<br>watch: {<br>  selectedLanguage (payload) {<br>    <em>this</em>.$i18n.locale = payload<br>  }<br>}</pre><p>If you want to use it with methods.</p><pre>methods: {<br>  changeLanguage (payload) {<br>    <em>this</em>.$i18n.local = payload<br>  }<br>}</pre><p>As I mentioned earlier, we can save the user preference for their language, here are some tips to save it to the localStorage.</p><pre>const DEFAULT_LANGUAGE_LOCAL_STORAGE_KEY =<br>&#39;defaultLanguageVuei18nExample&#39;</pre><pre>methods: {<br>  changeLanguage (payload) {<br>    <em>this</em>.$i18n.local = payload<br>    localStorage.setItem(<br>DEFAULT_LANGUAGE_LOCAL_STORAGE_KEY, payload)<br>  }<br>}</pre><h4><strong>Bonus Tips: accessing the language with some variable</strong></h4><p>There’s an interesting feature that Vue I18n provides us is you can also add a variable in your language text. Here’s an example of using a variable in your language and accessing it.</p><pre><em>export default </em>{<br>  welcomeMessage: &#39;Hello, Mr. {name}&#39;,<br>}</pre><p>Accessing from Vue Template</p><pre>&lt;template&gt;<br>  &lt;div&gt;<br>    {{ $t(&#39;welcomeMessage&#39;, { name: &#39;hans&#39; }) }}<br>  &lt;/div&gt;<br>&lt;/template&gt;</pre><p>Accessing from JavaScript</p><pre>computed: {<br>  welcomeMessage () {<br>    <em>return this</em>.$t(&#39;welcomeMessage&#39;, { name: &#39;hans&#39; })<br>  },<br>}</pre><p>You can also explore more my code example in <a href="https://github.com/hanssagita/vue-i18n-example">Github Repo</a>.</p><h3>Conclusion</h3><p>There’s a lot more that you can explore from the original website. Here’s only the best practice and simple tips to start your journey implementing creating Multi-language Vue Applications.</p><p>That’s it, and if you found this article helpful, let us know in the comments. You can also follow me on Medium and LinkedIn.</p><p><em>More content at </em><a href="https://plainenglish.io/"><strong><em>plainenglish.io</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60a0e3595193" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/create-multi-language-vue-applications-with-vue-i18n-60a0e3595193">Create Multi-language Vue Applications with Vue I18n</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean Architecture Vuex by example]]></title>
            <link>https://javascript.plainenglish.io/clean-architecture-vuex-by-example-a65cf2c18d5f?source=rss-9a96264a7232------2</link>
            <guid isPermaLink="false">https://medium.com/p/a65cf2c18d5f</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[vuex]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Hans Sagita Soegiarto]]></dc:creator>
            <pubDate>Sat, 27 Mar 2021 09:44:00 GMT</pubDate>
            <atom:updated>2021-03-27T09:44:00.832Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to keep your Vuex architecture clean and maintainable by example.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XVFgTuvRqxIfx-TVWJ2TcA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@benchaccounting">Bench Accounting</a> on <a href="https://unsplash.com/photos/nvzvOPQW0gc">Unsplash</a></figcaption></figure><h4>Introduction</h4><p>This article explores tips and tricks on how to create clean architecture for Vuex. This architecture inspired by <a href="https://vuex.vuejs.org/">Vuex</a> official documentation, my mentors and some other reference from my experience and the Internet.</p><p>Based on <a href="https://vuex.vuejs.org/">Vuex</a> official documentation, Vuex is a state management pattern + library for <a href="https://vuejs.org/">Vue.js</a> applications. It serves as a centralized store for all the components in an application, with rules ensuring that the state can only be mutated in a predictable fashion.</p><p>Just to simplify, VueJs is a framework which adopts component-based architecture, so each component is designed to be a small chunk of Vue file and reusable between components. Because of that, it does not rule out the possibility some small component needs to work together or consume the same data. That’s why we need Vuex to help us solve that issue. Vuex is like a global variable and global function that can be used by every component that we have. Vuex also helps us to manage API calls and store the response data more centralized, so one API call and the data can be used in every component in our Vue project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*KIoNyRO6s_52W68Y-0usJw.png" /><figcaption>Vuex Architecture from official docs</figcaption></figure><h4>Deep dive how to register and create Vuex module</h4><p>For the rest of the article, let us assume that we are building a simple Vue app with Vuex that displays a list of people and planets in Starwars movie using <a href="https://swapi.dev/">Swapi.dev</a> with clean architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*_3o5ZpsSZGoBZpA80olfaw.png" /><figcaption>Installing Vuex to our Vue App flow</figcaption></figure><p>First of all, we need to create a new store module based on each scope.<br>Here’s our template when creating a store module. Each store module contains state, mutations, actions and getters, we will learn more about each one at the next section. Make sure to add <strong>namescaped</strong> properties too. It means we will have to specify the namespace name first before accessing the store module, it will make your Vuex more clean and maintainable. We will see more example in the last section.</p><pre>const state = {}<br>const mutations = {}<br>const actions = {}<br>const getters = {}</pre><pre><em>export default </em>{<br>  namespaced: <em>true</em>,<br>  state,<br>  mutations,<br>  actions,<br>  getters<br>}</pre><p>After we finish creating a store module that we need, we have to combine all the store modules and create into a Vuex store.<br>Actually, you can go straight to create a store module (state, getters, actions) in code below without creating a separate modules like people module or planets module.<br>But for the clean architecture purpose, I must say <strong>don’t do that</strong> and better to create several small module and combine it into one like this example.</p><pre>import Vue from &#39;vue&#39;<br>import Vuex from &#39;vuex&#39;<br>import people from &#39;./module/people&#39;<br>import planets from &#39;./module/planets&#39;</pre><pre>Vue.use(Vuex)</pre><pre>const store = new Vuex.Store({<br>  modules: {<br>    &#39;people&#39;: people, // You can rename your namespaced in here<br>    planets // will auto set the namespaced name equals with planets<br>  }<br>});</pre><pre>export default store</pre><p>After that, you combine several store modules and bundle it into one. Next step is you must register it when creating the Vue app, so the Vue app can use all the Vuex store module that we have created earlier.</p><pre><em>import </em>Vue <em>from </em>&#39;vue&#39;<br><em>import </em>App <em>from </em>&#39;./App.vue&#39;<br><em>import </em>store <em>from </em>&#39;./store&#39;<em><br><br>new </em>Vue({<br>  render: h =&gt; h(App),<br>  store<br>}).$mount(&#39;#app&#39;)</pre><h4>Deep dive to create a single store module</h4><p>For the rest of the single store module, we only focus on the people store module because, more or less, it’s a bit similar between people and the planets store module. You can check it also for the planets implementation in my <a href="https://github.com/hanssagita/vuex-example">Github repo</a>.<br>First of all, I always start with the state first, to simplify state is like a global variable that contains data. For this example, we want to store the Starwars people data. Since we have more than one person data, we will store it in an Array. In this example I define a people field with the default value of an empty Array.</p><pre><em>const </em>state = {<br>  people: []<br>}</pre><p>Secondly, after we know what the global variable we want to store, we need to create a mutations to able to modify the state value. Because it’s like a global variable, we need to have guard the state to be edited without calling the mutations, only mutations can change the state value. In this example, I use the spread operator when modifying state value , because in JavaScript if we only use equals (=) the value only copy the reference not deep copy the array value. I’m afraid it can be another bug and hard to debug. So it’s better to use the spread operator when mutating the new value. For an object, also make sure to use the spread operator.</p><pre><em>const </em>mutations = {<br>  setPeople(state, payload) {<br>    state.people = [...payload]<br>  }<br>}</pre><pre>// Tips<br>// mutate array value use this --&gt; = [...payload]<br>// mutate object value with --&gt; = {...payload}<br>// mutate string, number or boolean value with --&gt; = payload</pre><p>Thirdly, we come to the actions. To simplify, actions are like a global function that can be called in every component we define. Mostly, actions are used for handling API calls and changing the state value. At actions we usually call mutations to change the state value.</p><p>In my opinion, and for cleaner architecture. I suggest to create a new separate file for the API. For this example I used Axios, and I combine the Axios future promise with callback function. Axios will call get request from <a href="https://swapi.dev/">Swapi.dev</a>, then return some response and trigger the success callback with the result. Some with the failed request. It will run the catch and return the fail callback also with the error response.</p><pre><em>import </em>axios <em>from </em>&#39;axios&#39;<br><br><em>const getPeople </em>= (success, fail) =&gt; {<br>  axios<br>    .get(&#39;https://swapi.dev/api/people/&#39;) // backend Url<br>    .then((response) =&gt; success(response)) // request success<br>    .catch((response) =&gt; fail(response)) // request fail<br>};<br><br><em>export </em>{ <em>getPeople </em>}</pre><p>After finishing and preparing all the API call and combining it with a callback, now we can go back to our store module. In this action we will call the API that we define previously in separate file, we accept 2 parameter in object success and fail, same like in the API, success for triggering some function after finishing API call. We usually use it for show and hide loading or trigger some trackers, and for fail callback we usually used for showing error message to customer or to handle error handler in the component.</p><pre>import { getPeople } from &#39;@/api&#39;</pre><pre><em>const </em>actions = {<br>  getPeopleAction({ commit }, { success, fail } = {}) {<br>    getPeople( // Call the API<br>      (response) =&gt; { // Success Callback<br>        commit(&#39;setPeople&#39;, response.data.results) // call mutations<br>        // Trigger to view another success Callback<br>        success &amp;&amp; success(response) <br>      },<br>      (response) =&gt; { // Fail Callback<br>        fail &amp;&amp; fail(response) // Trigger to view fail callback<br>      }<br>    )<br>  }<br>}</pre><p>Last but not least, Getters is to compute derived state based on store state. Getters is optionals, you can have it or not. If you need state with modified value you can have it. For this example I try to differentiate between male and female people, we can use getters to handle that.</p><pre><em>const </em>getters = {<br>  male (state) {<br>    <em>return </em>state.people.filter(person =&gt; person.gender === &#39;male&#39;) <br>  },<br>  female (state) {<br>    <em>return </em>state.people.filter(person =&gt; person.gender === &#39;female&#39;)<br>  }<br>};</pre><h4>Deep dive how to access the store module from views or components</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*WOE-8R5-RdcIGakVeg0T1w.png" /></figure><p>First of all, let’s start from the state. To access the state, we need to import mapState from Vuex and map it into a computed value like the example code below.</p><pre>import { mapState } from &#39;vuex&#39;<br>export default {<br>  name: &quot;People&quot;,<br>  computed: {<br>    // First parameter is the namespaced name<br>    // Second parameter is the list of state<br>    ...mapState(&#39;people&#39;, [&#39;people&#39;]),<br>  }<br>}</pre><pre><em>// Bonus tips<br>// If you want to access more than one store modules<br>// You need to define another mapState inside computed<br></em>computed: {<br>    ...mapState(&#39;people&#39;, [&#39;people&#39;]), // first module<br>    ...mapState(&#39;planets&#39;, [&#39;planets&#39;]) // second module<br>  }</pre><p>Secondly, the actions, you need to import mapActions from Vuex and place it inside methods, since actions are like global methods.</p><pre>import { mapActions } from &#39;vuex&#39;<br>export default {<br>  name: &quot;People&quot;,<br>  data () {<br>    return {<br>      isLoading: false<br>    }<br>  },<br>  methods: {<br>    ...mapActions(&#39;people&#39;, [&#39;getPeopleAction&#39;]),<br>    handleSuccess () {<br>      this.isLoading = false<br>      console.log(&#39;success fetch data&#39;)<br>    },<br>    handleFail () {<br>      this.isLoading = false<br>      console.log(&#39;failed fetch data&#39;)<br>    }<br>  },<br>  created () { // created will be running before component rendered<br>    this.isLoading = true // loading variable became true<br>    this.getPeopleAction({ // call the actions we define<br>      success: this.handleSuccess, // will run this after success<br>      fail: this.handleFail // will run this if failed<br>    })<br>  },<br>}</pre><p>Last but not least, getters it’s more or less the same like mapState, we need to import mapGetters from Vuex and place it also inside computed.</p><pre>import { mapGetters } from &#39;vuex&#39;<br>export default {<br>  name: &quot;People&quot;,<br>  computed: {<br>    // First parameter is the namespaced name<br>    // Second parameter is the list of getters<br>    ...mapGetters(&#39;people&#39;, [&#39;male&#39;, &#39;female&#39;]),<br>  }<br>}</pre><p><a href="https://github.com/hanssagita/vuex-example">Code Example on my Github</a></p><h3>Conclusion</h3><p>Vuex is state management, and it stores all of your Vue app logic. You have to make sure to keep it clean, and maintainable with some tips and tricks that I shared.</p><p>That’s it and if you found this article helpful, let us know in the comments. You can also follow me on <a href="https://medium.com/@hanssagita">Medium</a> and <a href="https://www.linkedin.com/in/hans-sagita/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a65cf2c18d5f" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/clean-architecture-vuex-by-example-a65cf2c18d5f">Clean Architecture Vuex by example</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implement Dark Mode without any Library or Utility]]></title>
            <link>https://javascript.plainenglish.io/implement-dark-mode-without-any-library-or-utility-cf2271af5837?source=rss-9a96264a7232------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf2271af5837</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Hans Sagita Soegiarto]]></dc:creator>
            <pubDate>Tue, 09 Mar 2021 08:43:08 GMT</pubDate>
            <atom:updated>2023-06-13T13:32:20.586Z</atom:updated>
            <content:encoded><![CDATA[<h4>You won’t believe how simple it is</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A3ryZhp2huItyBK28sEFvg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@quincoetzee">Quinton Coetzee</a> on <a href="https://unsplash.com/photos/_fHzsyyDcuQ">Unsplash</a></figcaption></figure><h4>Introduction</h4><p>Dark mode was becoming a trend nowadays. The trend came out when Apple adopted dark mode in the latest iOS and then the Android phone also came along. Dark mode is a must have feature on nowadays’s websites, almost every website that I visit has a dark mode feature. But still some people don’t know how to implement the right way, so sometimes they prefer to install a new library. Today I want to show you how simple it is to implement dark mode without any library.</p><h4>Deep dive to code Example</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a7b67a5872ec0948bb56fb1a6c401bd/href">https://medium.com/media/8a7b67a5872ec0948bb56fb1a6c401bd/href</a></iframe><p>This is just an example body html. I put a checkbox in the top of the page for toggling the dark mode feature. I use the “<a href="https://www.w3schools.com/jsref/event_onclick.asp">onClick</a>” as an example toggling the dark mode. For each content I give these CSS class names to help you differentiate and see the result.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c42530a8f7cfb72c33d6f306d471e2e/href">https://medium.com/media/0c42530a8f7cfb72c33d6f306d471e2e/href</a></iframe><p>The magic and tricks come in these CSS files. You can see above I use <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:root">:root selector</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties">CSS Variables</a> and <a href="https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes">Data Attributes</a>. The <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:root">:root selector</a> matches the document’s root element. It can be really useful for declaring global CSS Variables. HTML5 data Attributes is a HTML5 feature to allow us to store extra information on our DOM.</p><p>First, in the :root selector, I define all the default (Light Mode) background colour and text colour into a variable. After that, I also create new CSS selector using Data Attributes. The name I gave is Theme, and the value is dark. Inside the selector, I define all the background colour and text colour for the dark mode.</p><p>Lastly, I write all the text and background colour variables to the CSS class that I expect will change when I toggle the dark mode.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1909c3822fa8d067ec405246af32508/href">https://medium.com/media/f1909c3822fa8d067ec405246af32508/href</a></iframe><p>Finally, the JavaScript code, first, I initiate the “currentTheme” variable as “light” for default, and then I get a checkbox, info and body DOM preparing for DOM manipulation.</p><p>The “changeTheme” function is called when you toggle the checkbox DOM. Basically, this function is used for toggling the “currentTheme” and set the data attribute in the body tag. After toggling the body should be like this below.</p><pre>&lt;body data-theme=&quot;dark&quot;&gt;&lt;/body&gt;</pre><p>And then CSS will automatically override the default colour variable that we define in :root to the [data-theme=”dark”] selector.</p><h4>Demo Example</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fhans_sagita%2Fembed%2Fpreview%2FZEBMNGg%3Fheight%3D600%26slug-hash%3DZEBMNGg%26default-tabs%3Dcss%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2Fhans_sagita%2Fpen%2FZEBMNGg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c66a2ad2fc1983ead6b85056ed3f359/href">https://medium.com/media/9c66a2ad2fc1983ead6b85056ed3f359/href</a></iframe><p><a href="https://github.com/hanssagita/native-darkmode-example">Github Source Code Link</a></p><h4>Bonus tips</h4><p>You can save the user preference with <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage">local storage</a>, so when a user visits your website for the second time, the theme will automatically adjust the last time the user picks it.</p><pre>// define localStorage key<br>const localStorageThemeKey = &quot;localStorageThemeKey&quot;</pre><pre>// Getting the currentTheme from localStorage, when the localStorage return undefined will automatically set to light<br>const getCurrentTheme = <br>localStorage.getItem(localStorageThemeKey) || &quot;light&quot;</pre><pre>// Save user input to the localStorage with localStorage key and currentTheme right now<br>localStorage.setItem(localStorageThemeKey, currentTheme);</pre><h4>Conclusion</h4><p>Dark mode is very simple, and you don’t need a library to implement that.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Ff9lACksFcCE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Df9lACksFcCE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Ff9lACksFcCE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d41f98a14644ee78d78e59960dceaa26/href">https://medium.com/media/d41f98a14644ee78d78e59960dceaa26/href</a></iframe><p>That’s it and if you found this article helpful, let us know in the comments. You can also follow me on <a href="https://medium.com/@hanssagita">Medium</a> and <a href="https://www.linkedin.com/in/hans-sagita/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf2271af5837" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/implement-dark-mode-without-any-library-or-utility-cf2271af5837">Implement Dark Mode without any Library or Utility</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Example of a Non Blocking Process in JavaScript]]></title>
            <link>https://javascript.plainenglish.io/an-example-of-a-non-blocking-process-in-javascript-3d8dfd8e8938?source=rss-9a96264a7232------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d8dfd8e8938</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Hans Sagita Soegiarto]]></dc:creator>
            <pubDate>Fri, 05 Mar 2021 08:22:02 GMT</pubDate>
            <atom:updated>2021-03-05T08:22:02.106Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to create a non-blocking process using Callback and Promise by example</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*0MiR7DOGFKcFByxAwgETGg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/vpOeXr5wmR4">James Harrison</a> on <a href="http://unsplash.com/">Unsplash</a></figcaption></figure><p>JavaScript is a synchronous programming language. This means that it will execute your code block by order from top to bottom. But thanks to the JavaScript Event loop, we are able to do non-blocking processes by using a callback function and a promise function.</p><p>Here are some examples.</p><h4>Callback Function</h4><pre>// Example Parameter Function<br>const parameter = {<br>  firstName: &#39;John&#39;,<br>  lastName: &#39;Doe&#39;<br>}</pre><pre>// Example callback function (will run after delay function finish)<br>const callBackFunction = (result) =&gt; {<br>  console.log(result)<br>}</pre><pre>// Example slow process or API call Function<br>const delayFunction = (callBack, parameter) =&gt; {<br>  <br>  // For replicate delay we use setTimeout as example<br>  setTimeout(() =&gt; {<br>    // Example slow process or api call return<br>    const result = `${parameter.firstName} ${parameter.lastName}`<br>    <br>    // Triggering the callback function after getting the result<br>    callBack(result)<br>  },1000)<br>}</pre><pre>console.log(&#39;start&#39;)<br>// Run delay function<br>delayFunction(callBackFunction, parameter)<br>console.log(&#39;finish&#39;)</pre><pre>// Output:<br>// Start<br>// Finish<br>// John Doe</pre><h4>Promise Function</h4><pre>// Example Parameter Function<br>const parameter = {<br>  firstName: &#39;John&#39;,<br>  lastName: &#39;Doe&#39;<br>}</pre><pre>// Example callback function (will run after delay function finish)<br>const callBackFunction = (result) =&gt; {<br>  console.log(result)<br>}</pre><pre>// Example slow process or API call Function<br>const delayFunction = (parameter) =&gt; {<br>  return new Promise((resolve) =&gt; {<br>    <br>    // For replicate delay we use setTimeout as example<br>    setTimeout(() =&gt; {<br>    <br>    // Example slow process or api call return<br>    const result = `${parameter.firstName} ${parameter.lastName}`<br>    <br>    // Triggering the resolve promise after getting the result<br>    resolve(result)<br>  },1000)<br>  })<br>}</pre><pre>console.log(&#39;start&#39;)<br>// Run delay function<br>delayFunction(parameter).then(callBackFunction)<br>console.log(&#39;finish&#39;)</pre><pre>// Output:<br>// Start<br>// Finish<br>// John Doe</pre><p>The benefit of learning and using the non-blocking approach is you can reduce the JavaScript main thread process and boost your code performance, so your thread doesn’t get blocked and still run through every process left.</p><p>After all the process left has been done, JavaScript will check the Event loop to see whether the callback has already finished or not. When finished, it will run the callback function.</p><h4>Conclusion</h4><p>That’s it and if you found this article helpful, let us know in the comments. You can also follow me on <a href="https://medium.com/@hanssagita">Medium</a> and <a href="https://www.linkedin.com/in/hans-sagita/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d8dfd8e8938" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/an-example-of-a-non-blocking-process-in-javascript-3d8dfd8e8938">An Example of a Non Blocking Process in JavaScript</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Subtle Art Of Becoming Productive]]></title>
            <link>https://hanssagita.medium.com/the-subtle-art-of-becoming-productive-f376267c761b?source=rss-9a96264a7232------2</link>
            <guid isPermaLink="false">https://medium.com/p/f376267c761b</guid>
            <category><![CDATA[personal-growth]]></category>
            <category><![CDATA[personal-development]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[millennials]]></category>
            <dc:creator><![CDATA[Hans Sagita Soegiarto]]></dc:creator>
            <pubDate>Fri, 13 Dec 2019 19:00:49 GMT</pubDate>
            <atom:updated>2019-12-13T19:00:49.555Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6j1FGvnZFE_tAKwodaXuBg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@finesite">krisna iv</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Hi Readers! Have you ever feel anxious about your job? thinking that you’re not productive enough? wondering how you go to the next level? you come to the right Tips and trick. For some background, I’m a software engineer at one of the largest e-commerce companies in Indonesia (Blibli.com) and sometimes I feel anxiety when my work isn’t productive. That’s why I want to share with you all how I tackle this anxiety problem and give you some tips that work for me.</p><h3>What you should do?</h3><p><strong>Having clear priorities, achievable goals, milestones, and checkpoints</strong></p><p>Have you ever thought about what will happen to you in 2 or 5 years’ time? If you have this kind of thought, then it’s a good sign. You have to know exactly what is your short term goal, mid-term goal, long term goal and also the impact if you can achieve them. If you still don’t have any plan for your life, I urge you to start thinking about that.</p><p>Life is like video games, you have to create a milestone or checkpoints in your journey. Imagine if you play video games without a checkpoint, it’s gonna be so hard to finish it.</p><p>For Example, First, I want to have a good career path as a software engineer in a startup so, I have to find some time after the office to learn about new programming languageS and concepts (short term goal). After I got promoted to senior software engineer, I had to learn about management and mentorship to become a development manager (mid-term goal). Lastly, I have to learn about business and strategy to become C level employees or create my own startup company (long term goal).</p><p><strong>Know your best path or shortest path for you to achieve the goal</strong></p><p>Work smart rather than work hard, you have to know about yourself, your personality and which learning methods are the most suitable for you. As soon as you know what kind of learning styles you have (Visual, Auditory, Kinesthetic) and find a good mentor.</p><p>For example, I’m more productive when I learn about programming with video courses like youtube and udemy. Because of that, if I want to learn about programming, I learn it from A video course, not from another resource like books or articles, because I know my best way to learn about programming is from the video course.</p><p><strong>Set up Artificial Deadline and make it real</strong></p><p>The ultimate inspiration is the deadline, most people become productive because of the deadline, so I urge you to practice creating an artificial deadline, and also create real punishment for yourself to make yourself keep motivated and make it real.</p><p>For Example, you can set up simple artificial deadlines like finishing 100 pages of books each day and if you break the rules you can punish yourself the next day by having to read 150 pages or a hundred push-ups for (do something that you didn’t like).</p><h3>What you should avoid!</h3><p><strong>Know where most of your time wasted and throw it away</strong></p><p>In this smartphone era, most of our time is wasted on social media and entertainment on our smartphones. Luckily our smartphone nowadays has a rich feature like screen time on the iPhone so you can know where most of your time wasted.</p><p>After you know that, you can limit access to that application and with a screen time limit or other application, you can make a promise to yourself and create a real punishment.</p><p><strong>Avoiding distractions</strong></p><p>Last but not least, when you need time to focus, you have to stay away from anything that can distract you. For example, silence your mobile phone and put it away from your workplace. If you’re using a laptop to work. You can block social media and youtube with extensions in the chrome browser called blocksite. I use it a lot and IT really helps my productivity since I’m a software engineer and using my laptop to work.</p><p><strong>Thanks for reading!</strong></p><p>I hope you enjoyed this article. If you have any notes, you can leave it there in the comment section. Made with love by Hans Sagita 😁</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f376267c761b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What should you know before starting your career path as a Software Engineer]]></title>
            <link>https://hanssagita.medium.com/what-should-you-know-before-starting-your-career-path-as-a-software-engineer-b922eaeb82d9?source=rss-9a96264a7232------2</link>
            <guid isPermaLink="false">https://medium.com/p/b922eaeb82d9</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[self]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Hans Sagita Soegiarto]]></dc:creator>
            <pubDate>Sun, 03 Mar 2019 09:07:05 GMT</pubDate>
            <atom:updated>2021-03-03T16:17:27.932Z</atom:updated>
            <content:encoded><![CDATA[<h3>What should you know before starting your career as a Software Engineer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uwbv9Nzv7uoZV_hJwrsPGQ.jpeg" /></figure><p>Hi Readers! I’m a software engineer at one of the largest e-commerces in Indonesia (Blibli.com). I have just finished my 1-year experience as a full-time software engineer.</p><p>Before I became a full-time software engineer, I was enrolled in a special program at the university to have full-time internship experience for 1-year. I was learning new things such as software engineering, both frontend and backend, scrum practice, e-commerce business logic and so much more than during my internship.</p><p>I have to say that it was really challenging and tough because of my lack of preparation, and at that time I still didn’t know what my passion in software engineering was, either focus in frontend, backend. My aim is to help you not to have the same tough experience.</p><h3>Find Your Programming Passion</h3><h4>Never stop learning</h4><p>I have an analogy for this point, imagine that you’re riding a bike, when you stop cycling, you will fall, but if you keep cycling, you only have a small chance to fall. Just like programming. Every month or even every day, there’s always something new that we can learn. So never stop learning new technology and don’t be afraid to use that technology for your project. You can learn from many things, such as:</p><h4>Video Course</h4><p>For me personally, the videos course is the best source to learn. I usually learn from Udemy, and Youtube. When I did that, I used an extended monitor, one monitor to play the video course and the other monitor for me to follow the lecturer code or take notes.</p><p>Why does the video course really matter to me?</p><p>Because learning from the video course uses 3 senses of our body: ears, eyes, and hands. Also, when learning from a video course, I have the same pace with the lecturer. It makes the learning process much more productive. It is also easier to understand the concept of the material that is being thought.</p><h4>Books and documentation</h4><p>Books are a window to the world. Sometimes video courses or articles like on Medium only explain the core concepts in programming. If you still need more explanation, you can get that information more complete in books and documentation. For example, if you want to make a new feature to the library, you usually need more information than just a best practice.</p><h3>Knowing basic about how the industry work and technical term</h3><h4>Clean Code</h4><p>You have to learn how to write code that will be understood by both humans and computers. You will realize how important this is when you work with legacy code. Most of the college and online courses teach the student how to write code that a computer understands, and the output is some with the expected ones, but they don’t teach how to code so that another human will understand it.</p><h4>Soft-skill</h4><p>Working life is different from high school or even in college. There is no test and exact measurement for the result of our work as an employee. At work, we are measured by both hard skills and soft skills. You need to practise your soft skills like teamwork, communication, politeness, and personal development. You can practise that in student activities and communities.</p><h4>Technical and Industry Term (Jargons)</h4><p>When you enter the industry, you will find some strange technical and industry term that you will not be familiar with. I won’t explain all of those terms, but I will give you some good references for all that you should know.</p><ul><li><a href="https://www.youtube.com/watch?v=s7wmiS2mSXY">API</a></li><li><a href="https://www.youtube.com/watch?v=2Vt7Ik8Ublw">Scrum</a></li><li><a href="https://www.youtube.com/watch?v=SWYqp7iY_Tc">Git</a></li></ul><h3>Find the best company that suits you</h3><h4>Company values</h4><p>Before you apply for a job, make sure you find out about the company values, company prospects, and company technology stacks. Some people prefer to join a big company, some people like to join a startup company. So it’s your option to choose what kind of company you prefer.</p><h4>Work-life balance</h4><p>Most of your time when you’re working will be at the office. So it’s really important to know the working life there. You probably don’t want to spend your day without enjoying it, right?</p><p>Some people have their personal likes and behavior of working. For example, some people like to work at night time, the others prefer in the morning. You should also gather information about the environment in the office, whether it is dominated by old people or millennials, whether it is supportive or not. You can ask someone that already works there and also nowadays there are so many websites that provide that kind of data like Glassdoors, Linkedin.</p><h4>Company salary</h4><p>Don’t expect too much if you are looking for internship or you’re a fresh graduate, but you must know what is the average salary for that kind of job and the value of yourself, so you can negotiate with HR department or with recruiters because if from beginning you aren’t satisfied with your salary sooner or later you will look for a new company.</p><p><strong>With hard work, persistence, and be grateful you can achieve anything.</strong></p><p>If you like my writing please follow me on medium and give me a 👏. You can also find me on <a href="https://www.facebook.com/hans.sagita.20">Facebook</a>, <a href="https://www.linkedin.com/in/hans-sagita/">Linkedin</a>, and <a href="/service/mailto:hans.sagita@gmail.com">email</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b922eaeb82d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>