<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jessica Torres on Medium]]></title>
        <description><![CDATA[Stories by Jessica Torres on Medium]]></description>
        <link>https://medium.com/@jess.torres_?source=rss-d92e0d535819------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5Wv030ZILY5pvySMx7XXWQ.jpeg</url>
            <title>Stories by Jessica Torres on Medium</title>
            <link>https://medium.com/@jess.torres_?source=rss-d92e0d535819------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 02:09:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jess.torres_/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Input Formatting with Cleave.js]]></title>
            <link>https://medium.com/@jess.torres_/input-formatting-with-cleave-js-45359e550e22?source=rss-d92e0d535819------2</link>
            <guid isPermaLink="false">https://medium.com/p/45359e550e22</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[input-field]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[js-libraries]]></category>
            <dc:creator><![CDATA[Jessica Torres]]></dc:creator>
            <pubDate>Mon, 27 Jul 2020 19:01:05 GMT</pubDate>
            <atom:updated>2020-07-27T19:01:05.411Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*WK1m2U3wYVcWGCPu1Yz4Qg.png" /></figure><p>Often, one of the inconveniences when dealing with input fields and creating forms for your application is in trying to control what information the user can give you, and how that information looks once you receive it. <br><strong>The easiest way to create consistency across the data that you deal with is to handle it at the source: limit the freedom the user has.</strong></p><p>Fortunately, Cleave.js exists to solve our problem by doing just that.<br>Cleave is a JavaScript library that handles the formatting of input values, in a clean and easy to implement pattern, so that you don’t have to worry about taking up time or extra lines of code managing that on your own.</p><p>There are two obvious benefits here:</p><ol><li>The user is presented with better-looking information on their end; where the text is spaced or separated by characters, broken into blocks, and just altogether less jumbled.</li><li>The information you pull from the inputs is less likely to have issues caused by user error and mistake, and there can be no major difference in the way it is entered; where the input can be limited specifically to numbers or letters or have characters added by default.<br>(Example: users might enter a phone number with parenthesis around the area code, break it up with slashes, hyphens, or not at all)</li></ol><h3>WHAT IS INCLUDED?</h3><p>While the following are the use cases outlined in <a href="https://github.com/nosir/cleave.js/">the documentation for Cleave.js</a>, there are so many ways you can build the options object you can supply to Cleave that essentially anything you need, input wise, can be done with this library.</p><p><strong>Built-In Formatting:</strong></p><ul><li>Credit card numbers</li><li>Phone numbers</li><li>Dates</li><li>Numerals</li></ul><h3>CLEAVE BASICS</h3><p>Let’s look at the fundamentals for using Cleave and explain some of the terms you’ll need to be familiar with to start incorporating it into your projects.</p><h4>Delimiters</h4><p>Delimiters are single, or sequences of, characters. Their purpose is to establish the boundary between segments of the same data stream (- , /, . , etc).</p><h4>Blocks</h4><p>Blocks, within Cleave.js, are how you set up where spaces (or, if you’ve set them to occur, delimiters) will appear. If you were to create an input for a phone number, the block pattern would look like this: [3, 3, 4].</p><h4>Patterns</h4><p>Patterns exist as a possible property within the options object, so there is a separate pattern for each type of input field (timePattern, datePattern).</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><h4>Installation &amp; Import</h4><p>Cleave.js can be installed easily through npm, or the option to use a CDN also exists (where it is available on <a href="https://www.jsdelivr.com/package/npm/cleave.js">jsDelivr</a> or <a href="https://cdnjs.com/libraries/cleave.js">cdnjs.com</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*QWPnL6U2h9KPplnnKwNlpQ.png" /></figure><p>As far as front end framework and library compatibility are concerned, Cleave.js can be used with React.js as a component within the JSX or with Angular.js directives and included within the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*h_rbwhSW6qmuWYqzJLlAwQ.png" /><figcaption>ES6 module import</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*_fU3yoJw1k9wVI_Ke8TnQQ.png" /><figcaption>And then reference from inside of the model</figcaption></figure><h3>BUILDING AN EXAMPLE FORM</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*Hi8-T-wu4dkSWs6efWleAg.png" /></figure><p>For the example, we will be using ES6 Module version but Cleave can also be brought in with the CommonJS method. The form itself will be made using React with Hooks.</p><p>When you use the library and instantiate, note that the Cleave instance does simply return a normal input element. Which means it can be styled and otherwise manipulated the same way as usual.</p><p>Here is the example code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc935702a7a54fbe5ebd72eeb48b3e55/href">https://medium.com/media/bc935702a7a54fbe5ebd72eeb48b3e55/href</a></iframe><p>Now, let’s look at what is actually being done here.</p><p>Because the Cleave instances return a standard input field, we don’t need to do anything else outside of this file (after, of course, setting up the index.html that will be used) to start seeing the form on the page.</p><ul><li>You have the ability to set a placeholder and supply the function that will be called when the value of the input changes, the same as you normally would.</li><li>We set the type of the input field by creating the object that will be given to options, inside we set the desired type as the property and the value of that property to a boolean (clearly in this case, true).</li><li>For the time and date type fields we can provide a pattern array, also within the options object. This is where we determine the format of the data. (There are other versions of the patterns and some of those can be seen demoed in the Github documentation.)</li><li>Delimiter(s) will be set within the options object as well. You can provide a single delimiter and it will be used in place of every space OR provide a collection of delimiters, which will be used in the order in which they appear in the array. <br>An example of this is on line 43 in the Form code above. We pass not one, but two delimiters, and instead of using standard special characters we use the abbreviations ‘hr’ and ‘mins’ to separate our numerical values. You will see the result of this in the second example image below.</li><li>It’s important to explain also that Cleave recognizes whatever you set to be the placeholder value as formatting instructions also. Displayed in the first two fields we create here, for the date and time, where we do not pass any delimiters but still see formatting occur: 00/00/0000 and 00:00.<br><strong>Cleave takes the style of the placeholder and applies it to the field unless you tell it otherwise in the options object you send.</strong></li></ul><h3>AFTER VALUES</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*wnbOXYbSgZBtDQKUb2Mn7w.png" /></figure><p>This is how the form would appear to the user as they fill the input fields.</p><p>The characters and abbreviations would appear as the user types, formatting their information in realtime, as well as only allowing numerical values to be entered on the keyboard.</p><h3>CONCLUSION::</h3><p>That is all there is to it, really. Cleave.js is an extremely easy to use library and in my experience putting it to use in more than one application, is well worth its weight.</p><p>There are many more use cases than the ones I have outlined here, several of which have to do with how Cleave can help handle credit card and payment information (not only with formatting the card numbers themselves but in identifying card type and in managing the other information that would be provided in a checkout or payment form (exp, CCV, etc.)) and phone number/communication data.</p><p>Check it out for yourself and make your development life just a little easier.</p><h4>Thank you for reading!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45359e550e22" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating A Simple 2D Game With HTML5 & JavaScript]]></title>
            <link>https://levelup.gitconnected.com/creating-a-simple-2d-game-with-html5-javascript-889aa06035ef?source=rss-d92e0d535819------2</link>
            <guid isPermaLink="false">https://medium.com/p/889aa06035ef</guid>
            <category><![CDATA[canvas]]></category>
            <category><![CDATA[2d]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[side-scroller]]></category>
            <dc:creator><![CDATA[Jessica Torres]]></dc:creator>
            <pubDate>Mon, 20 Jul 2020 10:02:59 GMT</pubDate>
            <atom:updated>2020-07-24T00:50:36.922Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O98w8ztTUxSOD_7JNlh9lg.jpeg" /></figure><p>For the sake of following along with the code in this article, you should be familiar with JavaScript, as well as have an understanding of HTML5 Canvas basics.</p><p>If you aren’t yet acquainted with Canvas, it would be beneficial to take a few minutes to look over this <a href="https://link.medium.com/9VvfHzjBg8">introductory article</a> before moving forward.</p><h3>WHAT ARE WE BUILDING?</h3><p><strong>The finished product will be a simple 2D side-scroller game.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*24LcUr--WQJpjTr8K_jAeg.png" /></figure><ul><li>Simple concept, clear objective: The player is presented with “obstacles” as they move forward and should jump to avoid them.</li><li>The forward running, backward running, and jumping actions are controlled by the associated cursor keys (arrows) on the keyboard.</li><li>We’ll keep the canvas elements uncomplicated (just squares and triangles) so we can better focus on the element motion and “endless runner” effect that actually make this feel like a real game.</li></ul><h3>SETTING THE STAGE</h3><p>Before we look at what makes up the actual “game” code, we need to set up our project files and create the canvas element we intend to use.</p><ol><li>We will need <strong>index.html</strong>, <strong>game.js</strong>, and <strong>game.css</strong> files.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d7ea9979b9306e5cedfaf76e9e7b5f2/href">https://medium.com/media/0d7ea9979b9306e5cedfaf76e9e7b5f2/href</a></iframe><p><strong>FIRST:</strong></p><p>Create an index.html and include the displayed code.</p><ul><li>Make sure you have linked your stylesheet and your javascript file within your index.html.</li><li>We create the canvas element within the body of our HTML.<br>We’ll handle any styling and sizing for it elsewhere.</li><li>It does not matter what title or header names you give your own game, just include the same instructions that inform the player which controls they can use to play the game.</li></ul><p><strong>NEXT: </strong>Add whatever page styling you prefer, to surround the canvas area that will hold all of the game content.</p><p>You can see from the image above, in our example we’re centering our canvas within the page and the only styling that will really take place in our CSS file will be the background and text colors for the few other elements we include.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b01f4136f967787a3e70a48ecf7a313/href">https://medium.com/media/5b01f4136f967787a3e70a48ecf7a313/href</a></iframe><p><strong>LASTLY:</strong> Add your <strong>game.js</strong> file and get ready to start building your game!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1dbe623bb45bf370433251423bd44a63/href">https://medium.com/media/1dbe623bb45bf370433251423bd44a63/href</a></iframe><p>Skipping the detailed explanations here, because by this point in the article you either arrived with Canvas knowledge or followed the <a href="https://link.medium.com/9VvfHzjBg8">link</a> at the top of the page earlier and gathered the fundamentals.</p><p>In short:</p><ul><li>The first thing we need to do in our JavaScript is to define the context for our canvas; as a result, gaining access to all of the returned methods and more, that we’ll need while we’re creating in 2D.</li><li>The next step is to size the canvas element. If we don’t specify a new width and height, the element defaults to <em>300px </em><strong>W</strong> <strong>x</strong><em> 150px </em><strong>H.</strong></li><li>You can, of course, choose your own size to better fit the game you want to build or the page your game will be added to but understand that there are several values used later on in our code that are entirely calculated from the dimensions we have set in the example (<em>1120</em> <strong>W</strong> <strong>x</strong> <em>400</em> <strong>H</strong>).<br>Any changes you make to the sizing of the canvas will need to be reflected in the coordinate values you set for the elements afterward.</li></ul><p>Everything after the above code will be specific to our game.</p><h3>CREATE THE PLAYER ELEMENT</h3><p>The square that will represent the player in the game will be stored as an object. We’ll use this object throughout the code to:</p><ul><li>Update the coordinate properties that act as the square’s current location</li><li>Determine whether the square is currently in the air or not</li><li>Determine whether the square is moving forward or backward</li><li>Maintain the square’s height and width (set size)</li></ul><pre>const square = {</pre><pre>  height: 32,<br>  jumping: true,<br>  width: 32,<br>  x: 0,<br>  xVelocity: 0,<br>  y: 0,<br>  yVelocity: 0</pre><pre>};</pre><h3>CREATE THE PLAYER’S CONTROLLER</h3><p>The controller will also be represented as an object and will keep up with which keys are currently being pressed by the player (allowing us to determine which action to take within the canvas).</p><p>We check the key listener’s event type against the keycodes associated with the Left, Right, and Up arrow keys.</p><pre>const controller = {</pre><pre>  left: false,<br>  right: false,<br>  up: false,</pre><pre>  keyListener: function (event) {</pre><pre>    let key_state = (event.type == &quot;keydown&quot;) ? true : false;</pre><pre>    switch (event.keyCode) {<br>      case 37: // left arrow<br>        controller.left = key_state;<br>        break;<br>      case 38: // up arrow<br>        controller.up = key_state;<br>        break;<br>      case 39: // right arrow<br>        controller.right = key_state;<br>        break;<br>    }<br>  }<br>};</pre><h3>CREATE THE “LOOP” THAT FACILITATES ANIMATION</h3><p>This next step is quite a meaty one.</p><p>The loop function will be where we:</p><ul><li>Constantly check what the player is doing with their controller and animate the player’s square accordingly (direction, speed, running, or jumping).</li><li>Apply the “gravity” and “friction” effects that will change the speed of the player’s square and allow for the realistic manner in which it moves.</li><li>Handle the cases where the player’s square exits the screen to the left or the right and establish the infinite scroll behavior.</li><li>Draw and fill all the canvas shapes that make up the game, originally, and as each new frame is animated.</li></ul><ol><li>So, let’s get started by setting up the conditional blocks that will simulate player-triggered movement of the square by adjusting the square object’s velocity value or by flipping the jumping flag to true.</li></ol><pre>const loop = function () {</pre><pre>  if (controller.up &amp;&amp; square.jumping == false) {<br>    square.yVelocity -= 20;<br>    square.jumping = true;<br>  }</pre><pre>  if (controller.left) {<br>    square.xVelocity -= 0.5;<br>  }</pre><pre>  if (controller.right) {<br>    square.xVelocity += 0.5;<br>  }</pre><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>2. Next, we add gravity and friction effects. Once added, they won’t really stand out in action, but the animation looks pretty jolty and awkward without them.</p><pre>  square.yVelocity += 1.5; // gravity</pre><pre>  square.x += square.xVelocity;</pre><pre>  square.y += square.yVelocity;</pre><pre>  square.xVelocity *= 0.9; // friction</pre><pre>  square.yVelocity *= 0.9; // friction</pre><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>3. Following this, we have to start handling the traits of the game that will have become obvious concerns from watching the way the animation is running on the screen.</p><p>First, we need to guarantee the square is never “falling” below the region we have determined will be the “ground” that it’s meant to run across.</p><pre>  // if the square is falling below floor line, then:</pre><pre>  if (square.y &gt; 386 - 16 - 32) {</pre><pre>    square.jumping = false;</pre><pre>    square.y = 386 - 16 - 32;</pre><pre>    square.yVelocity = 0;</pre><pre>  }</pre><p>Here, the current value of the square’s y coordinate should never be greater than the y coordinate that represents the “top” of the ground line (with the height of the jump and the height of the square subtracted from it).</p><p><strong>If it is</strong>, we stop the square’s jump, set the y coordinate of the square to that of the value it cannot surpass, and stop the square from “falling” (set the y velocity back to 0).</p><p>Second, we need to guarantee we have control over what happens when the player’s square exits to either side of the game window. In this case, we set it up to bring the player back, entering on the opposite side from where they exited.</p><pre>  if (square.x &lt; -20) {</pre><pre>    square.x = 1220;</pre><pre>  } else if (square.x &gt; 1220) {  // if the square goes off the right</pre><pre>    square.x = -20;</pre><pre>  }</pre><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>4. Drawing the shapes, including the backdrop, ground layer, player square (and later in the article, the obstacles), happens next. This too goes within the loop function, so that it runs and redraws the shapes on every animation frame.</p><pre>  // Creates the backdrop for each frame</pre><pre>  context.fillStyle = &quot;#201A23&quot;;</pre><pre>  context.fillRect(0, 0, 1220, 400); // x, y, width, height<br></pre><pre>  // Creates and fills the cube for each frame</pre><pre>  context.fillStyle = &quot;#8DAA9D&quot;; // hex for cube color</pre><pre>  context.beginPath();</pre><pre>  context.rect(square.x, square.y, square.width, square.height);</pre><pre>  context.fill();<br></pre><pre>  // Creates the &quot;ground&quot; for each frame</pre><pre>  context.strokeStyle = &quot;#2E2532&quot;;</pre><pre>  context.lineWidth = 30;</pre><pre>  context.beginPath();</pre><pre>  context.moveTo(0, 385);</pre><pre>  context.lineTo(1220, 385);</pre><pre>  context.stroke();</pre><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>5. We signal to the browser that we’re ready to perform an animation, and that prior to the next repaint the browser should update the animation using the loop function.</p><pre>// Updates when called to tell the browser it is ready to draw again</pre><pre>window.requestAnimationFrame(loop);</pre><p>It is a rule of the requestAnimationFrame method that the callback you pass to it must have requestAnimationFrame called within itself<br>(if you want to animate another frame at the next repaint).</p><h3>CREATE EVENT LISTENERS</h3><h4>(&amp; KICKSTART THE ANIMATION LOOP)</h4><p>We set up the keyup and keydown event listeners for the necessary keys in the controller object.</p><pre>window.addEventListener(&quot;keydown&quot;, controller.keyListener)</pre><pre>window.addEventListener(&quot;keyup&quot;, controller.keyListener);</pre><p>Then we start the animation loop by adding the initial call of requestAnimationFrame, providing the loop function as the callback.</p><pre>window.requestAnimationFrame(loop);</pre><h3>NEXT STEP: OBSTACLES</h3><p>At this stage, we are all but finished. You’ll see if you’re following along with your own version of the code so far, that you have a player-controlled square that can move and jump, and a background that seemingly goes on forever.</p><p>However, we’re missing a key part of the equation, which is the obstacle that a player needs to be presented with. In order to make the adjustments necessary to create them, we’ll just have to add one or two things to the code we’ve already written</p><ol><li>First, we need to revisit the very beginning of the code.<br>In the space below our context definition and above the declaration of our square, we need to add the following:</li></ol><pre>// Start the frame count at 1 (also level 1)<br>let frameCount = 1;</pre><pre>// Set the number of obstacles to match the current &quot;level&quot; number<br>let obCount = frameCount;</pre><pre>// Create a collection to hold the randomly generated x coordinates<br>const obXCoors = [];</pre><p>We want to keep track of the number of frames, which will be the equivalent of levels as far as we’re concerned behind the curtain of this game. <br>We also want to set the number of obstacles to increase directly as the levels do.<br>And lastly, we want to establish storage for holding the x coordinates we’ll randomly generate and use to place the obstacles dynamically on each new frame.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>2. There is a straightforward way for us to know when a user has finished a “level” and is starting a new one, and it is actually already set up in the existing code.</p><p>We know that if a user is exiting the game window to the right then they are about to reenter on the left and that will represent a new level being started.<br>So, we want to have some function we can call when that happens.</p><p>**As a side note, to explain why we can’t simply draw the obstacle objects <em>when</em> the user exits the screen: T<strong>he order in which shapes are drawn <em>does </em>matter.</strong> <br>Therefore, we can create our random coordinates ahead of time but must wait to draw the obstacles themselves until <em>after </em>the backdrop and other shapes have been drawn.**</p><pre>// Create the obstacles for each frame</pre><pre>const nextFrame = () =&gt; {</pre><pre>  // increase the frame / &quot;level&quot; count</pre><pre>  frameCount++;</pre><pre>  for (let i = 0; i &lt; obCount; i++) {</pre><pre>    // Randomly generate the x coordinate for the<br>       top corner start of each triangle</pre><pre>    obXCoor = Math.floor(Math.random() * (1165 - 140 + 1) + 140);</pre><pre>    obXCoors.push(obXCoor);</pre><pre>  }</pre><pre>}</pre><ul><li>Increase the frameCount (which we take to mean the next level has been reached), which increases the number of obstacles that will be part of the next scene.</li><li>Start an iteration that will run up until the current count for obstacles.</li><li>Generate that number (the obstacles count) worth of random x coordinates<br>“Random” between the x coordinates of 140 and 1165 — Which were chosen to make sure no obstacles will spawn too close to the beginning, or right against the end, of the game window (completely unfair to the player and impossible to beat).</li><li>Add each x coordinate to the coordinate collection so that the obstacle shapes can be dynamically drawn later in the loop function.</li></ul><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>3. A very small adjustment, we need to add the call of nextFrame() to the conditional that verifies the player is exiting the right side of the window</p><pre>} else if (square.x &gt; 1220) {// if square goes past right boundary</pre><pre>square.x = -20;</pre><pre>nextFrame();</pre><pre>}</pre><p>(The rest of this conditional is already in your code, I’ve only shown it here so you can see the nextFrame method call in context.)</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>4. The actual <strong>final</strong> change is to add the draw section for the obstacle shapes to the correct area in the body of the loop function. We’ll insert this below the draw for the square and above that which is for the ground.</p><pre>  // Create the obstacles for each frame</pre><pre>  // Set the standard obstacle height</pre><pre>  const height = 200 * Math.cos(Math.PI / 6);</pre><pre>  context.fillStyle = &quot;#FBF5F3&quot;; // hex for triangle color</pre><pre>  obXCoors.forEach((obXCoor) =&gt; {</pre><pre>    context.beginPath();</pre><pre>    // (x = random, y = coor. on &quot;ground&quot;)<br>    context.moveTo(obXCoor, 385);</pre><pre>    // (x = ^random + 20, y = coor. on &quot;ground&quot;)<br>    context.lineTo(obXCoor + 20, 385);</pre><pre>    // (x = ^random + 10, y = peak of triangle)<br>    context.lineTo(obXCoor + 10, 510 - height);</pre><pre>    context.closePath();</pre><pre>    context.fill();</pre><pre>  });</pre><ul><li>Calculate the standard height we’ll follow for all obstacles</li><li>Iterate over the collection of randomly generated x coordinates, which will determine where along the window width, on the ground, the obstacle will appear.</li><li>Offset each x coordinate value by consistent values (20 and 10) to have the same sized equilateral triangle drawn no matter what the x coordinate turns out to be.</li></ul><h3>THE FINAL RESULT</h3><p>After everything we covered, your game.js file should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53d57eddcf2810d4b6171ccf4512f22a/href">https://medium.com/media/53d57eddcf2810d4b6171ccf4512f22a/href</a></iframe><ul><li>The Player can move forward or backward and jump.</li><li>The Player’s actions and movements will look smooth and realistic.<br>- There is “gravity” that affects the square as it falls back down from a jump<br>- There is “friction” that affects the square as it slides forward or backward<br>- Pressing the forward or backward arrow while still holding the other will slow and then immediately stop the square’s motion, as two conflicting forces are acting on the object at once.</li><li>For a simple, fast effect the number of obstacles will match the current “level” (which is considered to increase every time the player makes it through another frame).</li></ul><h3>CONCLUSION::</h3><p>There you have it, a basic 2D side-scroller made with JavaScript and HTML5 Canvas!</p><p>The main objective of the article was to show how easy it can be to get started making some kind of game; when it can often seem like a fairly daunting amount of groundwork learning must be done just to break into the world of game dev.</p><p><strong>Some suggestions and next steps for quickly improving the game:</strong></p><ul><li>Add an indicator on screen that informs the player which “level” they are currently on.</li><li>Add a form of <a href="https://developer.mozilla.org/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript/Collision_detection">collision detection</a>; so the player loses points or directly fails if they collide with one or a certain number of obstacles.</li><li>Optimize the new obstacle generation:<br>- Have the number of new obstacles increase every couple of levels instead of steadily, one every new level.<br>- Improve the randomization of the obstacles&#39; locations, to limit the times they group together.</li><li>Add some music or other effects like lighting to better the player’s experience.</li></ul><p>There are many ways to customize and advance the starter game we have built and many technologies that you can move toward learning if you had enough fun working with this project (like I did) that you’re excited to see what’s next.</p><h4>Thank you for reading!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=889aa06035ef" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/creating-a-simple-2d-game-with-html5-javascript-889aa06035ef">Creating A Simple 2D Game With HTML5 &amp; JavaScript</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Issues In Concurrent Systems]]></title>
            <link>https://medium.com/@jess.torres_/issues-in-concurrent-systems-649bd33f19e8?source=rss-d92e0d535819------2</link>
            <guid isPermaLink="false">https://medium.com/p/649bd33f19e8</guid>
            <category><![CDATA[parallelism]]></category>
            <category><![CDATA[bugs]]></category>
            <category><![CDATA[concurrency]]></category>
            <dc:creator><![CDATA[Jessica Torres]]></dc:creator>
            <pubDate>Wed, 15 Jul 2020 14:00:13 GMT</pubDate>
            <atom:updated>2020-07-20T16:05:59.060Z</atom:updated>
            <content:encoded><![CDATA[<h3>Concurrency vs Parallelism (&amp; Issues In Concurrent Systems)</h3><p>First, it’s important we determine what can be considered a concurrent system and where the differences between concurrency and parallelism lie.</p><h4>Concurrency vs. Parallelism</h4><p><strong>Concurrency is the composition of independently executing processes. Parallelism is the simultaneous execution of multiple things (related or unrelated).</strong> Because the ideas are so closely related, it is easy to confuse one for the other or assume that parallelism is the ultimate goal of concurrency, which it is not. It makes it a little less complicated to think of concurrency as more to do with structure (<em>dealing</em> with several things at once) and parallelism more to do with execution (<em>doing</em> several things at once).</p><p>Defining them individually like this might give the impression that they are concepts that exist only separate from each other but in reality, that is not the case. Just because concurrent designs are not intrinsically parallel, does not mean they are not capable of having the characteristic. <br>They become parallel the moment their different processes are being performed <em>at the same time</em>, <strong>not </strong>when the structure is in place for the system to be <em>able to </em>perform multiple processes at the same time.</p><h3>CONCURRENT MODELS</h3><p>In a general sense and not in a specific case set up, a small example of concurrency would be in a single-core machine that is multitasking (where at least two tasks can, in overlapping time periods, start, run, and complete). The parallelism version mentioned above might be in a multi-core processor (where at least two threads are executing in the same instant).</p><p>Concurrency is referred to as a property of a system or program, and as such does not exist by default in every design. There are ways a program can be built that do not allow for multiple tasks to be started, but not necessarily completed, where the order in which the tasks will be executed in time <strong>is</strong> predetermined.</p><h3>PROBLEMS IN CONCURRENCY</h3><p>We’ll look mostly at frequently encountered issues that will arise in dealing with concurrency. Understand that several of these issues are problems that <em>can</em> occur, but might not occur more than a fraction of the times that the same processes are performed.</p><p>Therefore, the importance of identifying and eliminating them while creating the systems increases, when you consider that because some of these bugs will only show themselves after a certain sequence and combination of operations, you otherwise will not be aware they exist until after a user has suffered some inconvenience.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><h4>Deadlock</h4><p>Often the result of the concurrent use of shared resources, deadlock and resource starvation are issues that are born often of a source of indeterminacy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mzoUNKHZSgFzLElwxgjcfw.jpeg" /></figure><p><strong>Deadlock</strong> is a state, in which every process is on hold, waiting for another process to take action, allowing each process to move on to the resource it presently needs.</p><p><strong>Characteristics:</strong></p><ul><li>Every resource a process needs to access is being “held” by some other process. All processes are then forced to wait to proceed — A deadlock has occurred.</li><li>A process is indefinitely unable to change its state, due to the above situation — The system itself is said to be in a deadlock.</li></ul><p>…</p><p>There is, however, only a certain environment in which a deadlock can take place. Specifically, that environment results from a set of four conditions existing synchronously within a system. <br>These “conditions” are known as the <strong><em>Coffman conditions</em></strong> and are as follows:</p><ul><li>Mutual Exclusion</li><li>Resource Holding/ Hold &amp; Wait</li><li>No Preemption</li><li>Circular Wait</li></ul><p>While there are no recognized “solutions” to deadlocks (in the sense that there are no sure-fire ways to ensure they <strong>never</strong> happen) most often, the preventative approach taken is one where the focus is turned to eliminating the possibility of one or more Coffman conditions’ emergence.</p><p>The reasoning being that if at least one condition can be stopped from manifesting within a system, then all four conditions can never coincide with one another and future deadlock is “blocked” as a result.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><h4>Resource Starvation</h4><p>In concurrent computing, it is possible for a process to be perpetually denied the resources it requires to complete its assigned task.</p><p>When certain processes hold a higher priority than others and are allowed to constantly revisit and use a resource, while a lower priority process is forced to sit stagnant in a state of, potentially indefinite, waiting this is called resource starvation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B1xkvgnagSfhYuIJN0bCNQ.jpeg" /></figure><p>Common causes include:</p><ul><li>Errors in a scheduling algorithm</li><li>Errors in a Mutual Exclusion algorithm</li><li>Resource Leaks</li><li>Fork Bombs (or other denial-of-service attacks)</li></ul><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><h4>Data Races</h4><p>Often, but not always, referred to as a subset of race conditions (when a program, to operate correctly, depends on the timing or sequence of that program’s threads or processes) — A data race usually involves a situation where one thread’s memory operation might attempt to access a memory location, at the same time that another thread’s memory operation is writing to that memory location — and in most contexts, this has great potential for causing nondeterminism.</p><p>It can happen that the data stored in memory as a result of a data race will be inaccurate for any of these reasons (or others):</p><ul><li>It winds up holding some arbitrary value that is a meaningless combination of the values that the individual threads were trying to write to memory.<br>In this case, some value is stored that was not intended by either thread (a ‘torn write’).</li><li>It can be that the value stored is some meaningless combination of the value being written by a thread, and the previously stored value that is simultaneously being read by another thread.<br>In this second case, some value is stored that represents neither the attempted written value nor the original version of the read value.</li></ul><h3>CONCLUSION::</h3><p>Mentioned at the beginning of this article is the fact that parallelism is not the goal of concurrency, and by this point, it should have become clear that a good, efficient structure <em>is</em>.</p><p>Remembering that it can be easy to mix up parallelism and concurrency, examining the status of the operations/processes will usually give you a quick answer to your question. If two or more actions are <em>in progress</em> at the same time, it is in fact a concurrent design, but if two or more actions are being <em>executed simultaneously</em> then it is additionally parallel in nature.</p><p>Obvious from what has been covered also, is that in trying to create a system that can handle a greater amount, at a faster pace, there will be additional openings for error unearthed that then also need to be addressed and managed.</p><h4>Thank you for reading!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=649bd33f19e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic Graphics Generation: The Canvas]]></title>
            <link>https://levelup.gitconnected.com/dynamic-graphics-generation-the-canvas-cac98ace99c3?source=rss-d92e0d535819------2</link>
            <guid isPermaLink="false">https://medium.com/p/cac98ace99c3</guid>
            <category><![CDATA[2d]]></category>
            <category><![CDATA[graphics]]></category>
            <category><![CDATA[canvas]]></category>
            <category><![CDATA[html5]]></category>
            <dc:creator><![CDATA[Jessica Torres]]></dc:creator>
            <pubDate>Mon, 06 Jul 2020 14:00:28 GMT</pubDate>
            <atom:updated>2020-07-21T03:25:12.115Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T2Ar7H7FTYN1hUqqPChCbw.png" /></figure><p>HTML5, the most recent, universally supported, backward compatible version of HTML, is also the version that brought about the addition of the <strong>canvas</strong> element. In short, it creates a drawing space for creating a fairly wide variety of dynamic graphics, using no more than rudimentary level HTML and vanilla scripting.</p><p>Within this article for the sake of establishing a clear understanding of the core points of canvas, we’ll cover the methods, properties, and shapes most frequently used. Next, the steps you’ll need to know to get started building your own interactive and animated canvas pages. Then briefly, how canvas measures up to other options for similar functionality and where the next steps in more advanced development in the realm might take you.</p><h3>CAPABILITIES</h3><p>There is actually a surprising number of things you can use the HTML5 Canvas element to build. Because it gives you control over the drawing area on such a detailed level, it is possible to create everything from static images and graphs to animations of varying complexity and fully fleshed out 2D games (or, even 3D with the help of outside Javascript API — specifically WebGL, talked about later in the article).</p><p><strong>Use Cases:</strong></p><ul><li>Any kind of animation or dynamic graphic</li><li>Offline and Online games (that in the past you may have had to have used Flash to create)</li><li>Audio and Video that is interactive</li><li>Static images, graphs, or other features</li></ul><h3>BASIC CANVAS TERMINOLOGY</h3><p><strong>Context — </strong>This is the drawing/rendering context you are required to set for the canvas element before you can begin working with it. It determines, basically, what the drawing area can be used for in particular.</p><p>The way to establish the context for the canvas element you are preparing to work with is through the <strong>getContext</strong> method. This method returns a “super object” that is stacked full of everything you will need to manipulate the features of the chosen context (2d components, 3d rendering, Image Bitmaps, etc.).</p><p><strong>Paths —</strong> Lists of points that are connected by lines. Forming anything other than a rectangle with canvas will be used by putting together some version of one or more paths.</p><p><strong>Grid Origin — </strong>You can recognize that the inside of the drawing space created by the canvas is essentially a grid, where each grid unit corresponds equally with a canvas pixel. The positioning of everything inside of the canvas is based on its relative distance, in any direction, from the grid’s origin (which is the top-left point, or coordinate (0, 0)).</p><h4>Methods to Bookmark:</h4><p>Specifically looking at the 2D context usage, which is the focus Canvas example for the purposes of this article, there are several methods you’d need to familiarize yourself with simply for how regularly you would be using them.</p><p>These methods become available once you have saved the result of the aforementioned <strong>canvas.getContext(‘2d’)</strong> to a variable.</p><p><strong>FILL —</strong> .fill()<br>Takes a shape and gives solid content to the inner region.<br>Depending on which shape you are trying to draw, there may be a specific fill method that will draw a shape and fill it immediately (fillRect for rectangles) instead of using <strong>.fill</strong> after the shape has been drawn.</p><p><strong>STROKE —</strong> .stroke()<br>Creates an outline for the shape, rather than solid, filled content.<br>Most important here is that (same as the fill method) even if you are successfully drawing objects to the canvas, <strong>none will show until a fill or stroke has been called for it.</strong></p><h4>Properties:</h4><p><strong>STYLE —</strong> .fillStyle <strong>OR</strong> .strokeStyle<br>These properties control the “styling” or coloring of a shape, whether for the inside fill or outline of the shape, respectively ^. <br>The value to be set here will be a string of a CSS color type, which can be anything you could set in actual CSS:</p><ul><li>CSS color name (‘orange’)</li><li>Hex Code (‘#RRGGBB’)</li><li>Decimal Code (‘rgb(R, G, B)’)</li><li>Gradient object</li><li>Pattern object</li></ul><p>If you do not set a fillStyle or strokeStyle before the fill or stroke method is called, the default color of the shape will be black.</p><p>Once any style has been set with either of these methods, every proceeding shape will adopt that last color set. <br>So remember that if you want any coloring to be different for individual elements, you will have to call whichever style method that is appropriate, directly before that elements fill or stroke call.</p><h3>HOW DOES IT WORK?</h3><p>All it really takes to get a canvas enabled page with stationary or moving, changeable elements up and running is an HTML file (as you <strong>should</strong> have a separate script file, with the amount of code that you’ll most likely have to add to it, but technically don’t have to and could include it all in a &lt;script&gt; section right in the HTML).</p><p><strong>The HTML</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*w31O6moIXILz-vxp1Bvz-w.png" /><figcaption>Set up within the index.html, where the canvas element is first created.</figcaption></figure><p>Easy to see here, as the canvas is fundamentally just another HTML element:</p><ul><li>It must be created the same way as usual. The <strong><em>&lt;canvas&gt;&lt;/canvas&gt;</em></strong><em> </em>tags have the same common attributes that are addable like ids, classes, etc.</li><li>Any styling for the element itself could happen within the style tags inside of the head (this would be the place to do things like setting a border for the canvas, changing the displayed background color from white, removing the margin that creates the gap between the perimeter and the sides of the pages, etc.). Or if there were a considerable amount more, you obviously have the option to create and link an external CSS file.</li><li>Then, as always, we link the file responsible for the JavaScript code that will control whatever we build within the canvas.</li></ul><p>It should also be acknowledged that, in the above index.html example, there has been a default display value set (‘Canvas Cannot Be Used In This Browser Version’). While canvas is a part of HTML5, the latest release of HTML, it is not supported in significantly older versions of most browsers. <br>It can also be the situation that some browsers will have JavaScript disabled, in which case the canvas element would again not show. <br><strong>The best practice is to inform the user, through some dummy value, why there is nothing rendering on the page.</strong></p><p><strong>The JavaScript</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*pR85X70nZva7wTpRw99pxA.png" /><figcaption>Set up for the canvas element. These things should be done prior to any object creation attempts.</figcaption></figure><p>At this point, the canvas element has been created within the HTML and must next be identified, having reference to it saved within the actual code, so that all aspects of it may be managed. Here we:</p><ul><li>Locate the specific canvas we intend to work with (The exampled does this just by finding the canvas element because in this case there is only one existing on the page. If there were more, ids could be set and they would found this way instead.) and set as the canvas variable.</li><li>Arrange the size of the canvas to fit the entire screen, instead of the <br><em>300px </em><strong>W</strong> <strong>x</strong><em> 150px </em><strong>H </strong>that both the canvas and it’s drawing area size default to.</li><li>Set the context of the canvas, determining which object will be returned and set to the c variable (c is actually commonly used as the abbreviated name for the context because it will be used so often throughout the code that single-digit length is much more optimal).</li></ul><p>From there, it really is mostly a matter of some simple geometry. Understanding a very base level would permit you to create any number of objects on the Canvas and control them simultaneously or individually, setting restrictions on how and where they can travel within the designated area and how they will react to each other, as well as (optionally) user input.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><h4>Creating Simple Shapes:</h4><p>There are two shapes that canvas has included functionality for creating: <strong>rectangles</strong> &amp; <strong>paths</strong>. As the foundational building blocks for simple to more complicated drawings, these two primitives can be used to form any shape you might need.</p><p>In the spirit of providing useful enough shapes, while still giving you something easy to animate, we’ll look at these main three: Rectangles, Lines, and Circles.</p><p><strong>Rectangles</strong></p><p>For Rectangles, there are two main ways to draw your shape:</p><ul><li><strong>.rect() </strong>is the base way to create a rectangle. Where you would next have to either call <strong>stroke()</strong> or <strong>fill()</strong> to see your rectangle appear on the page.</li><li>The second, and more shortcut way, would be to use one of the methods that combine the draw and the fill/stroke steps. Meaning, you would not have to follow up with another method call to see it show up in the canvas.<br>Between the shortcut set of options, you have your choice of drawing a hollow or filled rectangle: with either <strong>strokeRect</strong> or <strong>fillRect</strong>.</li></ul><p>Whichever you decide to use, all versions of the rectangle functions take the same arguments for the shape’s creation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*PF9Zo9s-gPqzF4kPrmCt8Q.png" /><figcaption>The (x,y) coordinates used to set the top left corner of the rectangle are relative to the top left corner of the canvas (the “origin” point of the grid).</figcaption></figure><p><strong>Lines</strong></p><p>Paths are used to draw lines on the canvas, where they can be extended by other lines at any point with the addition of new point coordinate sets that occur before that path’s related <strong>endPath()</strong> call.</p><p>It makes it easy to imagine if you think about it as you would drawing a line manually on paper:</p><ul><li>You decide to draw a line.<br>(in canvas: this is done with <strong>beginPath()</strong>, which signals a path is about to created and will continue through <strong>stroke()</strong> or <strong>fill()</strong> being called)</li><li>You choose a starting point and move your pencil to it.<br>(in canvas: you will use <strong>moveTo()</strong> passing the coordinates at which your line will start, which will move the drawing cursor to that point on the grid and begin drawing the line)</li><li>As you draw the line, you are deciding on points that will be included in your line.<br>(in canvas: we are identifying these as sub-paths and they will be added using the <strong>lineTo() </strong>method, which takes the “endpoint” for the current segment of the line and connects the previous point to it)</li><li>Once you reach the place your line will stop, you have chosen your ending point.<br>(in canvas: we want to signal that the current path (line) is finished and will not be added onto again at the moment. We want to make sure our line appears, we call either <strong>stroke()</strong> or <strong>fill()</strong>.)</li></ul><p>The <strong>moveTo</strong> and <strong>lineTo</strong> functions both accept (x, y) coordinate arguments. Outside of the regular line-drawing process we mentioned above, there is also <strong>closePath() </strong>that can be called after the last <strong>lineTo</strong> and will connect the final point of the line to the initial starting point (this can be used for several different things but creating a triangle is one of the most useful).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*_xyTgfgeNVn0sMaN44ysig.png" /></figure><p><strong>Circles</strong></p><p>Canvas does not have a designated circle shape but allows for the creation of arcs. With some very straightforward manipulation, we can use the arc type to draw some circles and get them on the page so we can start animating them.</p><ul><li>You still start with <strong>beginPath()</strong>,<strong> </strong>the same as if you were drawing a straight line shown above.</li><li><strong>.arc()</strong> is the method responsible for drawing the curve to the canvas and accepts the x coordinate, y coordinate, radius, and start and end “angles” (which are meant to be passed as radians and not actual degrees).</li><li>Following the arc being drawn, you set the style (optionally) and call the <strong>stroke()</strong> or <strong>fill()</strong> methods like usual to have it colored and shown on the page.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*mA6878ZM-rpZ0ALa9HqHeA.png" /><figcaption>The final argument to arc shown in the example above is an optional argument that allows the arc to be drawn counterclockwise. It defaults to false (which sets it to draw clockwise. While true would set it to draw the arc counterclockwise) but is still included as false above to show that it is a possible added argument.</figcaption></figure><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><h4>Creating Simple Animations:</h4><p>For the animation and interactivity code examples and explanations, we’ll keep it clean and simple by only looking at how we would accomplish these goals for a circle element on the canvas, rather than for all three shapes we created above.</p><p>This section would be broken down into two parts:</p><ol><li>Inbuilt Movements: A look at transformations native to the canvas.</li><li>Custom Animations: Creating your own animations and movements.</li></ol><p><strong>Inbuilt Movements</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*QcqBl-Ih_y8KuvPa4Bb1Hw.png" /></figure><p>These transformations are included in the context object returned from <strong>getContext(</strong>‘2d’<strong>)</strong> at the beginning of your code. In the examples we’ve seen so far, they would be accessed through the “<strong>c</strong>” variable (See below).</p><pre>const canvas = document.querySelector(&#39;canvas&#39;);<br>const c = canvas.getContext(“2d”);</pre><pre>c.rotate(20 * Math.PI / 180); <br>c.fillRect(200, 40, 100, 50);</pre><p>**Where rotate, specifically, will only affect shapes created after the rotate method has been called.**</p><h3>THE NEXT LEVEL</h3><p>Transitioning into 3D development from canvas’ contained 2D context is not a huge leap from what you’ve already seen up until this point. WebGL is an API that allows rendering for either 2D or 3D web content, and because it was created to work alongside canvas it is available as an argument option for the context function we learned about at the beginning of the article.</p><p>This means the only line in your canvas script code from above that you would need to change to start using WebGL would be the getContext line. It may look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*Pkxh_GXxRlZzXxxAtKrIyA.png" /></figure><p>Realize, also, that there are a number of frameworks that abridge WebGL’s abilities and make it somewhat easier to build the same three-dimensional games and applications (three.js being one of the most well-known). But, this does not take away from the value of knowing how to use the seed of the frameworks on its own (after all, how do you think three.js and the others like it were themselves built).</p><h3>CONCLUSION::</h3><ul><li>Canvas is an embedded element in the HTML, which means it is by nature part of the DOM and can interact with the DOM and any other elements in it. This puts it ahead of any embedded external file automatically.</li><li>Being part of HTML5, the canvas is natively supported by web browsers and does not require any kind of plugin installation (which other options like Flash do) or put any responsibility on the user for keeping up with install versions.</li><li>It takes very little time to learn how to use, as it is just a matter of becoming vaguely familiar with the few techniques used to create the graphics — for anyone who already knows a scripting language, they will already have the skillset to add functionality.</li></ul><p>You would likely be surprised to see how advanced some animations that are built without the help of any outside API can be; as well as how much farther you can take things with a little help from a 3D add-on. It would be worth checking out some of these examples of serious Canvas usage and picking up some inspiration for a Canvas project of your own.</p><p><a href="https://code.tutsplus.com/articles/21-ridiculously-impressive-html5-canvas-experiments--net-14210">Canvas Projects</a><br><a href="https://www.creativebloq.com/3d/30-amazing-examples-webgl-action-6142954">WebGL &amp; Canvas Projects</a></p><h4>Thank you for reading!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cac98ace99c3" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/dynamic-graphics-generation-the-canvas-cac98ace99c3">Dynamic Graphics Generation: The Canvas</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Material-UI: React Framework]]></title>
            <link>https://medium.com/@jess.torres_/material-ui-react-framework-465f3e69060e?source=rss-d92e0d535819------2</link>
            <guid isPermaLink="false">https://medium.com/p/465f3e69060e</guid>
            <dc:creator><![CDATA[Jessica Torres]]></dc:creator>
            <pubDate>Mon, 29 Jun 2020 14:00:45 GMT</pubDate>
            <atom:updated>2020-06-29T14:07:40.257Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*eNil9YJkPAAggKAG5NcLOA.png" /></figure><p><strong>Material-UI</strong> provides a large selection of easily integrated, reasonably customizable React components for building up your user interface quickly and cleanly. Installation is simple through npm or with a CDN and all of the core components (any material components that do not exist in the holding stage of The Lab, which we will talk about at a later point in the article) come injected with some basic CSS for styling.</p><h3>INSTALLATION AND IMPORTING</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*jnFFNgkYHcbLDgJwWCqIpg.png" /><figcaption>Installing Material-UI with npm OR using a CDN will both give you access to all core Material components.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*fHgpHGwIl4ci2gJePYKdfw.png" /><figcaption>Both lines are accessible through the Material-UI docs h<a href="https://material-ui.com/">ttps://material-ui.com/</a></figcaption></figure><p>It’s important to also note that the Material-UI framework is built with Roboto as the designated default font and will require you to also include a link in your html file, in order for the text type components (such as Typography) to work properly.</p><p>Icons bring a second, separate step to the installation process. While including the material icons library link in your html will grant you access to the Icon component, you will also need to install the material icons package from npm if you plan to use any SVG icons in your project. All three lines (links and command) are shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*8znbgmOdo1wU77gf4BJL_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*WKly_kJXBD-MJic55o0QBg.png" /><figcaption><a href="https://material-ui.com/components/material-icons/">This is the page where you can find all usable icons from the package as well as see code snippets on how naming and referencing would need to take place in your project</a></figcaption></figure><h3>THE LAB</h3><p>Any components that exist in the Lab section of the Material-UI documentation pages are usable but have not been deemed fully fit to be integrated into the “core” or the components that are dispensed with the base installation. This means that you will have to install the lab package separately and also that when importing it will require it’s own line and cannot be combined with destructuring the same way all of the core components can. The installation command is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/1*MewDcwxpQeGjuKnhfOzwqQ.png" /></figure><p>Styling is much more limited for these components and fewer have the added ability of easily controlling props that you can pass down, and building custom functionality (like most of the core components enable you to do).</p><h3>CONCLUSION::</h3><p>Material-UI offers a great option for building your React projects in a smart way, without using entirely from-the-box components.</p><p>The problem with a lot of the frameworks and libraries meant to make your front-end coding life easier is that they also take a lot of the decision-making capabilities out of your hands. In losing those choices, you often wind up in a tougher situation than you would have been in just building everything from scratch (You usually can’t customize the styling the way you’d like to, and sometimes will have trouble implementing the full functionality that you’d like).</p><p>Material-Ui is definitely one of the good ones out there that balances both sides.</p><h4>Thank you for reading!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=465f3e69060e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NPM and The Anatomy of package.json: Part Two]]></title>
            <link>https://medium.com/@jess.torres_/npm-and-the-anatomy-of-package-json-part-two-833c270fdc8a?source=rss-d92e0d535819------2</link>
            <guid isPermaLink="false">https://medium.com/p/833c270fdc8a</guid>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[dependencies]]></category>
            <category><![CDATA[packagejson]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Jessica Torres]]></dc:creator>
            <pubDate>Mon, 01 Jun 2020 12:13:43 GMT</pubDate>
            <atom:updated>2022-05-03T15:08:42.331Z</atom:updated>
            <content:encoded><![CDATA[<p>In Part One of the post (<a href="https://medium.com/@jes.tores2277.jt/npm-and-the-anatomy-of-package-json-part-one-d9547b47af77">link</a>) we talked about NPM — What it is and How it’s used. Now we shift the focus onto the package.json and the role that it plays in relation to NPM.</p><p>If there is any uncertainty as to what a particular element in the package.json is responsible for, there shouldn’t be by the end of this post.</p><h3>WHAT IS THE PACKAGE.JSON FILE?…</h3><h4>(And Who Let It Into My Project?)</h4><p>Package.json is essentially npm’s config file for your modules/projects. This is where you can easily see the project’s key information, manage the dependencies, affect the places that the project can appear, and determine how files can be run inside of the testing and development environments</p><p>It should be noted that your project must have a package.json file before you will be able to install any packages from npm or be able to publish your package to npm. The file itself is made up of a few (by npm’s standards) necessary, and a number of optional, properties. As for where package.json comes from, there are two ways to add one to your project:</p><ol><li>Running npm init -y will initiate a new project with the npm package manager and write a package.json file to the current directory. The -y answers yes to the series of questions npm asks you regarding the default values to appear in the file, which you can change at any point.</li><li>If for some reason, you wanted to write directly to a file you can do that also. Creating the custom package.json, with the correct configurations, and then making sure to include it in the right directory in your Node project.</li></ol><h3>PIECE BY PIECE — — — — PACKAGE.JSON</h3><p>For the sake of our anatomy lesson let’s reference this sample package.json from a project that uses Mysql, Express, and React.</p><p>The file is written in the JSON format so that it can be read programmatically by sources trying to access its properties, and the contents of the file can be divided into two categories of metadata:</p><ul><li><strong>Identifying- </strong>Where the property presents information about the project itself (who created it, what purpose it serves, etc). We’ll mark these properties with an <strong>-I-</strong> for identifying.</li><li><strong>Functional- </strong>Where the property presents some functional value of the module/project. We’ll mark these properties with an <strong>-F-</strong> for functional.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*uca54pYMxlVBdqcN8dxADg.png" /></figure><h4>NAME &amp; VERSION:: -I-</h4><p>In the case where the package is going to be published, it is mandatory for these two properties to be defined and given a value inside of the package.json.</p><ul><li>The value of the <strong>name</strong> property is exactly what you would expect it to be.</li></ul><p>Know that if you decide to publish to the NPM directory, this is the name that your package will be listed under.</p><p><strong>Limitations on naming include:</strong></p><p>— A maximum of 214 char (If you plan to publish, the name must be unique from any other published package in the registry)<br> — Only lowercase letters<br> — Hyphens &amp; Underscores are acceptable. No other special char. or spaces allowed.</p><ul><li>The <strong>version </strong>is the current version of whatever software the package.json is describing. It follows typical version semantics and should be kept up to date so that any other developers can be properly informed on what version of the package the project is designed to run with.</li></ul><h4>DEPENDENCIES:: -F-</h4><p>Running the command npm install ___ with some package name, will install that package as a dependency and will automatically place that new dependency inside of this dependencies key’s object in the package.json file.</p><p>This is also where you will keep track of the versions of each dependency that the program relies on to run.</p><p>If you add --save-dev, or the-D flag, you effectively install it as a development dependency, described below. (This, of course, adds it to the devDependencies list instead of dependencies.)</p><h4>DEV-DEPENDENCIES:: -F-</h4><p>Development dependencies are dependencies that are intended as development-only packages. They are supposed to be unneeded in production (like webpack, Babel, or testing packages).</p><p>When someone runs npm install, without the — production flag, on a package that has devDependencies specified in the package.json, all of the dependencies and devDependencies will be installed (without the production flag to tell it otherwise, npm assumes it is a development deploy).</p><h3>CONCLUSION::</h3><p>Hopefully, these posts together have shed further light on some familiar technologies and helped to plainly define some vague terms we use on a daily basis.</p><p>Go forward and look into some of the extremely useful things you can do with tools like the scripts section of the package.json, and the next time you catch yourself about to run a command or pass up a file and you aren’t sure what it’s doing, take a second to stop and figure it out.</p><h4>Thank you for reading!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=833c270fdc8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NPM and The Anatomy of package.json: Part One]]></title>
            <link>https://levelup.gitconnected.com/npm-and-the-anatomy-of-package-json-part-one-d9547b47af77?source=rss-d92e0d535819------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9547b47af77</guid>
            <category><![CDATA[installation]]></category>
            <category><![CDATA[package-management]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[npm]]></category>
            <dc:creator><![CDATA[Jessica Torres]]></dc:creator>
            <pubDate>Mon, 01 Jun 2020 11:04:46 GMT</pubDate>
            <atom:updated>2020-07-10T15:20:25.619Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T-15C0SVMxCAN5rg6TM-1w.jpeg" /></figure><p>As developers, there is any number of benefits to having provided to us these amazing technologies that handle large amounts of the setup and execution stages of our code. <strong>But</strong> with those conveniences comes also a large potential for gaps in knowledge — especially in a learning environment (whether through a program or in teaching yourself) where you are often supplied the starter shells of projects, that come equipped with libraries, frameworks, and lines of pseudocode that without explanation instruct you to // Run ‘npm install’</p><p>You could make it through several complete projects without ever really needing to know where certain files are coming from or all that they’re doing. Ask someone in that position to show you how they start their server or run their test suite and they can probably produce the right answer, having memorized the command from typing it so many times — asking them to explain how that command works or where it comes from may give them a harder time.</p><p>Looking at just two of the bigger examples of this, first in NPM and what comes along with it and second (in Part Two of this post (<a href="https://medium.com/@jes.tores2277.jt/npm-and-the-anatomy-of-package-json-part-two-833c270fdc8a">link</a>) at any sense of mystery surrounding the package.json file, let’s clear away some of that confusion…</p><h3>The Relationship Between NPM and Node.js</h3><p><strong>What is npm? </strong>Npm is Node JavaScript platform’s default package manager; it was the first package manager and registry for Node and remains the most widely used.</p><p>— If you’re wishing here that we were also defining <strong>packages</strong>, <strong>package managers</strong>, and some other base terms, let’s take a second to do so:</p><ul><li><strong>Package: </strong>A file or directory that the package.json describes.<strong> </strong>They can be Node modules themselves or simply contain Node modules.</li><li><strong>Package Managers: </strong>Software tools that exist to automate the processes that relate to not only installing these packages, but maintaining, updating, configuring, and removing them.</li><li><strong>Package Registry:</strong> The database where all of these packages that are then published, are stored. (Npm actually has an API that allows developers access to the registry from inside their program, making it possible for package managers other than npm (like <strong>yarn</strong> and <strong>pnpm</strong>) to download from the npm registry.</li><li><strong>Dependencies: </strong>Anything that is required for your program to “work”. There is a section in the package.json devoted to these that we will talk about later, but for now, just understand a dependency can refer to anything that a package can be. (It can also be used to refer to a module that is imported by a file, but only if that imported module is then utilized within the file.)</li></ul><p>That being said, we can acknowledge that npm is part of the deal with Node (meaning it is installed also, when you download Node). It is there to make your life easier, or at least the parts of it that you spend working with JavaScript in a Node environment.</p><blockquote>Most commonly, it is used to publish, discover, install, and develop node programs. — <strong>The NPM Documentation</strong></blockquote><h4><strong>There are 3 individual but related components of NPM itself:</strong></h4><ol><li><strong>The Actual NPM site:</strong> The website where a user can create an account for npm, set up profiles, manage access to private and public packages, and more.</li><li><strong>The NPM CLI (Command Line Interface):</strong> The CLI runs in the developer’s terminal and allows interaction with npm from inside of the project.</li><li><strong>The NPM Registry: </strong>The largest part of the operation, the registry is the open database of packages and projects. Think of it like a marketplace or even JavaScript software App Store of sorts.</li></ol><p>It would be ambitious to try and cover the list of commands available to you through npm but the next time that you can, run `<strong>npm help` </strong>in your terminal and check out what all you have to choose from. For the purposes of staying in the general scope of npm we’ll mostly cover the basics of package and dependency installation specifics.</p><h3>NPM — LOCAL vs GLOBAL INSTALLATION</h3><p>When the time arrives to start installing dependencies, npm provides you with two mode of operation options: Local and Global.</p><p>Npm install will default to local mode, so if you want to globally install a dependency you must specify in the command line (one way to achieve this is with the -g or--gflag).</p><h4>Local::</h4><p>Local packages will be installed into whatever directory you are currently inside of when you run npm install __, this is also the directory where the associated node_modules folder will be added.</p><p>Installing locally makes it possible to maintain however many applications you house on your computer, with some (or all) of them running different versions of the same packages (if necessary).</p><p>If the package provides an executable command (meant to be run from the CLI) it will be reused across all projects, that is a package that should be installed globally. Examples would be create-react-app, vue-cl, grunt-cl, mocha, and of course npm.</p><h4>Global::</h4><p>Global packages, on the other hand, are not installed by relative positioning — they will all be added to one single location inside of your system. That single location will depend on how your setup is configured.</p><p>To start, only one package will be installed globally (the npm package itself). When any other package is installed globally after that, <strong>and you are not using a version manager</strong>,<strong> </strong>the package will be saved in the folder owned by the root directory ({some prefix}/lib/node_modules/).</p><p>In this situation, it is important to:</p><ul><li>Identify the current global location (which should be the prefix of the node bin location path).</li><li>Change the global location to something like the Home directory. In redirecting, we ensure that globally installed packages will be added to whatever new, user-owned directory you’ve added to Home (which allows you to global install without having to usesudo).</li></ul><p>Once you have more than only the npm package installed globally, it can start to be harder to discern which dependencies are installed where. npm list -g --depth=0in the terminal can answer this question — npm list -gcan be run on its own but adding the depth option cleans up the format in which the results are returned.</p><h3>CONCLUSION::</h3><p>Hopefully, this first half of the post has served to give a little more information on what npm truly is and how some of the installation specifics work.</p><p>It should have set up a foundation of understanding, upon which we can continue to build with Part Two (<a href="https://medium.com/@jes.tores2277.jt/npm-and-the-anatomy-of-package-json-part-two-833c270fdc8a">link</a>) where we will look closely at the package.json file in particular.</p><h4>Thank you for reading!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9547b47af77" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/npm-and-the-anatomy-of-package-json-part-one-d9547b47af77">NPM and The Anatomy of package.json: Part One</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cryptography: Symmetric vs Asymmetric Encryption]]></title>
            <link>https://levelup.gitconnected.com/cryptography-symmetric-vs-asymmetric-encryption-db36277c8329?source=rss-d92e0d535819------2</link>
            <guid isPermaLink="false">https://medium.com/p/db36277c8329</guid>
            <category><![CDATA[comparison]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[cryptography]]></category>
            <dc:creator><![CDATA[Jessica Torres]]></dc:creator>
            <pubDate>Mon, 18 May 2020 13:58:47 GMT</pubDate>
            <atom:updated>2020-05-21T17:05:41.289Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IWsbgLgGeA5ArdAUKA-_XA.jpeg" /></figure><p>Before the modern age of cryptography, where the focus has expanded from the confidentiality of messages to encompass identity authentication, integrity checking, and more, the field mainly revolved around lexicographical and linguistic patterns.</p><p>With the addition of digital computers and the beginnings of the extensive use of mathematic theory and computer science practices in cryptography, the ability to “crack” complex encryption algorithms increased, but along with it, the speed at which increasingly complicated, computationally secure (albeit, theoretically breakable) encrypting mechanisms could be created.</p><p>Here, we’ll take a look at the two kinds of cryptosystems: symmetric and asymmetric.</p><h3>SOME BASIC CRYPTOGRAPHY TERMINOLOGY</h3><p><strong>Key</strong> — A “variable value” that is applied to some unencrypted message, using an algorithm (cipher), in order to encrypt it. Or applied to an encrypted message, in order to decrypt it.</p><p>The key is meant to be kept secret and should only be known by the sender and recipient of the message. This way if the message were to be captured by any outsider participant, it would read as nonsense and should provide no useful information.</p><p><strong>Plaintext — </strong>Unencrypted information. Usually, but not always, awaiting input into an encryption algorithm.</p><p><strong>Cyphertext —</strong> The result of the encryption of plaintext. Unreadable by a human or computer alike, without the proper decryption algorithm.</p><p><strong>Cipher —</strong> An algorithm. It is used to perform encryption on plaintext, decryption on cyphertext, or can be used to do both. Ciphers can be categorized as “procedures” of sorts, series of detail defined steps that can be followed. The way in which the cipher operates will depend on the key selected, which acts as the auxiliary information. So, a key must be chosen before a cipher can be used to encrypt a message.</p><p><strong>Cryptanalysis</strong> — In short, the study of decrypting messages (“cracking the code” of the encryption algorithms) without access to the key that was designed to do so.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>CASTING CALL</h3><p>For the sake of the rest of the article I will introduce you now to three commonly used players in the game of cryptography:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0NVHx5Te_3U34Mg3LW-PHA.jpeg" /></figure><ul><li><strong>Alice (‘A’)</strong>, who we cast the part of our sender. She wishes to relay some message or data to another party.</li><li><strong>Bob (‘B’)</strong> the intended recipient of the sent information. He plays the part of Alice’s confidant.</li><li><strong>Eve (‘E’)</strong>, our deceptively nicknamed, “passive” attacker. Short for Eavesdropper, this antagonist can listen in on the exchanges between Alice and Bob but cannot modify their messages as they are being sent back and forth. Their goal would simply be to successfully decrypt an overheard message. (This is different from a Mallory (‘M’), an “active” attacker, who can intercept and directly alter or substitute out a sent message before the second party ever receives it. Mallory participants in the game present more challenging obstacles to creating a safely secured system than Eves do.)</li></ul><p>These are short explanations of only a few characters. Four, of the dozens of conventional archetypes, used to aid in comprehension in discussions of cryptology, as well as other science and engineering texts, and (for “Alice” and “Bob” at least) even in game theory and physics thought experiments.</p><p>With the basic definitions provided, and the roles handed out, let’s set the stage to illustrate our two types of cryptosystems.</p><h3>SYMMETRICAL ENCRYPTION</h3><p>The only type of encryption publically recognized until the late 70s, symmetric key ciphers will either be of the block or stream variety.</p><ul><li><strong>Stream Ciphers — </strong>encrypt the letters or digits (usually bytes) of a message one at a time.</li><li><strong>Block Ciphers — </strong>gather some number of bits and then encrypt them as one single unit. Then pad the plaintext, making it a multiple of the block size (64-bit blocks were regularly used).</li></ul><p>Symmetrical encryption involves one singular key, for both encrypting and decrypting the message. This means the sender and recipient must have the same key available to them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KtWZBZt4j_vUn7QU2p9LGw.jpeg" /></figure><h4>How Does It Work?</h4><p>It’s really as simple as:</p><ul><li>Alice uses her private key to encrypt the message she intends to send.</li><li>She then passes that encrypted message along to Bob.</li><li>When Bob receives the encrypted messaged he proceeds to decrypt it, with the same private key that Alice used.</li></ul><p>Easy as that, one key — two (or possibly more) people.</p><p>Well…hold on. Addressing the question “How can Bob have the same private key as Alice?” leads us to the central, and major, flaw in the Symmetrical scheme. In order for Alice and Bob to have the same private key, it has to be handed off at some point between them, which opens the door for an Eve, or even a Mallory, to intercept the key and effectively render it useless in securing their communication of information.</p><h3>ASYMMETRICAL ENCRYPTION</h3><p>Also known as <strong>public-key cryptography</strong>, this is the much newer adaptation to the age-old symmetrical type above. The process here requires not the use of two identical keys, but for each party (sender and recipient) to have their own set of individual keys. (This makes the initial sharing of private keys unnecessary and eliminates the added risk associated with symmetrical.)</p><p>The first key is still referred to as the “<strong>private key</strong>”, but in this case is unique to the holder and must now be kept completely secret (even from the other party, sender or recipient). The second is called the “<strong>public key</strong>” and can be distributed freely, as it is not responsible for decryption (only encryption). These two keys are different, while still related mathematically, which means it is not meant to ever be possible for one key to be calculated based on knowledge of the other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1iEU3IGVmtpVDwr-_Vu9Yw.jpeg" /></figure><h4>How Does It Work?</h4><p>A slightly more complicated process:</p><ul><li>Alice and Bob both generate a public and private key for themselves (they use the RSA algorithm)</li><li>Alice sends Bob her public key and Bob in turn sends Alice his public key. (Neither reveals their private key to anyone else.)</li><li>Alice writes a message again, but this time encrypts it with Bob’s public key. She then sends the message along to Bob.</li><li>When Bob receives the encrypted message, he uses his private key to decrypt it and reads the message Alice wrote.</li></ul><h3>Between The Two</h3><ul><li>Data manipulation in symmetrical encryption is much faster than in asymmetrical because it utilizes only one key and because the lengths of the keys used are usually shorter.</li><li>Asymmetrical encryption is hardly ever used to directly encrypt large amounts of data, unlike symmetric; it increases the size of the cryptogram and can leave the data to take up more space in storage or more time to move. For decryption especially, the performance to security ratio with the asymmetric scheme is typically less impressive than in the symmetric scheme. As security increases, the efficiency of decryption decreases.</li><li>Most public-key algorithms involve more computationally expensive operations (exponentiation, for example).</li></ul><p>Given what we know about both, the obvious pros and cons of each scheme, it seems like symmetrical appears “better” in most categories, with the exception of its glaring “sharing the key” flaw.</p><p>………………………………………………………</p><h4>Enter, stage left, the <strong>hybrid cryptosystem</strong>.</h4><p>A combination of any data encapsulation scheme (a symmetric-key cryptosystem), which supplies the efficiency, and any key encapsulation scheme (an asymmetric-key cryptosystem), which provides the convenience.</p><p>A simple example of a hybrid implementation:</p><ul><li>A symmetric-key encryption algorithm of high quality is applied to the message.</li><li>The symmetric key itself is then encrypted using a public-key algorithm.</li><li>The encrypted symmetric key is sent along with the message.</li></ul><p><strong>KEY POINT:</strong> Essentially all practical asymmetric schemes in effect today employ some version of a hybrid system optimization.</p><h4>Thank you for reading!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db36277c8329" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/cryptography-symmetric-vs-asymmetric-encryption-db36277c8329">Cryptography: Symmetric vs Asymmetric Encryption</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tops Down & Bottoms Up: Two Software Design Strategies Explained]]></title>
            <link>https://medium.com/swlh/tops-down-bottoms-up-two-software-design-strategies-explained-904ecf2b1b1d?source=rss-d92e0d535819------2</link>
            <guid isPermaLink="false">https://medium.com/p/904ecf2b1b1d</guid>
            <dc:creator><![CDATA[Jessica Torres]]></dc:creator>
            <pubDate>Mon, 11 May 2020 14:00:46 GMT</pubDate>
            <atom:updated>2020-05-17T14:51:35.442Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1eaVj7l0s9O1D-wF3GfaLQ.jpeg" /></figure><h3>WHAT ARE WE TALKING ABOUT?</h3><p>Let’s lay some groundwork understanding down on the subject of the SDLC (Software Design Life Cycle) before we head straight into the differences between the Top-Down and Bottom-Up strategies. The general stages of the SDLC are:</p><h4>PLANNING -&gt; DEFINING -&gt; DESIGNING -&gt; BUILDING -&gt; TESTING -&gt; DEPLOYMENT</h4><p>and the big-picture way in which a software development team decides to approach these stages would be called their System Design Strategy. Specific SDPM (Software Development Process Models) exist which fall under the umbrella of one or the other of these two strategy types, and many that work to combine the two ideas in some way. Some examples of these software methodologies include Waterfall, Iterative, Big Bang, and Agile.</p><p>Now, we will look at the most important, most used software development methodologies in both detail and comparison in another post. Here, however, the focus is on the most general concepts of the two head category styles of design that you can follow, Top-Down and Bottom-Up.</p><h3>THE TOP-DOWN APPROACH</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nTGZibMedxIfhY3E8K4qCQ.jpeg" /></figure><p><strong>W</strong>ith the Top-Down strategy the system, as a whole, is defined first. Only then can the system be split into descending levels of subsystems and components, with characteristics determining what is combined, and where. This process only ends once the lowest level to which the system can be broken down has been hit.</p><p>Steps of this style can also be referred to as “decomposition” and “stepwise refinement”. Treating each subsystem or component as its own system and breaking it down further and further, each level becoming more specific in focus than the last, you are left with a hierarchical model that looks similar in appearance to that of a Tree data structure.</p><h4>Draws:</h4><ul><li>More freedom in creation. You are able to focus on solving one problem at a time and are allowed to direct your focus toward solutions in almost any order. Because the stability of the whole structure is not determined by every individual higher-level subsystem or component, you could continue building one “branch” of downward extending specificity and circle back to extending another, if you wanted to.</li></ul><h4>Flaws:</h4><ul><li>You may miss out on the opportunity to reuse components</li><li>You may wind up with an overly complicated or poorly structured project by the time of completion.</li></ul><h3>THE BOTTOM-UP APPROACH</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NlIPCdsOQDRyWLSdGBEr5w.jpeg" /></figure><p><strong>T</strong>his version of strategy begins on the ground floor and is built upward, one level at a time. The idea here is that in starting with the most specific and basic components, you can utilize them in the creation of the next highest, following component. This process continues until you’ve hit the point of system completion.</p><p>As you move upward in construction the original, lower components become the sub-systems of the emerging “super- system”. With the Bottom-Up style, the amount of abstraction and the height of the component is proportional.</p><p>— — — — — — — — — — —</p><h4>Draws:</h4><ul><li>Time and money are often saved when components and solutions, in general, can be reused.</li><li>Existing structures can be combined with each other or with new structures with less complication than Top-Down.</li></ul><h4>Flaws:</h4><ul><li>You are much more limited in the way you must problem solve. In order for a base component to be used in its higher component counterpart, it must be fully functional. This means you cannot begin creating upper levels until the base level is solidly built.</li></ul><h3>CHOOSING BETWEEN THE TWO</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZrR3mVwBKNpizb-oiCJLnw.jpeg" /></figure><h4><strong>Simplified Examples Of An Easily Made Choice:</strong></h4><ul><li><strong>If you are creating a system from scratch: </strong>The specific details of the entire project are likely unknown because they have not all been discovered yet, which makes it easier to break down the general system, bit by bit, conceptually before beginning. In these cases, it is not impossible to attempt coming up with solutions to guessed problems.</li><li><strong>If you are creating a system from an existing system:</strong> In these cases, there is some amount of information and process that is already in place. That makes it much easier to use a Bottom-Up style, where the basic components of the old system can be incorporated into the creation of the new.</li></ul><h3>CONCLUSION::</h3><p>Here, we’ve reached it! The point at which I give you a takeaway that you probably expect. There is no surprise, secret, better choice between the two; in practice, it is often true that the design strategy chosen and the model followed will be some hybrid result of Top-Down and Bottom-Up bred together.</p><p>Embrace the idea of the two as opposites of sorts, acknowledging and understanding the draws and flaws of both and be aware that you’ll most likely be striking a bargain for balance, somewhere closer to the middle ground between these two extremes.</p><h4>Thank you for reading!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=904ecf2b1b1d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/tops-down-bottoms-up-two-software-design-strategies-explained-904ecf2b1b1d">Tops Down &amp; Bottoms Up: Two Software Design Strategies Explained</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing Your Technical Debt]]></title>
            <link>https://medium.com/swlh/managing-your-technical-debt-aecd4fb43c83?source=rss-d92e0d535819------2</link>
            <guid isPermaLink="false">https://medium.com/p/aecd4fb43c83</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming-tips]]></category>
            <category><![CDATA[technical-debt]]></category>
            <category><![CDATA[concept]]></category>
            <dc:creator><![CDATA[Jessica Torres]]></dc:creator>
            <pubDate>Mon, 04 May 2020 08:23:38 GMT</pubDate>
            <atom:updated>2022-05-03T15:16:08.999Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CsJLye5LZp9b9DU8TMzS7w.jpeg" /></figure><h3>WHAT IS TECHNICAL DEBT?</h3><p>If you’ve ever worked on a professional project or even just an assignment, writing code, you’ve almost definitely heard an adage similar to “Get it working”. As programmers we are encouraged, more often than not, to worry about the passing tests or the basic functionality first, and the optimization of our code second. One of the major problems with this is that the projects and the assignments never stop coming and it very swiftly becomes impossible to actually circle back. You wind up leaving this trail of technical I.O.U.s behind you, promises of cleaner and more efficient code, edge cases you made note of but also made the decision to take care of later on, changes that you may have every intention of making in the near future but most likely never will. This leaves a mess for one of two people, future you or future “other guy” programmer (neither of whom will appreciate the added workload).</p><p><strong>These consequences of “limited solutions”, the implied costs of any and all additional reworking that has to be completed, they are what we refer to as Technical Debt. </strong>To be clear, technical debt is not always a result of a decision made in the moment by a programmer, and we will see more on the other situations that result in debt later on in this post. But in truth, a lot of the time you’ll spend as a developer will just be spent taking care of some form of these technical debts, and as such, it is in everyone’s best interest to try to minimize these debts early on.</p><h3>HOW DOES IT ACCUMULATE?</h3><p><em>Very. Quickly.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L4FuFkCaZHkhIJlPIN2Gng.jpeg" /></figure><p>That is obviously an overly simple and short answer. More specifically, sometimes the decisions to take a shortcut or prioritize a deadline lead to technical debt, and sometimes the debt is inevitable because the flaw could not have been foreseen at the time of the project’s original completion. We can see two clear categories forming here, then, recognized as <strong>Deliberate</strong> and <strong>Inadvertent.</strong></p><h4>Let’s look at a handful of the dozens of individual possible causes:</h4><ul><li>Poorly made decisions in the planning stage or sudden changes in the middle of development, fed down the chain of command.</li><li>Completely neglecting to designate time for planning or design phases, where requirements are still being laid out but development has already begun.</li><li>When shortcuts are taken on the spot by developers, for any number of reasons (pressure to meet a fast-approaching deadline, quick bug fixes, etc.).</li><li>Writing code but leaving no related documentation, the necessary work to add documentation later is considered debt.</li><li>A gap in individual knowledge or skill needed for a specific task or the general understanding of what constitutes clean or optimized code.</li><li>Any instance of refactoring code or aligning code with industry standards.</li></ul><h3>HOW CAN YOU HANDLE IT?</h3><p>The issue here is that once you have acquired some technical debt, by one means or another, the only real way to get rid of it is to buckle down and pay it off. So really, in this case the best defense is a prudent, preemptive offense.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gS-UL_gURu8PiyIsizwhpw.jpeg" /></figure><h4>Play It Smart From The Jump::</h4><ul><li>Give the planning and design steps the appropriate amount of time. If the development phase is rushed into, you are all but guaranteeing yourself some technical debt.</li><li>Find the balance between taking the fastest route and taking the longest, to a completed project. There is a middle ground you can reach to make sure that your code is still the best it can be at the time that it must be finished. If this means making a deadline a little uncomfortable, just acknowledge the amount of time and the amount of money, you are saving everyone in the long run.</li><li>Make sure you are actually working with the best toolbox that you can be, at any given point in time. Keep your knowledge of best practices and new features of languages that you use regularly fresh. In this way, you can at least be sure that you are not unwittingly causing debt by using already outdated methods or shortsighted techniques. Bits and pieces of the code will all be outdated eventually and have to be reworked, don’t speed up that timeline by falling behind in what is current and presently preferred.</li><li>Relay expectations as well as changes in the big picture or day to day plans, to everyone. Technical debt occurs in great proportions when teams are not sharing progress made or problems encountered with each other. It becomes impossible for every individual member of a project to be making the best, most informed choices for their contributions if there is no network for communication that is not only set in place and maintained but frequently utilized.</li></ul><h4>Break It Down, Knock It Out::</h4><p>At the point in which you are no longer trying to keep from creating new debt, but managing existing debt, your strategy obviously shifts. Understand the importance of dealing with technical debt before it has a chance to start building interest. Often it can feel like fixes can be put off as another day’s problem, but days add up at an alarming rate.</p><ul><li>First, always be upfront and honest with all parties (this includes the development team, superiors, product owners, and the organization as a whole) when some technical debt is discovered. Keeping everyone involved informed on the size of the debt and the immediate plans to work it off is the first and most important step toward resolving the issues.</li><li>Remember it is often impossible to know how long it will take to rid yourself entirely of your technical debt. Meaning, it will be very difficult to factor the excess debt work into the already full schedule, but it must be done. Make the time and space wherever you can and if it becomes impossible to continue the new work in progress at the same rate then that work should be lessened to make it feasible for the debt work to be taken care of. It is likely that a new deadline may need to be lobbied for in this situation, but assuming you have been transparent across the board you can at least show how much additional work (approximately) is required, what the plan is to complete the tasks at hand, and how much progress has been made so far. (Hopefully in never comes to this point.)</li></ul><h3>CONCLUSION::</h3><p>The reality of it is that technical debt is pretty much unavoidable, which means the goal then becomes limiting the amount you build up. Be cautious of any choice that “helps us now, but hurts us later”. Be as conscious as you can of what you are doing and how well you are doing it, throughout every phase of the process. At the point that you recognize some debt forming, handle it as soon as possible!</p><h4>Thank you for reading!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aecd4fb43c83" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/managing-your-technical-debt-aecd4fb43c83">Managing Your Technical Debt</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>