<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: KristijanFištrek</title>
    <description>The latest articles on Forem by KristijanFištrek (@kristijanfistrek).</description>
    <link>https://forem.com/kristijanfistrek</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F178084%2F282847c2-5462-46c2-a904-8f618d73d868.jpg</url>
      <title>Forem: KristijanFištrek</title>
      <link>https://forem.com/kristijanfistrek</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/kristijanfistrek"/>
    <language>en</language>
    <item>
      <title>I made an Android App in a week. </title>
      <dc:creator>KristijanFištrek</dc:creator>
      <pubDate>Thu, 02 Jul 2020 08:38:51 +0000</pubDate>
      <link>https://forem.com/kristijanfistrek/i-made-an-android-app-in-a-week-p1m</link>
      <guid>https://forem.com/kristijanfistrek/i-made-an-android-app-in-a-week-p1m</guid>
      <description>&lt;p&gt;First things first, &lt;strong&gt;I made an Android App&lt;/strong&gt;. 🎉 🥳&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can check it out here: &lt;a href="https://play.google.com/store/apps/details?id=com.codeitlab.ionic"&gt;My awesome &amp;amp; free app&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Technologies used&lt;/strong&gt;: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Angular/Ionic&lt;/li&gt;
&lt;li&gt;Firebase&lt;/li&gt;
&lt;li&gt;Node.js/Express.js&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;Currently I'm in the process of making a website version of this app, which will be done in &lt;strong&gt;React&lt;/strong&gt; (I know, I know...) and for that I will need a more solid back-end system, which I've started to move from &lt;strong&gt;Express&lt;/strong&gt; to &lt;strong&gt;Spring Boot&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Considering how much data and instant verification I'll need to do, I am looking into &lt;strong&gt;GraphQL&lt;/strong&gt; as my &lt;strong&gt;Postgres&lt;/strong&gt; layer. I believe it will enable me to query exactly what I need without overloading my website or my app with additional data which I am not using. &lt;/p&gt;

&lt;p&gt;Let me know how you like it in the comments below, leave your opinion, critique, advice or let's just talk about tech! &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is anyone interested in Ionic/Angular tutorials or some tricks &amp;amp; tips?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Take care good people! &amp;lt;3 &lt;/p&gt;

</description>
      <category>android</category>
      <category>angular</category>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>Deploy Springboot App to Heroku with Github</title>
      <dc:creator>KristijanFištrek</dc:creator>
      <pubDate>Mon, 25 May 2020 10:00:52 +0000</pubDate>
      <link>https://forem.com/kristijanfistrek/deploy-springboot-app-to-heroku-with-github-27ij</link>
      <guid>https://forem.com/kristijanfistrek/deploy-springboot-app-to-heroku-with-github-27ij</guid>
      <description>&lt;p&gt;Hey good peeps, long time - no hear.&lt;/p&gt;

&lt;p&gt;In this quarantine time I bring you something I've been working on lately, CD (continuous deployment) of Springboot apps. &lt;br&gt;
I hope you'll find it useful.&lt;/p&gt;
&lt;h2&gt;
  
  
  Table Of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;1. Introduction&lt;/li&gt;
&lt;li&gt;2. Create a Github repository&lt;/li&gt;
&lt;li&gt;3. Initialize the Springboot Application&lt;/li&gt;
&lt;li&gt;4. Create a Heroku account&lt;/li&gt;
&lt;li&gt;5. Connect with Github &amp;amp; Deploy&lt;/li&gt;
&lt;li&gt;6. Test &amp;amp; Celebrate&lt;/li&gt;
&lt;li&gt;7. Conclusion&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;1. Introduction&lt;/strong&gt; &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;In this short little blog we'll initialize the simple Springboot application, connect it with Github, connect it with Heroku and at the end we'll deploy our Spring application with incredible ease and what's most important, absolutely free of charge.&lt;/p&gt;

&lt;p&gt;First, make sure you have a Github account and that you're familiar with the basic git commands such as ''git clone'' – ''git commit''  and ''git push''. &lt;br&gt;
Of course, you can use whatever SVC tool you want, but we won't be covering the likes of Gitlab, Bitbucket and similar here. &lt;/p&gt;

&lt;p&gt;Second, make sure you have IntelliJ or other Spring IDE where you can build, run and debug your Springboot applications.&lt;/p&gt;

&lt;p&gt;Third, have fun!&lt;/p&gt;
&lt;h2&gt;
  
  
  2. &lt;strong&gt;Create a Github repository&lt;/strong&gt; &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;First things first, we want to establish a Github -&amp;gt; Heroku connection, so whenever we merge into our master, we'll instantly publish, build and deploy our app on Heroku.&lt;/p&gt;

&lt;p&gt;You can have multiple git instances in one folder, because Heroku provides its own git, but that is too troublesome. We'll use our Github repository as a single point of source control. &lt;/p&gt;

&lt;p&gt;Here are the steps I've followed:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://help.github.com/en/github/getting-started-with-github/signing-up-for-a-new-github-account"&gt;Sign up for Github (if you haven't already)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://help.github.com/en/github/getting-started-with-github/create-a-repo"&gt;Create a repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://help.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository"&gt;Clone a repository&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Another useful information is &lt;a href="https://help.github.com/en/github/managing-files-in-a-repository/adding-a-file-to-a-repository-using-the-command-line"&gt;committing &amp;amp; pushing&lt;/a&gt; the data in your repository.&lt;/p&gt;
&lt;h2&gt;
  
  
  3. &lt;strong&gt;Initialize the Springboot Application&lt;/strong&gt; &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;To initialize our Springboot application with ease, we'll use &lt;a href="https://start.spring.io/"&gt;https://start.spring.io/&lt;/a&gt; - excellent tool to kickstart your base application settings with dependencies you need.&lt;/p&gt;

&lt;p&gt;Feel free to select whatever you like, but for the purposes of this tutorial let’s just go with the basics. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kbR0BMPw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vvmmztjf06b8d91q8lf3.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kbR0BMPw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vvmmztjf06b8d91q8lf3.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After you have selecting the settings you like or the settings from the picture above, let's click on Generate and save it inside of your git repository we have cloned in the second step.&lt;/p&gt;

&lt;p&gt;Before you do anything else, make sure to run your application in the IDE of your choice, mine is IntelliJ, and build it just to make sure everything runs smoothly.&lt;/p&gt;

&lt;p&gt;If everything is alright, you should see something like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6Ly267jb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mx7b1i8e6ovzacxi8thv.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6Ly267jb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mx7b1i8e6ovzacxi8thv.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If some of your files are colored red, have no fear, it is due to git being too smart. He recognized new files in the directory and he is letting us know we haven't committed then yet, we'll do that in the moment.&lt;/p&gt;

