<?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 Justine Philip on Medium]]></title>
        <description><![CDATA[Stories by Justine Philip on Medium]]></description>
        <link>https://medium.com/@worldclassdev?source=rss-b981d2a5e374------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*-KLv0RVYyGjF4H1lcd7_pQ.png</url>
            <title>Stories by Justine Philip on Medium</title>
            <link>https://medium.com/@worldclassdev?source=rss-b981d2a5e374------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 19:18:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@worldclassdev/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[Javascript Algorithms #2: Palindromes]]></title>
            <link>https://medium.com/@worldclassdev/javascript-algorithms-2-palindromes-ead94e6c23bf?source=rss-b981d2a5e374------2</link>
            <guid isPermaLink="false">https://medium.com/p/ead94e6c23bf</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Justine Philip]]></dc:creator>
            <pubDate>Tue, 31 Jul 2018 04:49:43 GMT</pubDate>
            <atom:updated>2018-07-31T04:49:43.539Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q9pSYZMN7Pq2VWD8TT-iMg.png" /></figure><p>Palindromes! Palindromes!! Palindromes!!! Ooooh boy. I’m pretty sure that by now you are wondering what these are. You know personally as a software developer when someone utters words like this while communicating with me i gesture awkwardly and give a pretty obnoxious smirk to indicate some level of disinterest. I’m really not a fan of confusing people.</p><p>Seat belts on? Let’s do justice to the big word. Shall we?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y641BRtDTdu_h3dU" /><figcaption>“Sit tight and enjoy the ride” by <a href="https://unsplash.com/@samrudkinmillichamp?utm_source=medium&amp;utm_medium=referral">Sam Rudkin-Millichamp</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What is a Palindrome?</h3><p>A <strong>palindrome</strong> is a word, number, or other sequence of characters which reads the same backward as forward, such as “<em>madam”</em> or “<em>racecar”</em>. Using a bit of programmer’s speak we could say it’s a string of text that doesn&#39;t change when re-arranged in reverse(the opposite direction).</p><p>So much for the big word huh?</p><h3># The Challenge</h3><p>Given a string of text, return true or false indicating whether or not the text is a palindrome.</p><p><strong>PS: </strong>I remember taking this challenge once during <a href="http://andela.com/">Andela’s</a> test.</p><h3># Algorithmic Logic</h3><p>The challenge says <strong>“given a string of text” </strong>which implies that our function would have a string-typed parameter which we may call “text”. Next, we are to evaluate if the string is a palindrome. To do this, we’ll have to reverse the string first and then compare it with the string that was passed in as an argument.</p><p>To avoid issues with letter casing, it seems reasonable to convert text to a single case type, be it upper or lower. Finally, we are to <strong>“return true or false” </strong>depending on the result of our evaluation. True for when it is a palindrome and false for otherwise.</p><p>All said! You shall now proceed to the Code Dojo.</p><h3># Code Implementation</h3><p>There’s quite a handful of approaches to implementing a palindrome checker and this mostly due to the fact that there are several ways to reverse a string and several ways to loop through a string. Hence, there’s a couple of stunts and combos one could pull off. However we’d consider two unique ways to implement this below:</p><h3>## The Intuitive Approach</h3><p>Okay, i must confess the title sounds a bit misguiding. This isn’t exactly the first thing everyone would do if they are presented with this challenge. It’s really just a direct approach to solving the problem. How direct? You’d see.</p><pre>/*</pre><pre>The Intuitive Approach: This is mostly a direct</pre><pre>approach that most would follow. We split the</pre><pre>string into characters, reverse the array of characters,</pre><pre>join the characters back to form a string, and then</pre><pre>test the created string against what was originally received.</pre><pre>*/</pre><pre>function palindrome(text) {</pre><pre>// Split, reverse and join string to get reversed text</pre><pre>var reversedText  = text.toLowerCase()<br>                    .split(&#39;&#39;).reverse().join(&#39;&#39;);</pre><pre>return text === reversedText;</pre><pre>}</pre><p>I’m sure there’s someone thinking “this really isn’t direct at all”. Oh well! Let’s unveil the “mysteries”, shall we?</p><ul><li>First our function accepts a parameter which is the string of text which is to be tested.</li><li>Next, we convert all letters of the string to lowercase, then call the .split() method on the string that is received and pass it an empty string in order to spread the characters into and array.</li><li>Next, we call .reverse() on the array to re-order its elements in reverse.</li><li>After that we call .join() on the reversed array to form a string once again.</li></ul><p>Voila! we have a reversed string. Notice how we chained all these methods in succession making our code concise yet functional. This is one of the reasons i love Javascript. Elegant syntax!</p><ul><li>At the end we return the result of our comparison which is a boolean indicating if the string that was passed in equals the reversed string we created. This tells us if the text that was passed in is a palindrome.</li></ul><p>Capiche!!! That was easy wasn’t it?</p><p>Let’s try something slightly more complex.</p><h3>## Looping through and Comparing Characters</h3><p>Hmmmmmm! I did call this a slightly complex implementation.</p><p><strong><em>Disclaimer: This could be a bit more confusing than you expected. But i’ll break it down to the best of my ability. So, fear not!</em></strong></p><p>Following this approach we try to loop through the string as it was passed in and compare each character with the character currently in the position it’d have taken if the string was reversed.</p><p>For example if we were testing the string “developer”, we would compare “d” with “r” because if the string was reversed “d” would take “r”s position. Weird punctuation, I know! *smiles*</p><p>Correspondingly we’d compare “e” in position 2 with “e” in position 2 from the end as well. If the string were a palindrome, all of these would test true.</p><p>Alright now! Let the code speak for itself.</p><pre>/*</pre><pre>Looping and Comparing using .every(): This approach allows us to</pre><pre>split the sting into an array of characters and then loop through</pre><pre>the characters comparing them with the characters in their</pre><pre>corresponding positions from the right.</pre><pre>*/</pre><pre>function palindrome(text) {</pre><pre>// Split text into array of characters</pre><pre>let charArray = text.toLowerCase().split(&#39;&#39;);</pre><pre>// Loop through every character and compare with the</pre><pre>// character in its corresponding position if the string</pre><pre>// was reversed. Then store the result</pre><pre>let result = charArray.every((letter, index) =&gt; {</pre><pre>return letter === charArray[charArray.length - index - 1];</pre><pre>});</pre><pre>// Return the result of the evaluation</pre><pre>return result</pre><pre>}</pre><p><strong>**Dramatic sound effect here**…lol… I’m really just too playful.</strong></p><p>Well, i’m sure you must’ve noticed that learning to do amazing things with core Javascript is a fun and adventurous process. Alright let’s do the review thing.</p><ul><li>We converted all letters of the string to lowercase, then used .split() once again to spread the characters of the string into an array.</li><li>Next we use a special array method .every() to loop through the array an perform our check. Basically, the .<strong>every()</strong> method tests whether all elements in the array pass the test implemented by the provided function. The provided function in our case accepts the current letter and its index in the array as parameters. Then we return the result of the comparison between the letter and the letter currently occupying the position this letter would assume if the string was reversed. Learn more about .every() <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every">here.</a></li><li>Cumulatively, the .every() method would evaluate to true if the test passes in all cases and false if it didn&#39;t. The result of that evaluation is what we store in the variable “result” and that’s what our function returns as an indication that the string failed or passed the palindrome check.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BdSv7uPPDfC0ekqb" /><figcaption>“I see a performance problem” by <a href="https://unsplash.com/@franciscomoreno?utm_source=medium&amp;utm_medium=referral">Francisco Moreno</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Perhaps you noticed too? There’s something intrinsically wrong with our second implementation performance-wise. Maybe try identifying it by yourself before you proceed with the rest of the article?</p><p>Okay, here it is. We loop through the entire string and compare every letter with the corresponding letter in its position in reverse. Maybe take out a pen and paper and try to do this manually, then you’d notice that once you loop beyond the string holding the middle position, you are intrinsically repeating comparisons you’ve already gone through in the first half of the iteration. That’s redundant, don’t you think?</p><p>In order to fix this, we’d add a check to ensure that we stop looping once we get to the mid-point of the string. I’d really like you to try your hands on optimizing this. I’ll be posting the solution in the comment section and on twitter after seeing what you could come up with.</p><p>Have fun while at it!</p><h3># Evaluation &amp; Summary</h3><p>We’ve now examined two ways to implement a palindrome checker in Javascript. Both implementations are okay and could help you pass that coding interview. However as is our concern in this case, we need to determine which has higher performance characteristics as we take a look at their pros and cons.</p><p>In my next article i will explore more ways to implement this algorithm as we consider other stricter variations of palindromes, then we’d run a performance test to determine the most highly performant.</p><p>Feel free to implement this in other ways and explore the pros and cons of using each method. Also share them with everyone in the comment section (possibly a link to your pen). We look forward to seeing them. Ask questions as well. I’m sure we’d be able find the answers somehow.</p><p>Please share this article with other’s too if you found it helpful. You received freely, give freely. I also won’t mind a round of applause you know (***winks***).</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*OTgg_GpyKLBKezAFT-3k9w.gif" /><figcaption>Clap so others get to enjoy this too!</figcaption></figure><p>Connect with me on twitter will you? <a href="https://twitter.com/worldclassdev">@worldclassdev</a></p><p><strong>SUBSCRIBE FOR UPDATES &amp; STAY TUNED FOR THE NEXT ARTICLE ON THE SERIES.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ead94e6c23bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript Algorithms #1: Counting the Vowels in a String Of Text]]></title>
            <link>https://medium.com/@worldclassdev/javascript-algorithms-counting-the-vowels-in-a-string-of-text-51802adbeb5?source=rss-b981d2a5e374------2</link>
            <guid isPermaLink="false">https://medium.com/p/51802adbeb5</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Justine Philip]]></dc:creator>
            <pubDate>Thu, 26 Jul 2018 04:20:04 GMT</pubDate>
            <atom:updated>2018-07-27T13:36:49.184Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_39YpU47uNEfQYUmJahMw.png" /></figure><p>Over the years, Javascript has continued to gain lots of attention as its increasingly vast capabilities continue to expand. It has grown from being just a client-side scripting language for making cool interactive web interfaces to being used extensively on the server-side, for mobile applications, desktop applications, embedded systems, IOT, and so on.</p><p>However, it’s become clear that despite the wide range of frameworks available to enhance the strengths of a Javascript developer, it eventually all boils down to understanding the basics. The ability to manipulate vanilla Javascript to do things in the most efficient way is what makes the difference. There’s really so many Javascript developers out there these days and it makes me wonder how many of us really know our stuff.</p><p>In this series, we will be implementing various algorithms using Vanilla Javascript. We will explore various solutions and examine the pros and cons of each approach. We’d also be <strong>posting links to a CodePen</strong> show-casing these implementations. It’ll benefit you most when you try to re-create these solutions on your own as well as make an attempt to improve them.</p><p>We’d recommend that you try to do it yourself first and only refer to the code to get pointed in the right direction, confirm your solutions, and study other approaches. The algorithms will range from writing basic to advance algorithms hence, some of these challenges would be indeed very challenging. Do not be discouraged. That’s the point of it all and that’s how you get to grow as a developer.</p><p>So sit tight and enjoy the ride. Let’s all grow together!</p><h3># The Challenge</h3><p>Basically, we want to be able to receive a string of text of any length and return the number of vowels found within the text.</p><h3># Algorithmic Thinking</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w9ZqNj9KDG3zkYus" /><figcaption>“Men! This isn’t as easy as i thought” by <a href="https://unsplash.com/@punttim?utm_source=medium&amp;utm_medium=referral">Tim Gouw</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Reading through the challenge statement above, you’d notice the statement <strong>“receive a string of text”.</strong> If you’re quite used to programming in general, this should bring the idea of functions to mind. We could write a function that’d have a parameter called “text”. Text would be a string of any length which would be passed to the function as an argument when it is called.</p><p>Next, within the function we have to <strong>go through the text and search for occurrences of the English vowels</strong> (a,e,i,o,u).</p><p>The function then <strong>returns the total number of matches(vowels) found. </strong>This should bring “return statements” to mind as they basically stop the execution of a function and return a value from that function.</p><p>Oooooohhh yeah!!! We got the boring stuff out of the way. These algorithms won’t write themselves, would they?</p><h3># Code Implementation</h3><p>We’d explore two ways to implement this. First we’d follow an <strong>Iterative approach</strong> and then the use of <strong>Regular Expressions</strong>.</p><h3>## An Iterative Approach</h3><p>In the iterative approach, we would have to loop through each letter of the string passed and then check to see if they match any of the vowels. Before running through the text we would have a counter initialized and assigned a value of zero. In a case where there’s a match, we would increment the counter. Pretty simple right?</p><p>Well here’s our implementation:</p><pre>/*</pre><pre>An iterative approach to counting the number of vowels in a</pre><pre>string of text.</pre><pre>*/</pre><pre>const vowels = [&quot;a&quot;, &quot;e&quot;, &quot;i&quot;, &quot;o&quot;, &quot;u&quot;]<br></pre><pre>function countVowelsIterative(text) {</pre><pre>// Initialize counter</pre><pre>let counter = 0<br></pre><pre>// Loop through text to test if each character is a vowel</pre><pre>for (let letter of text.toLowerCase()){</pre><pre>    if (vowels.includes(letter)) {</pre><pre>       counter++</pre><pre>    }</pre><pre>}<br></pre><pre>// Log formatted response to console</pre><pre>console.log(`The text contains ${counter} vowel(s)`)<br></pre><pre>// Return number of vowels</pre><pre>return counter</pre><pre>}<br></pre><pre>/*</pre><pre>    ============== Test Case ===================</pre><pre>*/</pre><pre>countVowelsIterative(&#39;I am a world-class developer using iterations&#39;);</pre><pre>// Logs &quot;The text contains 16 vowel(s)&quot; to the console</pre><pre>// returns 16</pre><p>Well, that was pretty self explanatory right? Let’s go over some key points.</p><ul><li>First, we declared a constant “vowels” which contained an array of the five English vowels.</li><li>Next, we make use of a <strong>for…of</strong> loop to iterate through each letter of the text. If you’re not conversant with this, a for…of loop basically creates a loop iterating over <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol">iterable objects</a>. Iterable objects could be strings, arrays, maps, sets etc. You can learn more <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of"><strong><em>here</em></strong></a><em>.</em></li><li>Notice how we convert all letters of the text to lowercase within the loop. This is because, we don’t want to miss the cases of uppercase vowels within the passed text (trust me that wasn’t intentional).</li><li>Next within the loop, we use an if statement to check if the selected letter is included in the array of vowels we defined earlier. Fittingly, we call the <strong>includes()</strong> method on the array of vowels to determine whether the array includes the selected letter, returning true or false as appropriate. Learn more about how includes() works <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes">here.</a></li><li>If the condition evaluates to true, we increment the counter.</li><li>After looping through we log a formatted message to the console telling us the number of vowels and then return the counter which is equivalent to the number of vowels found.</li></ul><p>Wheeewww!!! That felt good. Now let’s consider a slightly more advanced yet concise approach.</p><h3>## Using Regular Expressions</h3><p>Regular Expressions are quite a bit of a trouble for most developers in my experience. Usually, we don’t get to understand the syntax and its application. Hence, we mostly get some snippets online when we need to make use of them. Okay then! Let’s try to change that!</p><p>Basically regular expressions help us find patterns or characters/ character combinations within strings. See why this is relevant to us? They’ll help us find the desired characters within the text passed. By extension, regular expressions can help us to do way more remarkable things such us the implementation of content filters. However, my favorite thing about Regular Expressions is the fact that the basics stay same across all languages.</p><p>Without further ado, let’s examine the solution. If you’d love to learn more about Regular Expressions in Javascript, go through the Mozilla Developer Network’s documentation <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions">here.</a></p><p>Here’s our implementation:</p><pre>/*</pre><pre>Using Regular Expressions to count the number of vowels in a</pre><pre>string of text.</pre><pre>*/</pre><pre>function countVowelsRegex(text) {</pre><pre>// Search text with Regex and store all matching instances</pre><pre>let matchingInstances = text.match(/[aeiou]/gi);</pre><pre>// Check if matching instances exist then calculate length</pre><pre>    if(matchingInstances) {<br></pre><pre>    // Log formatted response to console</pre><pre>    console.log(`The text contains ${matchingInstances.length} vowel(s)`)</pre><pre>// Return number of vowels</pre><pre>        return matchingInstances.length</pre><pre>    } else{</pre><pre>        return 0</pre><pre>    }</pre><pre>}<br></pre><pre>/*</pre><pre>    ============== Test Case ===================</pre><pre>*/</pre><pre>countVowelsRegex(&#39;I am a world-class developer uisng Regex&#39;);</pre><pre>// Logs &quot;The text contains 13 vowel(s)&quot; to the console</pre><pre>// returns 13</pre><p>I guess you won’t need a review of this one, would you? Okay! Okay! Let’s look at the solution.</p><ul><li>The first thing we did within the function was to call the<strong>match()</strong> method on the text which returns an array of the matches found after matching the regular expression passed as an argument against the text. Learn more about how match() works <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match">here.</a></li><li>The regular expression specifies the letters to be looked for within the brackets[]. For simple patterns, Regular expressions are usually defined within a pair of slashes. Notice the characters “gi” trailing the closing slash?<br>“g” stands for a global search which does not return after the first match, restarting the subsequent searches from the end of the previous match.<br>“i” stands for case insensitive search which makes the whole expression case-insensitive (for example <strong>/xyz/i</strong> would match <strong>XyZ</strong>).</li><li>Next we use a conditional to check if any matching instances were found. The .match() method used above returns an array of the matched items if matches were found and “null” if they weren’t. Hence in the conditional, if “matchingInstances”evaluates to a truthy value(that is an array of matches found), we log a formatted message showing the number of vowels which is same as the length of the array. Then we return the number as well. On the other hand if it evaluates to a falsy value, we return 0 as it means no matches were found.</li></ul><h3># Evaluation &amp; Summary</h3><p>We have now successfully implemented an algorithm that counts the number of vowels in a string of text in Javascript.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OikT1OG_q9MPkOQ3" /><figcaption>“We made it!” by <a href="https://unsplash.com/@brookecagle?utm_source=medium&amp;utm_medium=referral">Brooke Cagle</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Let’s evaluate both methods used. The iterative approach although not as concise as the other is an easier and somewhat more logical approach especially for beginners. However as the result below shows, the Regex method is better optimized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RWbGd1aYfPpjTlM6SdRckQ.png" /><figcaption>Test case ran on Jsperf.com</figcaption></figure><p>Click<a href="https://jsperf.com/vowel-counter"> here</a> to run these tests by yourself.</p><p>Perhaps we could say the Regex method wins? Nevertheless, both approaches work and could be used in an interview situation.</p><p><a href="https://codepen.io/worldclassdev/pen/xJLOBL"><strong>Click here to view on CodePen.</strong></a></p><p>Was this exciting for you? Let me know in the comment section below. It really was for me. We were able to successfully examine two approaches to implementing an algorithm that helps us count the number of vowels within a given piece of text. In the process, we’ve learnt about some Javascript methods and regular expressions. These tools are very important items in a Modern Javascript Developer’s toolbox.</p><p>Feel free to implement this in other ways and explore the pros and cons of using each method. Also share them with everyone in the comment section (possibly a link to your pen). We look forward to seeing them. Ask questions as well. I’m sure we’d find the answers somehow.</p><p>Please share this article with other’s too if you found it helpful. You received freely, give freely. I also won’t mind a round of applause you know (***winks***).</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*OTgg_GpyKLBKezAFT-3k9w.gif" /><figcaption>Clap so others get to enjoy this too!</figcaption></figure><p>Connect with me on twitter will you? <a href="https://twitter.com/worldclassdev">@worldclassdev</a></p><p><strong>SUBSCRIBE FOR UPDATES &amp; STAY TUNED FOR THE NEXT ARTICLE ON THE SERIES.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51802adbeb5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A DEEP DIVE INTO REACT COMPONENTS PART ONE: A GENTLE INTRODUCTION]]></title>
            <link>https://medium.com/@worldclassdev/a-deep-dive-into-react-components-part-one-a-gentle-introduction-821fef560382?source=rss-b981d2a5e374------2</link>
            <guid isPermaLink="false">https://medium.com/p/821fef560382</guid>
            <category><![CDATA[react-js-tutorials]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react-components]]></category>
            <dc:creator><![CDATA[Justine Philip]]></dc:creator>
            <pubDate>Fri, 05 Jan 2018 00:39:29 GMT</pubDate>
            <atom:updated>2018-03-04T23:40:26.464Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IQSh6g9b-0cS5tM_Bz-_IA.png" /></figure><blockquote><strong><em>DISCLAIMER: If you are looking for just a brief and shabby explanation of concept/ workings of components in react, this series isn’t for you.</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*l6Tp6g3hqVaGtr7VHocLcA.gif" /><figcaption>Let’s go</figcaption></figure><p>This series takes a “deep” dive into the concept of components in development with Facebook’s react. If you are a novice with no previous knowledge of the library, a newbie in the world of crafting dynamic UI’s with react, or a react developer with a handful of knowledge and experience relating to the library, this series is just for you as it comprehensively sheds light on react components from a beginner’s level to advanced.</p><p>This first part of the series sheds some light on the following;</p><ul><li>What is react?</li><li>What is a component?</li><li>Factors to consider when creating components in react</li></ul><h3>A BRIEF INTRODUCTION TO REACT</h3><p>React is an open-source JavaScript library maintained by Facebook that can be used for creating views rendered in HTML. Unlike some other similarly popular equally capable technologies (e.g Angular, Ember etc), React is not a framework. It is a library. Thus, it does not, by itself, dictate a framework pattern such as the MVC pattern. You use React to render a view (the V in MVC), but how to tie the rest of the application<br> together is completely up to you.</p><p>The take-home here will be that React is a Javascript library used for creating views. This implies that React helps you design the user interfaces and implement whatever logic may be required as it renders your application.</p><blockquote>That said, lets dive into the concept of components.</blockquote><h3>WHAT IS A COMPONENT?</h3><p>In a general sense, a component is a part or element of a larger whole. To bring this home lets consider a classroom setting. What are the components of a typical classroom?</p><p>I’m pretty sure you’re thinking students, teachers, some pieces of furniture and so on. The figure below presents a sample breakdown. Not exactly the best there is if you ask me. But it does the job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D7uE_KGXm_0IX9lDF8hyrQ.png" /></figure><p>In react, the same logic applies. The applications user interface is broken down into “smaller”, “reusable” components to which data is passed and logic is applied to render the UI appropriately.</p><p><em>Lets now take time to understand the key factors behind the formation of react components.</em></p><h3>HOW SMALL IS SMALL?</h3><p>Let’s consider the classroom example again. Did you notice that the components we outlined for a classroom aren’t exactly all that there is? That even those components have their own components?</p><p>Lets further break down the students component as shown in the figure below. This component comprises of a number of students yeah? So we have a student component! Could we go further? Each student has body parts, Don’t they? So we have the hands, legs, mouth etc. But then the hand is made up of muscles, then the muscles of tissues and tissues of cells. Getting too abstract?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*Ctxhwzwc0OcR9Usj1hVBRw.png" /></figure><p><strong><em>Of course, it is.</em></strong></p><p>It’s getting so abstract that the components are losing relevance of some sort in the larger context under consideration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*lIK7S12mmG3CEK_hcqdjgg.gif" /><figcaption>lol……of course i do</figcaption></figure><p><strong><em>The point?</em></strong></p><p>When creating react components, ensure that the components created stay relevant to the application, carrying out a specific function for it.</p><p><strong><em>Word of Caution: Do not bundle things up so much that your components are cluttered and lack a particular focus. And don’t break things down so much that you start having irrelevant components that are of no specific relevance to the application at large. Understand the big picture.</em></strong></p><blockquote><strong>EACH COMPONENT SHOULD CARRY OUT A SPECIFIC FUNCTION RELEVANT TO THE APPLICATION. KEEP IT SIMPLE.</strong></blockquote><blockquote>===<strong>Lets consider yet another important point </strong>===</blockquote><h3>RE-USABILITY EXAMINED</h3><p>Let’s consider the classroom example yet again. The idea of something being reusable certainly implies that its required (needed) in many instances. Making reference to the first figure, we had a students component. If break that down further, we would have a student component. Now that is an ideal example of a reusable component. Because this component would be required in many instances when we have a handful of students.</p><p>In react we take out time to carefully observe patterns in the applications user interface. Where a pattern is noticed, a component that typically fits the function required therein is created. It is with this single component that multiple instances are rendered to the application.</p><p>Okay now. This is getting pretty boring. No more theories! Let’s get our hands dirty.</p><p><strong><em>In Part Two of this series,</em></strong> we’d learn how to create react components by considering a real-life hosted react application and taking moments to reflect on these concepts.</p><p>Stay expectant!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*OTgg_GpyKLBKezAFT-3k9w.gif" /><figcaption>Applause!!!</figcaption></figure><p>Show appreciation for this article by clapping and sharing with your friends. That’s if you did appreciate it of course.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=821fef560382" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>