<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Benaiah Barango</title>
    <description>The latest articles on DEV Community by Benaiah Barango (@bambie1).</description>
    <link>https://dev.to/bambie1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F381211%2F7f51af4c-a337-4d56-8a46-774595c6df62.png</url>
      <title>DEV Community: Benaiah Barango</title>
      <link>https://dev.to/bambie1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bambie1"/>
    <language>en</language>
    <item>
      <title>Building the Front-End for SoPlugged (a platform for Black-owned businesses)</title>
      <dc:creator>Benaiah Barango</dc:creator>
      <pubDate>Tue, 11 May 2021 22:41:30 +0000</pubDate>
      <link>https://dev.to/bambie1/building-the-front-end-for-soplugged-a-platform-for-black-owned-businesses-2h8f</link>
      <guid>https://dev.to/bambie1/building-the-front-end-for-soplugged-a-platform-for-black-owned-businesses-2h8f</guid>
      <description>&lt;p&gt;Hello! Brief introduction: I'm Benaiah, an Ottawa-based Full-Stack developer. Nice to meet you!&lt;/p&gt;

&lt;p&gt;TL;DR: I did some freelance work for SoPlugged (a platform to find black-owned businesses in Canada). Check it out &lt;a href="https://www.soplugged.com"&gt;&lt;code&gt;here&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I wanted to document how I built this platform, and what tools I used.&lt;/p&gt;

&lt;h2&gt;
  
  
  Front-end Library
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/"&gt;&lt;code&gt;React&lt;/code&gt;&lt;/a&gt;, easy! Being very conversant with React, and enjoying the benefits of easy state management made this an easy choice.&lt;br&gt;
However, when the all-too-familiar &lt;a href="https://blog.logrocket.com/how-next-js-can-help-improve-seo/"&gt;issue of SEO&lt;/a&gt; came up, especially for the landing page, I made the executive decision to migrate to &lt;a href="https://nextjs.org/"&gt;&lt;code&gt;Next JS&lt;/code&gt;&lt;/a&gt; (a.k.a Server-side React).&lt;/p&gt;

&lt;h2&gt;
  
  
  Styling
&lt;/h2&gt;

&lt;p&gt;Again, for this, choosing what I was familiar with was key. And, that was &lt;a href="https://material-ui.com/"&gt;&lt;code&gt;Material-UI&lt;/code&gt;&lt;/a&gt;. I've been using Material UI for a while now, primarily because of the components they provide 'ready-made'. I was a little worried about performance based on certain articles I had come across, but we'll discuss this in a subsequent article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Back-end
&lt;/h2&gt;

&lt;p&gt;I didn't have to handle this. A Ruby developer created the API and database using Rails.&lt;/p&gt;