&lt;p&gt;Let's just create a simple controller, something that will display a generic message. That generic message will serve as a confirmation that everything was deployed smoothly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QMfouSdZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mshtycmhfpyp184yy9re.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QMfouSdZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mshtycmhfpyp184yy9re.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your Spring annotations are red, be sure to add this in your pom.xml and update your Maven settings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.springframework&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;spring-web&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;5.0.7.RELEASE&amp;lt;/version&amp;gt;
        &amp;lt;/dependency&amp;gt;

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



&lt;p&gt;Before we create a heroku account, let's push the changes to our repository. &lt;/p&gt;

&lt;p&gt;You can do it directly from IntelliJ or the IDE of your choice, but this time I'll do it with Git Bash.&lt;/p&gt;

&lt;p&gt;Navigate in your working directory, open Git Bash and let's commit!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
git add -A

git commit -m "Master: Initial commit"

git push

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



&lt;p&gt;If everything was successful, you should see the files in your Github repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8QjusBQm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0ppxrqoa0622t0odmw3f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8QjusBQm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0ppxrqoa0622t0odmw3f.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. &lt;strong&gt;Create a Heroku account&lt;/strong&gt; &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;First things first, sign up for Heroku: &lt;a href="https://signup.heroku.com/"&gt;https://signup.heroku.com/&lt;/a&gt;&lt;br&gt;
After a successful sign in, your dashboard should look something like this.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I already have one Java project, so just ignore that one.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4KBsR8yr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ykud3ivi375gpolq445i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4KBsR8yr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ykud3ivi375gpolq445i.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even though Heroku provides its own &lt;a href="https://devcenter.heroku.com/articles/heroku-cli"&gt;CLI&lt;/a&gt;, we'll be using our Heroku dashboard for creating our application and we'll use &lt;a href="https://github.com/NREL/SAM/wiki/Basic-git-tutorial"&gt;Github Bash&lt;/a&gt; once again for all of our git purposes. &lt;/p&gt;

&lt;p&gt;Now let's create our app by click &lt;strong&gt;New&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Create new app&lt;/strong&gt; in the upper right corner.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B1LgmpPG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0guqng8mtmazasu193ai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B1LgmpPG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0guqng8mtmazasu193ai.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then you'll need to provide a name for your app, feel free to name it whatever you like.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--A2RryXw5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ijwfqjblzfxdtt0anf8x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A2RryXw5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ijwfqjblzfxdtt0anf8x.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And voila! You should see something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--a_UxkXPd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yay1d3v8zmty0oapzh9o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a_UxkXPd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yay1d3v8zmty0oapzh9o.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. &lt;strong&gt;Connect with Github &amp;amp; Deploy&lt;/strong&gt; &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;In this next step we'll continue where we've left off.&lt;/p&gt;

&lt;p&gt;On the previous screen, you should see the section &lt;strong&gt;Deployment method&lt;/strong&gt;, by default &lt;strong&gt;Heroku Git&lt;/strong&gt; should be selected.&lt;/p&gt;

&lt;p&gt;Since we're be using our Github repository for continuous deployment here, make sure to select &lt;strong&gt;Github option&lt;/strong&gt; like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bt1y0xFm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yx9sy2p2p029zg90an7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bt1y0xFm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yx9sy2p2p029zg90an7m.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you may have assumed, to connect Heroku with our Github account, we need to proceed with this step by clicking on &lt;strong&gt;Connect to Github&lt;/strong&gt; button down below.&lt;br&gt;
Once clicked, and you're authorization was successful, you should see a screen like this one: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NWAmoEpE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/e7jacdu90zx7nlgy1cj0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NWAmoEpE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/e7jacdu90zx7nlgy1cj0.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Search for your repository in &lt;strong&gt;Search for a repository to connect to&lt;/strong&gt; section, it should look like something like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--70XQOkVH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ogpeurv5s2g0x3rkb7b6.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--70XQOkVH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ogpeurv5s2g0x3rkb7b6.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After you successfully connect with the desired repository, make sure to connect &lt;strong&gt;master&lt;/strong&gt; as a deployment branch and click on &lt;strong&gt;Enably automatic deploys&lt;/strong&gt; and voila, our connection is established!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qqvcPZkK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i2xje4utmlv54tr3k8lr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qqvcPZkK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i2xje4utmlv54tr3k8lr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. &lt;strong&gt;Test &amp;amp; Celebrate&lt;/strong&gt; &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The last step in our process is making slight adjustments in our app and publishing to our master branch.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Head into our app, change the text in our @GetMapping method.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;
&lt;span class="nd"&gt;@GetMapping&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;hello&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;"This tutorial is the best. All hail the great Kristijan."&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

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



&lt;ul&gt;
&lt;li&gt;Now let's repeat our Git Bash commands from before.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
git add -A

git commit -m "Master: Text changes"

git push

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



&lt;ul&gt;
&lt;li&gt;Head over to Heroku and click on &lt;strong&gt;Open app&lt;/strong&gt; in the upper right corner of our Heroku Dashboard.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tKYKDF1g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mqr1jn1nlbj0nxjioocg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tKYKDF1g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mqr1jn1nlbj0nxjioocg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And voila! You should see the message &lt;em&gt;This tutorial is the best. All hail the great Kristijan.&lt;/em&gt; displayed on your screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. &lt;strong&gt;Conclusion&lt;/strong&gt; &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;If you're having any issues with setting this up, feel free to contact me or leave a comment in the comment section, I'll get back to you as soon as possible.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Few to things to keep in mind: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your application goes to sleep after 30 minutes of being inactive&lt;/li&gt;
&lt;li&gt;Your app can't be online 24/7, otherwise you'll run out of your &lt;a href="https://devcenter.heroku.com/articles/free-dyno-hours"&gt;free Dyno hours&lt;/a&gt; - &lt;em&gt;If you choose to enter your credit card number, you will get extra 400-500 Dyno hours&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Metrics are not available for free users, you'll have to upgrade.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hosting your Java apps on Heroku, or other apps in general, is simply too easy and amazing. Even the paid plan offers extraordinary options and it would probably cost way more if you were to set it up yourself + considering the maintenance and security of the server.&lt;/p&gt;

&lt;p&gt;However, Heroku may not be the tool for every occasion and everyone in the development world. It has its pros and cons, so make sure to weight them in carefully before deciding.&lt;/p&gt;

&lt;p&gt;Until next time, stay awesome. &lt;/p&gt;

