<?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>DEV Community: The Unfactoring Guru</title>
    <description>The latest articles on DEV Community by The Unfactoring Guru (@the_unfactoring_guru).</description>
    <link>https://dev.to/the_unfactoring_guru</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%2F650715%2F904009e1-fdae-438e-acbf-7b45a6a44dc1.png</url>
      <title>DEV Community: The Unfactoring Guru</title>
      <link>https://dev.to/the_unfactoring_guru</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/the_unfactoring_guru"/>
    <language>en</language>
    <item>
      <title>Godot Docs Simplified: Part 0 Introduction</title>
      <dc:creator>The Unfactoring Guru</dc:creator>
      <pubDate>Mon, 19 Dec 2022 07:39:04 +0000</pubDate>
      <link>https://dev.to/the_unfactoring_guru/godot-docs-simplified-0-introducion-20b0</link>
      <guid>https://dev.to/the_unfactoring_guru/godot-docs-simplified-0-introducion-20b0</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This is mostly just a simplified and digestable series for you to understand what Godot is the simplest way possible.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Godot?
&lt;/h3&gt;

&lt;p&gt;Godot is a general purpose game development engine. You can develop 2D and 3D games for Desktop, Smartphone, or for the Web.&lt;/p&gt;

&lt;p&gt;You can also create applications that need an interactive GUI.&lt;/p&gt;

&lt;h3&gt;
  
  
  Games and Apps made with Godot
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Ex-Zodiac&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp374moc2d2bml5wjhklq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp374moc2d2bml5wjhklq.png" alt="alt Ex-zodiac" width="640" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pixelorama: PixelArt tool&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7enmgol8ufh5bnsvycrs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7enmgol8ufh5bnsvycrs.png" alt="alt Pixelorama" width="720" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RPG in a Box: RPG Voxel game builder&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fup700clpa86msl4erlux.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fup700clpa86msl4erlux.png" alt="alt RPG in a Box" width="720" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Aspect
&lt;/h3&gt;

&lt;p&gt;Just like your typical game engine: tilemaps, resources, textures, etc.:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9kncrr0p8yx3xhb9sll.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9kncrr0p8yx3xhb9sll.png" alt="alt Godot" width="800" height="426"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Programming Languages
&lt;/h3&gt;