&lt;h2&gt;
  
  
  Search Functionality
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.algolia.com/"&gt;&lt;code&gt;ALGOLIA&lt;/code&gt;&lt;/a&gt;.&lt;br&gt;
Front-end search can easily be implemented by adding an input and querying your database on every keystroke, or when the user stops typing (to reduce how many times you'd have to hit the database).&lt;br&gt;
This is what I started off with, till I came across Algolia.&lt;br&gt;
Simply put, Algolia is VERY good when it comes to search. When configured, it routinely indexes your database to get all new information, so searches are hitting Algolia instead of your database directly. This results in a faster and more-efficient search experience.&lt;br&gt;
You also get ready-made and easily customizable widgets for your front-end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Form Handling
&lt;/h2&gt;

&lt;p&gt;Forms are a critical aspect of a user's experience on a website, and so, should be properly created and easily navigated by the user. &lt;br&gt;
I usually opt for &lt;a href="https://react-hook-form.com/api"&gt;&lt;code&gt;react-hook-form&lt;/code&gt;&lt;/a&gt; to properly handle form validation (however complex), displaying error messages and handling other events.&lt;br&gt;
But, I had to switch to &lt;a href="https://formik.org/"&gt;&lt;code&gt;Formik&lt;/code&gt;&lt;/a&gt; when I decided to create a multi-step format. Simply because of the limitations I ran into when managing the form's context, and accessing certain methods from child components.&lt;br&gt;
It is possible with React Hook Forms, but much easier with Formik.&lt;/p&gt;




&lt;p&gt;These are the major building blocks of the SoPlugged website. Feel free to leave a comment if you have any further questions.&lt;/p&gt;

&lt;p&gt;Till next time!&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Why I switched from hand-drawn sketches to Figma</title>
      <dc:creator>Benaiah Barango</dc:creator>
      <pubDate>Mon, 19 Oct 2020 20:28:08 +0000</pubDate>
      <link>https://dev.to/bambie1/why-you-should-switch-from-hand-drawn-sketches-to-figma-48b9</link>
      <guid>https://dev.to/bambie1/why-you-should-switch-from-hand-drawn-sketches-to-figma-48b9</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0WZ4NSjI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/oi80q2qlf0b6o0xuxf20.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0WZ4NSjI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/oi80q2qlf0b6o0xuxf20.jpg" alt="marvin-meyer-HN1roKF-DS4-unsplash"&gt;&lt;/a&gt;&lt;br&gt;
  "Why didn't you find me sooner?" That's what I'd say to &lt;a href="https://www.figma.com/"&gt;Figma&lt;/a&gt; if he/she managed to speak/understand English.&lt;/p&gt;

&lt;p&gt;As a code newbie, I was told to always draw out a sketch of what I intended to create and also work out a pseudo-code before jumping on my appealing &lt;a href="https://marketplace.visualstudio.com/items?itemName=Equinusocio.vsc-material-theme"&gt;Material-themed&lt;/a&gt; VSCode editor. One major thing that was missing from this very useful piece of advice was &lt;em&gt;what&lt;/em&gt; to use to "sketch" out my idea. So, like most people I saw, I pulled out a pen and a pad to try and replicate my mental pictures of this great web-app I had brewing.&lt;/p&gt;

&lt;p&gt;While hand-drawing is better than not sketching at all, it had a few hinderances for me.&lt;br&gt;
Simply put, I am not a very talented doodler. So, once I drew out boxes for where what component should go, and the relative sizes, I was done sketching.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This resulted in something I call "Designing on-the-go" (using CSS to try deciding what a page should look like by trial-and-error).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now, this doesn't sound like much of a problem, considering that I made two nice apps this way. But here's how it can be an issue:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I found that writing CSS to create a component/page that I only had a mental image of is more tasking. It was easier to get frustrated because of the trial-and-error method I employed.&lt;/li&gt;
&lt;li&gt;Secondly, you can play around &lt;strong&gt;easily&lt;/strong&gt; with colors, gradients, font sizes, alignment etc. on Figma without having to tweak your CSS a 1000 times (I can't be the only one)&lt;/li&gt;
&lt;li&gt;Thirdly, and more importantly, having a design protoype trained me to replicate designs with code. It doesn't get simpler than "here is what I want my app to look like... write code to bring it to life".
&lt;em&gt;Moreso, when you have a nice-looking design, you'd WANT to replicate it!&lt;/em&gt;!!
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm more fond of Figma because of it's VERY shallow learning-curve. A 5-minute video was enough for me to get started!! &lt;br&gt;
There are a few other well-known design options out there: Adobe Photoshop, Sketch, etc.&lt;/p&gt;

&lt;p&gt;Regardless of which platform you are more comfortable with, I highly recommend taking some time to create a starting design before you jump to your preferred code editor (VS Code rules, btw!)&lt;/p&gt;

&lt;p&gt;Let me know your thoughts in the comments :-)&lt;/p&gt;

</description>
      <category>uiweekly</category>
      <category>figma</category>
      <category>frontend</category>
      <category>design</category>
    </item>
    <item>
      <title>Longest Substring Without Repeating Characters </title>
      <dc:creator>Benaiah Barango</dc:creator>
      <pubDate>Fri, 28 Aug 2020 19:12:02 +0000</pubDate>
      <link>https://dev.to/bambie1/longest-substring-without-repeating-characters-fji</link>
      <guid>https://dev.to/bambie1/longest-substring-without-repeating-characters-fji</guid>
      <description>&lt;p&gt;I have recently started attempting one &lt;a href="https://leetcode.com/"&gt;LeetCode&lt;/a&gt; LeetCode problem everyday, to keep me "in shape".&lt;/p&gt;

&lt;p&gt;Today's task? To &lt;a href="https://leetcode.com/problems/longest-substring-without-repeating-characters/"&gt;find the length of the longest substring without any duplicate characters&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here's my solution process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Loop through giving string (s) while counting characters, and break if a duplicate is found&lt;/li&gt;
&lt;li&gt;Use a &lt;strong&gt;hash-map&lt;/strong&gt; (in this case, a &lt;code&gt;javascript object&lt;/code&gt;) to store the unique characters
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let uniqueChars = {}
let length = 0;
for(let i=0; i&amp;lt;s.length; i++){
  let char = s.charAt(i)
  if(uniqueChars[char]) {break;}
  else {
     uniqueChars[char] = true
     length ++
  }
}
return length;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we're not done, because we are assuming that the longest substring starts from the first index (!).&lt;br&gt;
So, to account for that, we'll need to make it into a &lt;em&gt;recursive&lt;/em&gt; function where we keep slicing the string till the end, and compare the lengths.&lt;/p&gt;

&lt;p&gt;Looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var lengthOfLongestSubstring = function(s) {
    if(s.length &amp;lt;= 1) return s.length  //for 1-letter or empty strings
    let uniqueChars = {}
    let length = 0;
    let counter = 0
    for(let i=0; i&amp;lt;s.length; i++){
        let char = s.charAt(i)
        if(uniqueChars[char]) {break;}
        else {
            uniqueChars[char] = true
            length ++}
    }
    if (length &amp;gt;= s.length -1) return length
    return Math.max(length, 
         lengthOfLongestSubstring(s.slice(++counter)))
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break this down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;From index, counter, we loop through string UNTIL there's a duplicate or we reach the end.&lt;/li&gt;
&lt;li&gt;After the loop, we check if the length of our substring is at least &lt;strong&gt;1 less than the string length&lt;/strong&gt;. If true, we can stop searching, because this is our max length.&lt;/li&gt;
&lt;li&gt;Otherwise, we call the function again, moving the counter a step forward, and return the maximum of both lengths.
This happens until the counter is at the last letter.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;As you can probably tell, this method has a time-complexity of O(n^2), as we have to loop through the rest of the string at every index. 👎&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I will be updating this with a faster algorithm, but please feel free to let me know your suggestions!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>leetcode</category>
      <category>algorithms</category>
    </item>
  </channel>
</rss>