</description>
      <category>java</category>
      <category>heroku</category>
      <category>github</category>
      <category>devops</category>
    </item>
    <item>
      <title>I made a Hack Quiz in 48 hours.</title>
      <dc:creator>KristijanFištrek</dc:creator>
      <pubDate>Sat, 04 Jan 2020 14:12:41 +0000</pubDate>
      <link>https://forem.com/kristijanfistrek/2020-challenge-1-i-made-a-hack-quiz-in-48-hours-48fk</link>
      <guid>https://forem.com/kristijanfistrek/2020-challenge-1-i-made-a-hack-quiz-in-48-hours-48fk</guid>
      <description>&lt;h2&gt;
  
  
  Hack This Quiz
&lt;/h2&gt;

&lt;p&gt;In short, I wanted to challenge myself and I made a hacking quiz in 48 hours with Vanilla JavaScript and Firebase. &lt;/p&gt;

&lt;p&gt;Look at it here: &lt;a href="https://hackthisquiz.firebaseapp.com/"&gt;https://hackthisquiz.firebaseapp.com/&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  How to play?
&lt;/h4&gt;

&lt;p&gt;Basically, it's really simple.&lt;br&gt;
You need to insert a password to move forward and collect all the points.&lt;br&gt;
You are given a paragraph of text and occasionally a hint which helps you and directs you toward finding the correct password. &lt;/p&gt;

&lt;p&gt;Use any means and knowledge necessary in order to find a password! &lt;/p&gt;

&lt;h4&gt;
  
  
  Why?
&lt;/h4&gt;

&lt;p&gt;Obviously not to practice UX and UI. :D &lt;br&gt;
The application has a terrible UX and UI design, mainly because I wanted to focus on learning MVC in Vanilla JavaScript and most of how to handle Firebase for database management, user management, deploy and hosting purposes. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I want to challenge myself in 2020. to learn as much as I can about certain technologies. Coming up and completing these little challenges help me stay alert and sharp. &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Closing words
&lt;/h4&gt;

&lt;p&gt;Feel free to play it and make sure to tell me how'd you like it!&lt;br&gt;
I am opened to have a meaningful discussion about improvements, questions, UI/UX or any kind of advice you can think of.&lt;/p&gt;

&lt;p&gt;Let me know in the comments below if you've played it and let's chat about it!&lt;/p&gt;

&lt;p&gt;Have fun! \m/&lt;br&gt;
Stay awesome!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>firebase</category>
      <category>database</category>
    </item>
    <item>
      <title>JavaScript Design Patterns - Factory Pattern</title>
      <dc:creator>KristijanFištrek</dc:creator>
      <pubDate>Sun, 10 Nov 2019 16:33:24 +0000</pubDate>
      <link>https://forem.com/kristijanfistrek/javascript-design-patterns-factory-pattern-562p</link>
      <guid>https://forem.com/kristijanfistrek/javascript-design-patterns-factory-pattern-562p</guid>
      <description>&lt;p&gt;Welcome to my new development series where I try my best to explain design patterns by using &lt;strong&gt;JavaScript&lt;/strong&gt;!&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What is a design pattern?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In software engineering in general, a design pattern is a reusable solution, or better yet a blueprint or a template, that we can use in different situations and programming languages in order to solve every day development problems. &lt;br&gt;
They are formalized best practices which developers can follow when designing and developing a software application. &lt;br&gt;
Design patterns can speed up the development process by providing &lt;strong&gt;tested&lt;/strong&gt; and &lt;strong&gt;proven&lt;/strong&gt; development paradigms.&lt;/p&gt;

&lt;p&gt;There are different types of design patterns out there.&lt;/p&gt;

&lt;p&gt;Some of the main categories are : &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Creational patterns&lt;/li&gt;
&lt;li&gt;Structural patterns&lt;/li&gt;
&lt;li&gt;Behavioral patterns&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Today we will be discussing the &lt;em&gt;factory patterns&lt;/em&gt; which falls under the creational category. &lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Why should we use the factory pattern?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Factory pattern is often times used in situations where you need to deal with potential problems which occur when creating objects. &lt;br&gt;
Especially in situations where you need to create many different types of many different objects. &lt;/p&gt;

&lt;p&gt;In that case, factory pattern enables you to call a &lt;strong&gt;factory method&lt;/strong&gt; - specified in an interface or implemented in a base class - which handles the creation of objects instead of a constructor. &lt;br&gt;
By calling a &lt;strong&gt;factory method&lt;/strong&gt; you avoid reallocating memory for each object you create, instead a &lt;strong&gt;factory method&lt;/strong&gt; does that only once when it's called. &lt;/p&gt;

&lt;p&gt;To put it simply, our &lt;strong&gt;factory method&lt;/strong&gt; is a centralized place or better yet, a factory that manufactures different types of objects.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;How can I use a factory pattern?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Disclaimer - In this situation, you are free to use any of the design patterns you like and develop you own solution. I do not explicitly claim you should only use the factory pattern if you encounter a situation like this.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Let's imagine a following scenario.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You have been hired to develop an application for a car shop. The owner of the car shop wants an easy to navigate interface with the ability to document all the types of vehicles that he fixes in his shop. On a daily basis, through his and his employers hands pass around dozen different types of vehicles. You need to find a clean and concise way to insert all those types of cars into your database. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For this example, and since I've learning more about it in the past few months, we will be using &lt;strong&gt;JavaScript&lt;/strong&gt;.&lt;br&gt;
Important thing to notice is that these kind of patterns are not language specific, you can use them with any language you like. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First of, let's assume that our mechanic works only with &lt;strong&gt;trucks&lt;/strong&gt; and &lt;strong&gt;cars&lt;/strong&gt;. Even though there's a lot of different types of trucks and cars, let's limit ourselves, for the purposes of this tutorial, to only this 1st class hierarchy of our vehicles. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So with that in mind, let's create our two classes for those two categories of vehicles.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Truck&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

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



&lt;p&gt;This seems pretty primitive and basic, there are better ways of doing this with the &lt;strong&gt;class&lt;/strong&gt; keyword implemented in ECMA2015, but keep up with me.&lt;br&gt;
With these foundations structured, let's create our factory method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;VehiclesFactoryMethod&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;switch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Car&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
           &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
         &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Truck&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
           &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Truck&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
         &lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

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



&lt;p&gt;With our factory method in place, we are ready to use it for our object creation!&lt;br&gt;
Let's test that out.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// Let's instantiate our factory method object.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;VehiclesFactoryMethod&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;VehiclesFactoryMethod&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// This array will simulate our Database for the purposes of this tutorial&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;vehicles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

&lt;span class="c1"&gt;// Let's fill our array with some vehicles!&lt;/span&gt;
&lt;span class="nx"&gt;vehicles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;VehiclesFactoryMethod&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;BMW&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Car&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;vehicles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;VehiclesFactoryMethod&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MAN&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Truck&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

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