&lt;p&gt;For editing purposes you can use &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;VSCode&lt;/a&gt; and &lt;a href="https://www.gnu.org/software/emacs/" rel="noopener noreferrer"&gt;Emacs&lt;/a&gt; for GDScrpt or C# development. Also Godot supports animations from 3D &lt;a href="https://www.blender.org/" rel="noopener noreferrer"&gt;Blender&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What do you need to learn Godot
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Fundamental Code Experience (&lt;em&gt;OOP, DataStructures, Algorithms&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;These fundamentals can be self-taught on this free &lt;a href="https://cs50.harvard.edu/x" rel="noopener noreferrer"&gt;Harvard Course&lt;/a&gt; for Computer Science Fundamentals.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>symfony</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Complete Phaser 3 Game Development Guide: Part 0.5 (Bundling and Compiling)</title>
      <dc:creator>The Unfactoring Guru</dc:creator>
      <pubDate>Mon, 04 Apr 2022 18:08:50 +0000</pubDate>
      <link>https://dev.to/the_unfactoring_guru/complete-phaser-3-game-development-guide-part-05-bundling-and-compiling-3an9</link>
      <guid>https://dev.to/the_unfactoring_guru/complete-phaser-3-game-development-guide-part-05-bundling-and-compiling-3an9</guid>
      <description>&lt;p&gt;This article is part of the "Complete Phaser 3 Game Development Guide" series, if you haven't installed Phaser 3 into your game project go to &lt;a href="//www.example.com"&gt;Part 0&lt;/a&gt;. Also this is a &lt;strong&gt;required&lt;/strong&gt; section if you are using commonjs to require the Phaser 3 library.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's this about?
&lt;/h2&gt;

&lt;p&gt;Since Phaser 3 is a front-end library, the files that we include inside our game file need to be included in the main html file we are using. The problem is, the &lt;code&gt;require&lt;/code&gt; function is used to import libraries using Node.js and since html doesn't execute code without the use of a browser (hence not using Node.js), this will cause an error in our game not compiling properly or at all!&lt;/p&gt;

&lt;p&gt;To solve this, the lovely developer community created tools that &lt;strong&gt;bundle&lt;/strong&gt; your Node.js libraries into normal Javascript files that your browser can execute.&lt;/p&gt;

&lt;p&gt;In this part of the guide we will complete the following tasks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install a Bundling Tool&lt;/li&gt;
&lt;li&gt;Bundling Code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After this you can go ahead to &lt;a href="//www.example.com"&gt;Part 1&lt;/a&gt; and continue the tutorial.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a&gt;&lt;/a&gt;Installing Bundling Tool
&lt;/h2&gt;

&lt;p&gt;There are a bunch of bundling tools that are used to convert Node.js code into normal Javascript code. The most popular and complete tool is called &lt;strong&gt;webpack&lt;/strong&gt;, but it's a "bit to much" for beginners. In this tutorial we will use &lt;strong&gt;browserify&lt;/strong&gt;, mostly because of it's simplicity (even though the creator of Phaser doesn't like it...).&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbzds7y4j8n9ggxuwne37.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbzds7y4j8n9ggxuwne37.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Regardless of this, it's a great beginner tool to start with, later (if you want of course) you can move into &lt;strong&gt;webpack&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To install browserify you just need to use npm and write:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install --save-dev browserify&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;on console and install it as development dependency.&lt;/p&gt;

&lt;p&gt;And that's it!&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a&gt;&lt;/a&gt; Bundling Code
&lt;/h2&gt;

&lt;p&gt;After installing browserify as a dependency in your project you can bundle your code with the following command.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx browserify game.js -o bundle.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Assuming your game is inside a file named game.js, the following command takes your game file (game.js) where you have Phaser 3 included, bundles it and outputs a file called bundle.js (this happens because we used the &lt;code&gt;-o&lt;/code&gt; or &lt;code&gt;--outfile&lt;/code&gt; option).&lt;/p&gt;

&lt;p&gt;Now instead of including your game.js (that basically uses Node.js libraries) inside your html file, you include your bundle.js into your library.&lt;/p&gt;

&lt;p&gt;Basically this works because browserify includes EVERYTHING from the required library into a single Javascript file including your game.js code so that your browser can execute it. This is why it's called &lt;strong&gt;"bundling"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And that's it!!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Optionally&lt;/strong&gt;: Since it's so tedious to bundle your game every time you edit something, you can install &lt;strong&gt;watchify&lt;/strong&gt; which works exactly the same as browserify, but your bundle.js file is updated everytime you save your game.js file.&lt;/p&gt;

&lt;p&gt;Install with the following:&lt;br&gt;
&lt;code&gt;npm install --save-dev watchify&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Run with the following:&lt;br&gt;
&lt;code&gt;npx watchify game.js -o bundle.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And that's basically it for this section! If you feel comfortable, you can now move on to &lt;a href="//www.example.com"&gt;Part 1&lt;/a&gt; where we create our first "Hello World" in Phaser 3!&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>html</category>
    </item>
    <item>
      <title>Complete Phaser 3 Game Development Guide: Part 0 (Installation and Importing)</title>
      <dc:creator>The Unfactoring Guru</dc:creator>
      <pubDate>Fri, 01 Apr 2022 21:20:10 +0000</pubDate>
      <link>https://dev.to/the_unfactoring_guru/complete-phaser-3-game-development-guide-part-0-installation-and-importing-4903</link>
      <guid>https://dev.to/the_unfactoring_guru/complete-phaser-3-game-development-guide-part-0-installation-and-importing-4903</guid>
      <description>&lt;p&gt;&lt;strong&gt;DISCLAIMER&lt;/strong&gt;: These series of articles may seem long and with a lot of information. I try to condense as much as possible for beginners to understand, but also to not get bored reading them. If you have any recommendations, I would gladly accept them!&lt;/p&gt;

&lt;h2&gt;
  
  
  What's this about?
&lt;/h2&gt;

&lt;p&gt;Phaser 3 is a simple, complete, and efficient Javascript library for developing video games in HTML or Browser. Phaser 3 is great for beginners because of its simplicity during development and it's lightweight environment (unlike Unity or Unreal which take up a lot of CPU and processing power). In this part of the guide we will complete the following tasks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installation&lt;/li&gt;
&lt;li&gt;Importing Library&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After that we will pass to &lt;a href="https://dev.to/the_unfactoring_guru/complete-phaser-3-game-development-guide-part-1-hello-world-in-phaser-3-5103-temp-slug-8794418"&gt;Part 1&lt;/a&gt; where we dive into the details of the project we are creating and on how to run our first "Hello World" in Phaser (Trust me, it's a lot more exciting than it sounds).&lt;/p&gt;

&lt;p&gt;The only requirements you need are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic HTML-CSS knowledge (just to create our game's window)&lt;/li&gt;
&lt;li&gt;Object Oriented Programming skills (not necessarilly Javascript)&lt;/li&gt;
&lt;li&gt;Node.js installed on your machine (we need to install some packages necessary for compilation and execution)&lt;/li&gt;
&lt;li&gt;Text/Code Editor (... duh)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If all of that is done, let's get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a&gt;&lt;/a&gt;Installation
&lt;/h2&gt;

&lt;p&gt;There are many ways for installing Phaser 3 into your machine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NPM&lt;/li&gt;
&lt;li&gt;Source code&lt;/li&gt;
&lt;li&gt;JS File&lt;/li&gt;
&lt;li&gt;CDN&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each one has its benefits and consequences, but that's for another section or article. For now just choose the one which is best for you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a&gt;&lt;/a&gt; NPM&lt;/strong&gt;&lt;br&gt;
Phaser 3 is available through the &lt;a href="https://www.npmjs.com"&gt;NPM Registry&lt;/a&gt; so you just need to go to your project folder and execute:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install phaser&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;from the console!&lt;/p&gt;

&lt;p&gt;And that's basically it! If you are done installing then you can skip the other methods and jump into how to import the library.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a&gt;&lt;/a&gt; Source Code&lt;/strong&gt;&lt;br&gt;
This library is Open Source which means it's source code is free to download and edit from a public repository (Github in this case). You can either download the zip/tar.gz file from the &lt;a href="https://github.com/photonstorm/phaser"&gt;Phaser 3 Repository&lt;/a&gt; or you can use git to clone the repo into your project:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone https://github.com/photonstorm/phaser.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Or if you have &lt;a href="https://cli.github.com/"&gt;Github's CLI&lt;/a&gt; tool you can just run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gh repo clone photonstorm/phaser&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;after that take in mind that the file we will import afterwards is called &lt;code&gt;phaser.js&lt;/code&gt; located in &lt;code&gt;phaser/dist/phaser.js&lt;/code&gt;. With this done you can go right into how to import the Phaser 3 library.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a&gt;&lt;/a&gt; JS File&lt;/strong&gt;&lt;br&gt;
The simplest and easiest way you can install Phaser, it's to just download the js file from here: &lt;a href="https://github.com/photonstorm/phaser/releases/download/v3.55.2/phaser.js"&gt;phaser.js&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then just include the library into your project folder and... done!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a&gt;&lt;/a&gt; CDN&lt;/strong&gt;&lt;br&gt;
For those who don't know, a CDN (Content Delivery Network) is used to import library (an almost infinite amount of libraries) from the internet without needing to install them locally! Lucky for us, Phaser has it's own CDN! Installing it is easy, you just need to go to the index.html file (or your main html file) and included into the browser's &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tag as a &lt;code&gt;&amp;lt;scrpt src="$PHASER_LIBRARY_CDN&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"//cdn.jsdelivr.net/npm/phaser@3.55.2/dist/phaser.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    ...
   &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now with any of these installation methods, you can now start importing the library&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a&gt;&lt;/a&gt;Importing Library
&lt;/h2&gt;

&lt;p&gt;With which ever method you chose! There are two main ways of importing the library:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Requiring the library using commonjs&lt;/li&gt;
&lt;li&gt;Include into the HTML file&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;a&gt;&lt;/a&gt;Require inside javascript file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are familiar with commonjs, than you know that when we talk about &lt;strong&gt;importing&lt;/strong&gt; the library, we are actually &lt;strong&gt;requiring&lt;/strong&gt; it's contents into a variable. This variable will have ALL the functionality we need from the library.&lt;/p&gt;

&lt;p&gt;If you installed through npm, then you can simply write this into your main javascript file:&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;const&lt;/span&gt; &lt;span class="nx"&gt;Phaser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;phaser&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;If you installed through github or just downloaded the javascript file, you basically do the same step, but specifying the library's directory:&lt;/p&gt;

&lt;p&gt;With Github, it's highly likely that you import the library 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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Phaser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./phaser/dist/phaser.js&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;Or if you downloaded the phaser.js file into a custom directory then you would import the library 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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Phaser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./path/to/library/phaser&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//REPLACE 'path/to/library/' WITH THE PHASER DIRECTORY&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Regarding which step you chose, you would actually need a bundling tool to compile your code (we will get into bundling in another section, so don't worry yet).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a&gt;&lt;/a&gt;Including in HTML file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This step was already done in the CDN install section, but of course this is done differently regarding which method of installation you used.&lt;/p&gt;

&lt;p&gt;Basically you just include your phaser.js script inside the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tags of you html file using a &lt;code&gt;&amp;lt;script src="src"&amp;gt;&lt;/code&gt; where &lt;code&gt;"src"&lt;/code&gt; is your Phaser library.&lt;/p&gt;

&lt;p&gt;If you used npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"./node_modules/phaser/dist/phaser.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    ...
   &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you used Github:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"./phaser/dist/phaser.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    ...
   &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you saved the phaser.js file into a custom directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"./path/to/library/phaser.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    ...
   &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And with that, you're all done.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we learned...
&lt;/h2&gt;

&lt;p&gt;In this part we learned the basic requirements we need to create our game, how to install the required library, and how to import the library into our project. In &lt;a href="//www.example.com"&gt;Part 1&lt;/a&gt; we will create our "Hello World" program inside our project so we are sure that things are running smoothly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;: If you imported the library using commonjs (&lt;code&gt;require("$PHASER_LIBRARY")&lt;/code&gt;), then go to &lt;a href="//example.js"&gt;Part 0.5&lt;/a&gt; to learn about basic bundling using &lt;strong&gt;browserify&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>html</category>
    </item>
    <item>
      <title>Developing My Own Node CLI Tool! And YOU can Contribute</title>
      <dc:creator>The Unfactoring Guru</dc:creator>
      <pubDate>Sat, 20 Nov 2021 07:51:41 +0000</pubDate>
      <link>https://dev.to/the_unfactoring_guru/developing-my-own-node-cli-tool-and-you-can-contribute-2164</link>
      <guid>https://dev.to/the_unfactoring_guru/developing-my-own-node-cli-tool-and-you-can-contribute-2164</guid>
      <description>&lt;h2&gt;
  
  
  I made a CLI Tool and You Can contribute!
&lt;/h2&gt;

&lt;p&gt;Basically I'm really excited about writing packages. I just created this small tool called bring-me! This basic cli tool just brings you libraries to your current working directory directly from its cdn! You can also add libraries to the repertoir of libraries you have saved for downloading later!&lt;br&gt;
Examples: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;bring-me lib jquery -d /public/js&lt;/code&gt; you will have jquery already integrated in your project!&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/devasolutions"&gt;
        devasolutions
      &lt;/a&gt; / &lt;a href="https://github.com/devasolutions/bring-me"&gt;
        bring-me
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      NPM CLI tool for delivering common front-end libraries, frameworks, stylesheets, etc. for lightweight and easy development without needing them stored in node_modules or when internet connection could be a problem in the future.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
bring-me&lt;/h1&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://camo.githubusercontent.com/7c945076bd8d737b17e8ccfc5afc4ac97671a02b47a132bbc348ee68cf30a0b6/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f4064657661736f6c7574696f6e732f6272696e672d6d65"&gt;&lt;img src="https://camo.githubusercontent.com/7c945076bd8d737b17e8ccfc5afc4ac97671a02b47a132bbc348ee68cf30a0b6/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f4064657661736f6c7574696f6e732f6272696e672d6d65" alt="npm (scoped)"&gt;&lt;/a&gt; &lt;a rel="noopener noreferrer" href="https://camo.githubusercontent.com/e9662fa5103a0a1d2a5e6e282ba7cebc3da286ea7e09f68e09e8d8048f79a50f/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f64742f4064657661736f6c7574696f6e732f6272696e672d6d65"&gt;&lt;img src="https://camo.githubusercontent.com/e9662fa5103a0a1d2a5e6e282ba7cebc3da286ea7e09f68e09e8d8048f79a50f/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f64742f4064657661736f6c7574696f6e732f6272696e672d6d65" alt="npm"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;NPM CLI tool for delivering common front-end libraries, frameworks, stylesheets, etc. for lightweight and easy development without needing them stored in node_modules or when internet connection could be a problem in the future.&lt;/p&gt;
&lt;h1&gt;
Install&lt;/h1&gt;
&lt;p&gt;Install globally with NPM
&lt;code&gt;npm install -g @devasolutions/bring-me&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Or install in development
&lt;code&gt;npm install --save-dev @devasolutions/bring-me&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
Introduction&lt;/h1&gt;
&lt;p&gt;Bring-me is a CLI tool used to download popular frameworks from there CDNs so that you can use them offline when needed in mostly Front-End Development scenerios&lt;/p&gt;
&lt;p&gt;Summary:&lt;/p&gt;
&lt;p&gt;Bring-me scans a &lt;code&gt;bmconfig.json&lt;/code&gt; file inside the module's directory to get the most popular frameworks and libraries (bootstrap,bulma,jquery,lodash,phaser at the moment).&lt;/p&gt;
&lt;p&gt;bmconfig.json example:&lt;/p&gt;
&lt;div class="highlight highlight-source-json position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;[
  {
    &lt;span class="pl-ent"&gt;"url"&lt;/span&gt;: &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.js&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;,
    &lt;span class="pl-ent"&gt;"file-name"&lt;/span&gt;: &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;jquery.js&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;,
    &lt;span class="pl-ent"&gt;"lib-name"&lt;/span&gt;: &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;jquery&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;,
    &lt;span class="pl-ent"&gt;"format"&lt;/span&gt;: &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;js&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;,
    &lt;span class="pl-ent"&gt;"version"&lt;/span&gt;: &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;"&lt;/span&gt;3.6.0&lt;span class="pl-pds"&gt;"&lt;/span&gt;&lt;/span&gt;
  },
  &lt;span class="pl-ii"&gt;...&lt;/span&gt;
]&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;bmconfig.json fields:&lt;/p&gt;
&lt;p&gt;url: (contains the url of the library from cdn)
file-name: (the…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/devasolutions/bring-me"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;I need people to help with creating more basic commands, fefactoring, and improving documentation. So anybody is welcome to participate!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Regards&lt;/li&gt;
&lt;li&gt;The unfactoring guru&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>npm</category>
      <category>node</category>
      <category>cli</category>
    </item>
    <item>
      <title>Basic Software Architecture Principles (except SOLID)</title>
      <dc:creator>The Unfactoring Guru</dc:creator>
      <pubDate>Fri, 05 Nov 2021 06:28:14 +0000</pubDate>
      <link>https://dev.to/the_unfactoring_guru/basic-software-architecture-principles-except-solid-mlj</link>
      <guid>https://dev.to/the_unfactoring_guru/basic-software-architecture-principles-except-solid-mlj</guid>
      <description>&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fys3786b0yu10c1at105y.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fys3786b0yu10c1at105y.png" alt="Architecture Principles"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;As programmers we always try to create the BEST CODE IN THE WORLD. But we sometimes start to feel and think things like "Is my code to simple?" "Will it function well?" "Is my code to bulky?" and other nonsense. Well here are some basic principles to follow if you want to become a better and more productive programmer&lt;/p&gt;

&lt;h2&gt;
  
  
  YAGNI (You ain't gonna need it)
&lt;/h2&gt;

&lt;p&gt;As developers we are always excited to use and integrate the new technologies that come around: React, Node, Flutter, Docker, Kubernetes. But before implementing this new stuff, stop an think "Do I REALLY need this?" 90% of the time you will say "Yes, of course it's just what my application needs!", but later on in your project you will notice that your application will start to run slow, need a lot of memory and disk space, and will actually slow your coding process a lot! So, just because Facebook is starting to use AWS for their projects, don't think you do! Keep your project as simple as possible! Which brings me to another principle&lt;/p&gt;

&lt;h2&gt;
  
  
  KISS (Keep it stupid simple)
&lt;/h2&gt;

&lt;p&gt;This happens a lot in modern programming. People start using unnecessary operations or methods to "optimize" their code for example do you know what this is?&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;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//Wait for it...&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you don't know what this is, it's a conditional way of writing the following&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;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
   &lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They both return 4, but a simple junior programmer won't know or will get confused when seeing things like that. In principle, just believe everyone your working with or for, is a beginner, so don't add fancy stuff like this so that your ·"code looks pretty and organized." The compiler is not gonna applaud to you if you use ternary operators, both solutions are fine, but KISS, and let everyone know your code.&lt;/p&gt;

&lt;h2&gt;
  
  
  DRY (Don't repeat yourself)
&lt;/h2&gt;

&lt;p&gt;I can explain this better with an example:&lt;/p&gt;

&lt;p&gt;This is a file inside one of my projects&lt;br&gt;
&lt;code&gt;add.js&lt;/code&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;let&lt;/span&gt; &lt;span class="nx"&gt;bmObj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;bmconfig&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;bmObj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bmTempObj&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/bmconfig.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bmObj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;err&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;And lines after I started using this same structure of code inside a different file.&lt;br&gt;
&lt;code&gt;lib.js&lt;/code&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;lib&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;version&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;bmObj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
        &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/bmconfig.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bmObj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&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;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;chalk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;redBright&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Couldn't write file&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="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&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;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&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;As you may clearly see the same functionality is been repeated a lot!&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="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/bmconfig.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bmObj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;err&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;How do you solve this? Simple! Just create a function that writes a specific file with what you want inside it.&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;function&lt;/span&gt; &lt;span class="nf"&gt;writeToBmConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bmObj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/bmconfig.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bmObj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&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="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&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;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&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;And just include this function and replace the code you had in your other files! This now means you only write your code once. And adds more functionality to your application!&lt;/p&gt;

&lt;h2&gt;
  
  
  WET (Write Everything Twice)
&lt;/h2&gt;

&lt;p&gt;This one is basically the opposite of DRY. When is it useful? I honestly think when your starting to write your first lines of code. During these stages don't try to think about the DRY principle. Code as your heart desires and later you will notice functionalities inside programs that can actually just can simply function as a method! So yeah if you're starting a project, always keep in mind after taking a break "How should I make my code DRY?"&lt;/p&gt;

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

&lt;p&gt;Try to focus on this principles when refactoring code or when developing new projects. Sometimes when starting a project we kind of miss this principles! But don't worry, they aren't strict rules for development, their just recommendations when writing code.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>design</category>
      <category>programming</category>
      <category>refactorit</category>
    </item>
  </channel>
</rss>