&lt;p&gt;Let's test this out! &lt;br&gt;
For further testing purposes, let's create a display function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// This function will output the inserted vehicles in a more stylized context &lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Database of our vehicles : &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Name: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Type: &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Let's loop through our array of vehicles &lt;/span&gt;
&lt;span class="c1"&gt;// And call **showVehicles*** method to print them out.&lt;/span&gt;
&lt;span class="nx"&gt;vehicles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;vehicle&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nx"&gt;print&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// If we have done everything correctly, this will be our console log output &lt;/span&gt;
&lt;span class="c1"&gt;// Database of our vehicles : &lt;/span&gt;
&lt;span class="c1"&gt;// Name: BMW&lt;/span&gt;
&lt;span class="c1"&gt;// Type: Car&lt;/span&gt;

&lt;span class="c1"&gt;// Database of our vehicles : &lt;/span&gt;
&lt;span class="c1"&gt;// Name: MAN&lt;/span&gt;
&lt;span class="c1"&gt;// Type: Truck&lt;/span&gt;

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



&lt;p&gt;With this setup, every time we want to create a new object of either a Car or Truck class, all we need to do is call our &lt;strong&gt;VehiclesFactoryMethod&lt;/strong&gt;, pass the needed attributes and the factory method will take care of all memory allocations and object creation you need. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Use the Factory Method when you don’t know beforehand the exact types and dependencies of the objects your code should work with.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the Factory Method when you want to save system resources by reusing existing objects instead of rebuilding them each time. You often experience this need when dealing with large, resource-intensive objects such as database connections, file systems, and network resources.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Pros : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You avoid tight coupling between the creator and the concrete products.&lt;/li&gt;
&lt;li&gt;Single Responsibility Principle. You can move the product creation code into one place in the program, making the code easier to support.&lt;/li&gt;
&lt;li&gt;Open/Closed Principle. You can introduce new types of products into the program without breaking existing client code.&lt;/li&gt;
&lt;li&gt;Memory preservation and greater control over your objects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cons : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As far as my experiences go with the factory method, the only con I've fond so far is that the code may become more complicated since you need to introduce a lot of new subclasses to implement the pattern. The best case scenario is when you’re introducing the pattern into an existing hierarchy of creator classes. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Should you use a factory method?&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Absolutely yes!
&lt;/h3&gt;

&lt;p&gt;It depends on you where and how you will use it. &lt;br&gt;
I have found it extremely useful in many cases. &lt;/p&gt;

&lt;p&gt;If you have known about the factory pattern before this article, comment down below where and how are you using it.&lt;br&gt;
I'd like to know more about it and discuss about potential improvements. &lt;/p&gt;

&lt;p&gt;See you next Sunday when we will go through another design pattern! &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>design</category>
      <category>patterns</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Angular - Let's build an app together | Part 1</title>
      <dc:creator>KristijanFištrek</dc:creator>
      <pubDate>Tue, 27 Aug 2019 10:01:51 +0000</pubDate>
      <link>https://forem.com/kristijanfistrek/angular-let-s-build-an-app-together-part-1-13o4</link>
      <guid>https://forem.com/kristijanfistrek/angular-let-s-build-an-app-together-part-1-13o4</guid>
      <description>&lt;p&gt;Hi there again guys &amp;amp; gals of Dev.to!&lt;/p&gt;

&lt;p&gt;Welcome to the first part of the series ,,&lt;strong&gt;&lt;em&gt;Let's build an app together&lt;/em&gt;&lt;/strong&gt;'' where I'll do my best to take you through the process of building a REST API Angular application.&lt;/p&gt;

&lt;p&gt;I am not an expert when it comes to Angular, so feel free to correct me down below.&lt;/p&gt;

&lt;p&gt;Without further ado, let's start!&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Table of contents&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;What we will be building&lt;/li&gt;
&lt;li&gt;Setting up the environment&lt;/li&gt;
&lt;li&gt;Hello world&lt;/li&gt;
&lt;li&gt;Setting up the project&lt;/li&gt;
&lt;li&gt;Design&lt;/li&gt;
&lt;li&gt;Modeling your JSON data &amp;amp; display&lt;/li&gt;
&lt;li&gt;Additional tips &amp;amp; tricks&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. What we will be building&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In short, we will be building an application that will receive data using NASA's open API. We'll be using some cool features that the API offers and we'll display some data on the screen. &lt;/p&gt;

&lt;p&gt;Pretty cool stuff!&lt;/p&gt;

&lt;p&gt;Take a look at the final product :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7969rlmcrgdgzkw6eja5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7969rlmcrgdgzkw6eja5.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bear in mind that I am not a grand designer, and I primarily want to focus on the logic and the most appropriate way of handling the data, you're free to design your UI in any way you want to.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2. Setting up the environment&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;First things first. &lt;/p&gt;

&lt;p&gt;In order to create your Angular application, you need to have Node.js installed locally. &lt;/p&gt;

&lt;p&gt;To do that successfully, follow these steps : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visit &lt;a href="https://nodejs.org/en/download/" rel="noopener noreferrer"&gt;https://nodejs.org/en/download/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Install version 10.9.0 or later.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why are we doing that?&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Well according to Angular Wiki and a bunch of other articles online, the reasons for Node.js &amp;amp; Angular 2 combo are as follows : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Node.js&lt;/strong&gt; includes &lt;strong&gt;NPM&lt;/strong&gt;, we need &lt;strong&gt;NPM&lt;/strong&gt; because most of &lt;strong&gt;Angular 2&lt;/strong&gt; packages or libraries are distributed as different NPM packages. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Angular 2&lt;/strong&gt; mostly works with Typescript. Browsers can not understand Typescript syntax, therefore we need &lt;strong&gt;NPM&lt;/strong&gt; in combination with &lt;strong&gt;Angular CLI&lt;/strong&gt; to compile the Typescript into plain good old JavaScript.&lt;/li&gt;
&lt;li&gt;We will be using &lt;strong&gt;Angular CLI&lt;/strong&gt; to automate all the compiling, building and minimizing, and that is where certain &lt;strong&gt;NPM&lt;/strong&gt; commands will come in handy! &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can read more on : &lt;a href="https://www.angularjswiki.com/angular/is-node-js-required-for-angular-2-or-angular/" rel="noopener noreferrer"&gt;https://www.angularjswiki.com/angular/is-node-js-required-for-angular-2-or-angular/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To make sure we've installed &lt;strong&gt;Node.js&lt;/strong&gt; , and with it the famous NPM environment, try this : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run &lt;strong&gt;npm -v&lt;/strong&gt; in your console to make sure the installation was successful. 
You should get the result similar as in this picture below : &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fhorun46cr8r0kuw9o339.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fhorun46cr8r0kuw9o339.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the version of &lt;strong&gt;npm&lt;/strong&gt; is displayed, congratulations, you just installed node.js!&lt;/p&gt;

&lt;p&gt;P.S. - Yes. I'm one of those Linux nerds.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3. Hello World&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Let's open our consoles/terminals/command prompts one more time ladies and gentlemen!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open your terminal and type in &lt;strong&gt;cd *desired location&lt;/strong&gt;* where as the &lt;strong&gt;desired location&lt;/strong&gt; is the folder inside of which you will create your new Angular application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fchpaalkz65jjm6h4kmiq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fchpaalkz65jjm6h4kmiq.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1)&lt;/strong&gt; Let's install our &lt;strong&gt;Angular CLI&lt;/strong&gt; by typing the following command into our terminal :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g @angular/cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the version of your &lt;strong&gt;Angular CLI&lt;/strong&gt; by typing the following command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should get something like this : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F3265n0dm49aq917e45vb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F3265n0dm49aq917e45vb.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you get this kind of output, we're halfway there to fully setup our project!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2)&lt;/strong&gt; We can easily create the default instance of our application by using the following command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng new ourNasaAPP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's recap this command very shortly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ng&lt;/strong&gt; is the basically a built in directive which in short stands for ,,&lt;em&gt;Angular&lt;/em&gt;''. &lt;br&gt;
&lt;strong&gt;new&lt;/strong&gt; is another built in directive which will tell our Angular CLI that we would like to create a new default instance of our application.&lt;br&gt;
&lt;strong&gt;ourNasaAPP&lt;/strong&gt; that is just a name we'll give to this application.&lt;/p&gt;

&lt;p&gt;After we type in &lt;strong&gt;ng new ourNasaAPP&lt;/strong&gt; we'll have to go through a short process of successfully defining our default app. &lt;/p&gt;

&lt;p&gt;The process should go something like this : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a default instance of your app with &lt;strong&gt;ng new&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fipn8kucx7h2wox2qohzc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fipn8kucx7h2wox2qohzc.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When asked about the routing, select yes by typing &lt;strong&gt;y&lt;/strong&gt; and pressing Enter. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fo8diolwxa8mfevffheo2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fo8diolwxa8mfevffheo2.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's select &lt;strong&gt;SCSS&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fd9ahjpbujjzaecc81jff.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fd9ahjpbujjzaecc81jff.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;By selecting SCSS, Angular CLI will start building your default Angular project and you should see something similar to this when it is done : &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnugrot5zou5cpoeuqevt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnugrot5zou5cpoeuqevt.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You might get some warnings by default, certain npm packages may not like something, but essentially if you don't get critical errors or your application to instantiate, you shall be fine. &lt;/p&gt;

&lt;p&gt;We can check if our project instantiated properly by typing the following command , which will start your application and open it in your default browser :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng serve --open
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see something like this : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fz7812i0c83th7gl3ux2g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fz7812i0c83th7gl3ux2g.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you get this screen, congratulations! &lt;br&gt;
You just created your first Angular application!&lt;/p&gt;

&lt;h3&gt;
  
  
  Closing words
&lt;/h3&gt;

&lt;p&gt;With this I would like to conclude the first part of this series. &lt;/p&gt;

&lt;p&gt;Getting into further functionalities opens up a whole new spectrum of development that I would like to keep for upcoming parts. &lt;/p&gt;

&lt;p&gt;I certainly hope you have found this helpful and useful. &lt;/p&gt;

&lt;p&gt;A lot of interesting things are coming next! &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What's next?&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Setting up the project &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this section we'll explore what we need to properly handle API responses and so to speak model our data within the application.&lt;br&gt;
We will take a closer look into models, components and services. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Design &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will take a look at the most appropriate design according to the data we shall receive. &lt;br&gt;
We'll dive into how to setup NGX-Bootstrap and use some its awesome features!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modeling your data &amp;amp; display&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We might touch upon the subject of modeling your data in the &lt;strong&gt;Let's Build An App Together part 2&lt;/strong&gt;.&lt;br&gt;
If not, it will certainly be included in the &lt;strong&gt;part 3&lt;/strong&gt; of the series.&lt;br&gt;
This section is reserving to further explain how we will build our models, services and components. &lt;br&gt;
We will touch about the best practices in modeling your API data and I will show you the way I am doing it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Join me in part 2 - coming soon!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>What cleaning my room taught me about programming.</title>
      <dc:creator>KristijanFištrek</dc:creator>
      <pubDate>Tue, 30 Jul 2019 09:04:15 +0000</pubDate>
      <link>https://forem.com/kristijanfistrek/what-cleaning-my-room-taught-me-about-programming-3ajn</link>
      <guid>https://forem.com/kristijanfistrek/what-cleaning-my-room-taught-me-about-programming-3ajn</guid>
      <description>&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I am still learning how to organize my projects. &lt;br&gt;
I am in no way an expert and my advice should be taken with a grain of salt. I have however noticed certain problems with my previous setup, I've adjusted it and immediately saw improvements. &lt;br&gt;
I'd like to share my story and hopefully help some of you. &lt;br&gt;
Feel free to leave your advice down below if you see something stinky&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Foreword&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;We've probably all heard the famous saying : ,,&lt;em&gt;Go and clean your room!&lt;/em&gt;'' &lt;br&gt;
And probably all of us, sometimes in our lives, have answered : &lt;br&gt;
,,&lt;em&gt;I can't right now! I'm like doing something really, really important!&lt;/em&gt;''. &lt;/p&gt;

&lt;p&gt;As a self-proclaimed ''&lt;em&gt;creative&lt;/em&gt;'' person, I have defended my creative mess with all my strength. &lt;br&gt;
I've explained in thorough detail how 20 layers of t-shirts across my chair actually helps my everyday decision making and how my table is not messy, it is perfectly organized in well thought-out sections that speed up my process of finding things. &lt;/p&gt;

&lt;p&gt;But the harsh truth about creative mess hit me on top of my head many years down the line. &lt;br&gt;
I've been told that creative mess, at the end of the day, is still a mess.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnprch23l62jh6j4ibf8k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnprch23l62jh6j4ibf8k.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Me&lt;/strong&gt; : ,,&lt;em&gt;How dare they, those pathetic simpletons will never grasp the astronomical importance and the technical complexity with which I'm conducting these creative procedures that enable me the efficiency and productivity of nothing short of a God!&lt;/em&gt;'' &lt;br&gt;
I humbly thought to myself.&lt;/p&gt;

&lt;p&gt;As my view has once again fallen upon the creatively designed 20 layers of t-shirt lounge chair, a small voice from the back of my head whispered : ,,&lt;em&gt;Maybe they're right...''&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;And unfortunately, they &lt;strong&gt;were&lt;/strong&gt; right.&lt;/p&gt;

&lt;p&gt;With watery eyes, I mumbled : ,,&lt;em&gt;Goodbye, 20 layer/high profile/one of a kind/customized lounge chair worthy of nothing short of a God...goodbye.&lt;/em&gt;''.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Table of contents&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Illusion of a clean work space&lt;/li&gt;
&lt;li&gt;What happens now?&lt;/li&gt;
&lt;li&gt;Examples&lt;/li&gt;
&lt;li&gt;Closing words&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1.Illusion of a clean work space&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Don't get me wrong, creative mess is a wonderful thing, until someone other than you needs something from it. &lt;br&gt;
I still remember when I tried to navigate my brother, over a 20 minute phone call, to read some numbers off of the specific document buried away in my room. &lt;/p&gt;

&lt;p&gt;All things have a tendency of succumbing to entropy, even more so if those things are not taken care of.&lt;/p&gt;

&lt;p&gt;I had the uncomfortable privilege of experiencing such fate with software projects, mostly my own. &lt;/p&gt;

&lt;p&gt;At the beginning of a project, be it a bigger software application or a smaller website, sooner or later the code will pile up. &lt;br&gt;
As little bits of your code are being added in your application over a longer period of time, you don't have a feeling like things are getting messier, just like the frog doesn't experience water getting slightly warmer, until it's cooked alive. Too dark, Kristijan...too dark. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But how should I know before hand how to organize my projects? &lt;br&gt;
I don't want to be cooked alive!&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;No worries, young padawan. &lt;br&gt;
I am here to tell you that...I have no idea. &lt;br&gt;
Like, I'm still learning this stuff myself, it depends...it's super hard...I can't even...I mean, where to start?&lt;/p&gt;

&lt;p&gt;Nahh, I'm just kidding...well, not entirely.&lt;/p&gt;

&lt;p&gt;Organization of your projects and how detailed it must be definitely depends on the technology you're using, how robust the application is and definitely on how many people are working on it. &lt;br&gt;
There isn't &lt;em&gt;one size fits all&lt;/em&gt; in this case, unfortunately. &lt;/p&gt;

&lt;p&gt;But what I have noticed as a consistency, throughout the projects I was working on, is the collaborative effect of the team in establishing the architecture, the scale of it and defining the necessary steps that each developer can follow in order to write better, consistent and clean code while keeping the file structure concise and neat.&lt;/p&gt;

&lt;p&gt;If I can sum it up in a few steps, it would be : &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Talk first, code later&lt;/li&gt;
&lt;li&gt;Clearly define the architecture and the necessary tools&lt;/li&gt;
&lt;li&gt;Write down, if you have to, the rules that ensure consistency and clean environment according to the predefined architecture&lt;/li&gt;
&lt;li&gt;Don't crash and burn
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2.What happens now?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Taken into account the steps I've aforementioned, let's put it in perspective. &lt;/p&gt;

&lt;p&gt;Recently I've marched into a project, which I'll post more about here pretty soon, that is in-visioned to unify Nasa API's in one place. &lt;br&gt;
This is my story.&lt;/p&gt;

&lt;p&gt;1) &lt;em&gt;Talk first, code later&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;By talking about the project, you put yourself in a different position. &lt;br&gt;
Preferably in a position of someone who will be using the app, since we as developers often get stuck in a mindset of someone creating the app.&lt;/p&gt;

&lt;p&gt;You discover new angles from which you can tackle certain problems and hopefully start thinking about design that is suited for the users, not the design that you want to see. &lt;/p&gt;

&lt;p&gt;With that in mind, I wrote down the key points of my application, alongside with the key issues that I will potentially face. &lt;br&gt;
Of course, you can not cover every little detail in this segment, but it's kinda important to set the proper base of your project, upon which you can fluently build every future release.&lt;/p&gt;

&lt;p&gt;2) &lt;em&gt;Clearly define the architecture and the necessary tools&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Architecture was supposed to be designed in a way where we could efficiently and fluently grab the results from the API, map it to our predefined models, functionally sort the data and feed it to the front end. &lt;br&gt;
That communication needed to be as fast, fluent and clean as possible.&lt;/p&gt;

&lt;p&gt;During the talk bit, we clearly all agreed upon using Java Spring on the back-end and &lt;strong&gt;Angular 7&lt;/strong&gt; as our main front-end tool (triggered comments ahead). Even though it can be robust at times and it definitely serves more as a tool to handle big enterprise applications, it perfectly met the requirements and needs we all had. &lt;/p&gt;

&lt;p&gt;Just a heads up, not a line of code was written yet.&lt;/p&gt;

&lt;p&gt;3) &lt;em&gt;Write down, if you have to, the rules that ensure consistency and clean environment according to the predefined architecture&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Immediately, the clear and concise &lt;strong&gt;Git&lt;/strong&gt; flow instructions were written down. &lt;br&gt;
Source control is a major thing and a quality &lt;strong&gt;Git&lt;/strong&gt; flow can really save the day down the line. &lt;/p&gt;

&lt;p&gt;Alongside of that, agreement was made regarding how our folders should be structured and what the naming convention shall be. &lt;/p&gt;

&lt;p&gt;An example of our app folder is as follows : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzcl8dbr08jkle1wx7ypm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzcl8dbr08jkle1wx7ypm.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;It is slightly different at the current stage&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Therefore, everyone was able to easily orient themselves within a project and maneuver their way through the application. &lt;/p&gt;

&lt;p&gt;Everyone was informed and on-board regarding the naming conventions and logic flow of the application, which means we all followed the hierarchical rules about what our services should do, how our components should look like - &lt;em&gt;or in the case of Angular, how dumb should they be&lt;/em&gt; - and last but not least, how our syntax would look like. &lt;/p&gt;

&lt;p&gt;We've also used tools like &lt;em&gt;Prettier&lt;/em&gt; to keep our TypeScript/Javascript syntactically consistent + tools like &lt;em&gt;Husky&lt;/em&gt; &amp;amp; E2E test tools to make sure our code is somewhat bulletproof - I'll touch upon this subject a bit more in future posts. &lt;/p&gt;

&lt;p&gt;4) &lt;em&gt;Don't crash and burn&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Seriously, it's easy to get tangled up in all the procedures, workflows and get burned by the process of trying to make everything perfect. &lt;br&gt;
It's nearly impossible to predict everything, it is crucial for you to remember that mistakes will find their way into your projects and you will inevitably have to go back and fix some things. &lt;/p&gt;

&lt;p&gt;Don't stress too much about it. Know that you're doing your best and keep at it. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3.Examples&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you are further more interested in the subject, check out the links below for further detail : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thehelloworldprogram.com/web-development/creating-files-folder-structure-web-pages/" rel="noopener noreferrer"&gt;https://thehelloworldprogram.com/web-development/creating-files-folder-structure-web-pages/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/Dealing_with_files" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/Dealing_with_files&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://softwareengineering.stackexchange.com/questions/176803/how-to-organize-my-sites-file-system-properly" rel="noopener noreferrer"&gt;https://softwareengineering.stackexchange.com/questions/176803/how-to-organize-my-sites-file-system-properly&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://onextrapixel.com/building-web-apps-file-and-directory-structures/" rel="noopener noreferrer"&gt;https://onextrapixel.com/building-web-apps-file-and-directory-structures/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/24199004/best-practice-to-organize-javascript-library-css-folder-structure" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/24199004/best-practice-to-organize-javascript-library-css-folder-structure&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I've applied this principle to the smallest of my projects.&lt;br&gt;
For example, my web portfolio, which is composed of only HTML, SCSS and Vanilla Javascript, has the following structure : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzanuw6bjm2lfqchrmcju.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzanuw6bjm2lfqchrmcju.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now if anyone needs to get into my room, figuratively speaking, and needs to do some adjustments in my &lt;em&gt;services&lt;/em&gt; part of the room, he or she would be able to do so effortlessly. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Closing words&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What is the connection between your room and your code?&lt;br&gt;
I still don't get it man.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I talk a lot. Let me summarize. &lt;/p&gt;

&lt;p&gt;As I started to keep my living environment in check, suddenly like the stars aligned, I gained greater insight how everything is at the length of my hand and I knew where every little thing is. &lt;br&gt;
Finally I didn't have to spend too much time looking for trivial things, and most importantly, if anyone needed anything from my room, it was extremely accessible and organized. &lt;/p&gt;

&lt;p&gt;The same principles, in my humble opinion, should be applied to our software projects. &lt;/p&gt;

&lt;p&gt;Sooner or later someone will inherit your code. &lt;br&gt;
Make sure it represents your coding skills as much as your organization skills. &lt;br&gt;
Keep your room clean. &lt;/p&gt;

</description>
      <category>productivity</category>
      <category>devops</category>
      <category>webdev</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Javascript pattern that changed everything (for me...)</title>
      <dc:creator>KristijanFištrek</dc:creator>
      <pubDate>Sun, 28 Jul 2019 11:10:47 +0000</pubDate>
      <link>https://forem.com/kristijanfistrek/javascript-pattern-that-changed-everything-for-me-4cfa</link>
      <guid>https://forem.com/kristijanfistrek/javascript-pattern-that-changed-everything-for-me-4cfa</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;Foreword&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Hello there good people of Dev.to &amp;amp; welcome to my first Dev.to post!&lt;br&gt;
I've been a member of this community for a while and finally decided to contribute &amp;amp; share my thoughts about a subject I'm passionate about.&lt;/p&gt;

&lt;p&gt;I am still learning all the ways in which I can use the forthcoming pattern, so feel free to correct me down below if you see something stinky.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F0itpe03ifven1ssth3oq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F0itpe03ifven1ssth3oq.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;What will this post be about?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A short table of contents :&lt;/p&gt;

&lt;p&gt;1) What is IIFE?&lt;br&gt;
2) JS pattern that changed everything...&lt;br&gt;
  2.1) Advantages&lt;br&gt;
  2.2) Disadvantages&lt;br&gt;
3) Examples&lt;br&gt;
4) Closing words&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's get into it!&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;1. IIFE&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Before we head into explaining any sort of javascript design pattern, I think it's worth mentioning IIFE.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is IIFE?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;IIFE stands for &lt;em&gt;immediately-invoked function expression&lt;/em&gt; or Self-Executing Anonymous Function.&lt;br&gt;
In simple terms, it is a block of code that is invoked or called as soon as the file is executed. &lt;br&gt;
And it looks something like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="p"&gt;})();&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;In not so simple terms, it is a way of encapsulating your functions within a scope that will keep it away from the global scope, which might be a tricky place in the javascript world.&lt;/p&gt;

&lt;p&gt;It consists of primarily two parts :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First part is an anonymous functions enclosed within a grouping operator &lt;strong&gt;()&lt;/strong&gt; which limits the access to your data within the function and as we said before, keeps it away from the global scope.&lt;/li&gt;
&lt;li&gt;The second part creates the immediately executing function expression &lt;strong&gt;();&lt;/strong&gt; through which the JavaScript engine will directly interpret the function.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you're curious about it and want to learn more, since I want to put emphasis on the javascript patterns here, you can read more on : &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/IIFE?source=post_page---------------------------" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Glossary/IIFE?source=post_page---------------------------&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2. Javascript pattern that changed everything&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A pattern that changed everything, at least for me, is : &lt;em&gt;drumroll&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Revealing module pattern&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;_setName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;My name is : Slim Shady&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="na"&gt;init&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;_setName&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="p"&gt;})();&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;You might see something familiar, and if your guess is IIFE, then you're completely correct.&lt;/p&gt;

&lt;p&gt;Revealing module pattern, just like many other javascript patterns, takes advantage of IIFE to hide the functionalities of your code from the global scope, and enable you more consistency and re-usability.&lt;/p&gt;

&lt;p&gt;All the properties you declare within the IIFE scope are inherently private, and you decide what you will expose to the outside in the &lt;strong&gt;return&lt;/strong&gt; segment of our code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now let's break down our example from above.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1) We've declared an object by the name of &lt;em&gt;module&lt;/em&gt; and we've saved in it a reference to whatever our IIFE function holds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="p"&gt;})();&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;2) The next step is to create our private function by the name of &lt;strong&gt;_setName()&lt;/strong&gt; which in our case outputs a generic result.&lt;br&gt;
I prefer to name my private properties with an underscore, it helps me to differentiate them from the rest and makes the debbuging easier.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;_setName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;My name is : Slim Shady&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;})();&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;3) The crucial segment of our example comes in a form a &lt;strong&gt;return&lt;/strong&gt; statement, where we reveal the functionality of our private properties as public. &lt;/p&gt;

&lt;p&gt;Since in this example we only have one private property, we shall have only one public property, although examples may vary depending on the complexity of your function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;_setName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;My name is : Slim Shady&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="na"&gt;init&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;_setName&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;})();&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;The final step is calling whatever we need through our &lt;strong&gt;module&lt;/strong&gt; object.&lt;/p&gt;

&lt;p&gt;By calling our &lt;strong&gt;module&lt;/strong&gt; object we can access everything we've returned as public in our &lt;em&gt;return&lt;/em&gt; scope.&lt;/p&gt;

&lt;p&gt;Therefore if we type &lt;strong&gt;module.init()&lt;/strong&gt; , in our console we will see the console log from the &lt;strong&gt;_setName()&lt;/strong&gt; function.&lt;br&gt;
That's because our &lt;em&gt;init&lt;/em&gt; property stores whatever value &lt;strong&gt;_setName&lt;/strong&gt; function might hold.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;module&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;_setName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;My name is : Slim Shady&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="na"&gt;init&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;_setName&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;})();&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Console log&lt;/span&gt;
&lt;span class="c1"&gt;// My name is : Slim Shady&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;For further information that expand beyond this simple example, check out the links below for in depth analysis of &lt;em&gt;revealing module pattern&lt;/em&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://addyosmani.com/resources/essentialjsdesignpatterns/book/#revealingmodulepatternjavascript" rel="noopener noreferrer"&gt;https://addyosmani.com/resources/essentialjsdesignpatterns/book/#revealingmodulepatternjavascript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gist.github.com/zcaceres/bb0eec99c02dda6aac0e041d0d4d7bf2" rel="noopener noreferrer"&gt;https://gist.github.com/zcaceres/bb0eec99c02dda6aac0e041d0d4d7bf2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developerslogblog.wordpress.com/2017/11/05/javascript-quick-guide-to-the-revealing-module-pattern/" rel="noopener noreferrer"&gt;https://developerslogblog.wordpress.com/2017/11/05/javascript-quick-guide-to-the-revealing-module-pattern/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The big advantage of this pattern is the fact that it allows the syntax of our scripts to be more consistent. It also makes it more clear at the end of the module which of our functions and variables may be accessed publicly which eases readability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An uncomfortable disadvantage of this pattern is that if a private function refers to a public function, that public function can't be overridden if a patch is necessary. This is because the private function will continue to refer to the private implementation and the pattern doesn't apply to public members, only to functions.&lt;/p&gt;

&lt;p&gt;So care should be taken during the usage of this pattern, because modules created with the Revealing Module pattern may be more fragile than those created with the original Module pattern.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3. Examples&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Here are some of the examples of module revealing pattern in use.&lt;br&gt;
Some examples are the direct usage of MRT in some of my projects, and some of them are made up on the spot. &lt;/p&gt;

&lt;p&gt;Hopefully you'll find them helpful!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example #1 - The footer component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This piece of code displays a module revealing pattern that holds the structure of a footer, and basically creates a component which you can re-use throughout your website and save yourself a couple of lines of HTML code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;footer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;_footerDesign&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;html&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;div class="footer-content text-center"&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;html&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;small&amp;gt;&amp;lt;b&amp;gt;Copyright &amp;amp;copy; Kristijan Fištrek&amp;lt;/b&amp;gt;&amp;lt;/small&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;html&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;render&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;footerContainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;footer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;footerContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;_footerDesign&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;init&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;render&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;})();&lt;/span&gt;

&lt;span class="nx"&gt;footer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example #2 - Data storage&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This examples portraits a way of defining a certain data set and keeping it structure private. &lt;br&gt;
The only public aspect of it is the object that is returned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;blogsContainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;blogs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Welcome to my first blog!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Allow me to introduce myself &amp;amp; the content you can expect from me in my blogs. Primarily I will focus on delivering tech driven content, mostly about web development, but I have few ideas about project organization, agile methodology &amp;amp; much more!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;imgURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;assets/img/blogs/1.Welcome/1.Welcome-header.jpg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pages/blogs/welcome-blog.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;initialize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;contentOfBlogs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;blogs&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;contentOfBlogs&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;initialize&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})();&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example #3 - Addy Osmani example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;myRevealingModule&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;privateCounter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;privateFunction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;privateCounter&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;publicFunction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;publicIncrement&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;publicIncrement&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;privateFunction&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;publicGetCount&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;privateCounter&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// Reveal public pointers to&lt;/span&gt;
        &lt;span class="c1"&gt;// private functions and properties&lt;/span&gt;

       &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;publicFunction&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;publicIncrement&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;publicGetCount&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="p"&gt;})();&lt;/span&gt;

&lt;span class="nx"&gt;myRevealingModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;4. Closing words&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;I apologize for the long post, I really wanted to cover everything I considered important.&lt;br&gt;
Since this is my first time writing anything on Dev.to, I believe a couple of mistakes have found their way into the content despite my relentless care. &lt;/p&gt;

&lt;p&gt;Revealing module pattern is a powerful tool that should be used wisely, it is not perfect for every occasion, but it might prove itself useful in many others. &lt;/p&gt;

&lt;p&gt;How did you like this lesson?&lt;br&gt;
Do you think I covered enough?&lt;br&gt;
What else would you like for me to cover?&lt;/p&gt;

&lt;p&gt;Let's talk down below.&lt;/p&gt;

&lt;p&gt;Cheers people, happy coding.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>design</category>
      <category>oop</category>
    </item>
    <item>
      <title>Web components </title>
      <dc:creator>KristijanFištrek</dc:creator>
      <pubDate>Tue, 18 Jun 2019 16:28:45 +0000</pubDate>
      <link>https://forem.com/kristijanfistrek/web-components-5c37</link>
      <guid>https://forem.com/kristijanfistrek/web-components-5c37</guid>
      <description>&lt;p&gt;I recently really got into web components.&lt;/p&gt;

&lt;p&gt;What is your opinion about them?&lt;br&gt;
Good? Bad? Useful? Over-engineering? &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>webcomponents</category>
      <category>html</category>
    </item>
    <item>
      <title>Angular (click) - multiple functions? </title>
      <dc:creator>KristijanFištrek</dc:creator>
      <pubDate>Fri, 14 Jun 2019 15:10:01 +0000</pubDate>
      <link>https://forem.com/kristijanfistrek/angular-click-multiple-functions-3o2g</link>
      <guid>https://forem.com/kristijanfistrek/angular-click-multiple-functions-3o2g</guid>
      <description>&lt;p&gt;Scenario&lt;br&gt;
-&amp;gt; on click of a button you need to check data from two functions with (click) attribute.&lt;/p&gt;

&lt;p&gt;Do you :&lt;br&gt;
A) create a third function which encapsulates the two &amp;amp; pass that in the (click).&lt;br&gt;
Example : (click)="thirdFunction()"&lt;br&gt;
B) you pass both of them.&lt;br&gt;
Example : &lt;br&gt;
(click)="first(); second();"&lt;/p&gt;

&lt;p&gt;What seems to be the best practice for you? &lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
