<?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 Kenlyn Terai on Medium]]></title>
        <description><![CDATA[Stories by Kenlyn Terai on Medium]]></description>
        <link>https://medium.com/@kenlynterai?source=rss-e7807f924c51------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MORMc_oWwSqN4KdgmmmqdQ.png</url>
            <title>Stories by Kenlyn Terai on Medium</title>
            <link>https://medium.com/@kenlynterai?source=rss-e7807f924c51------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:56:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kenlynterai/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[Microservices and Distributed Systems]]></title>
            <link>https://medium.com/@kenlynterai/microservices-and-distributed-systems-36a90d5d8ce?source=rss-e7807f924c51------2</link>
            <guid isPermaLink="false">https://medium.com/p/36a90d5d8ce</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Kenlyn Terai]]></dc:creator>
            <pubDate>Sun, 17 Nov 2019 03:11:41 GMT</pubDate>
            <atom:updated>2019-11-17T03:14:23.443Z</atom:updated>
            <content:encoded><![CDATA[<p>The topics of Microservice architectures and distributed systems have swirled around virtual watercoolers and their implementation put forth as best practice for my entire Engineering career so far. I’ve taken it for granted that Tech companies are migrating towards these practices. However, after hearing <a href="https://www.linkedin.com/in/robzuber/">Rob Zuber</a>’s talk, <em>Building Microservices Without Abandoning Your Monolith</em> at the <a href="https://www.ctoconnection.com/summits/seattle-cto-summit-2019">inaugural Seattle CTO Summit</a>, it made me realize that there’s more to the story and that it’s time to learn more.</p><h4>Monolithic vs. Microservices Application Architecture</h4><p>To begin with, the important problems to solve involve maximizing software delivery velocity and its components: <a href="https://en.wikipedia.org/wiki/Maintainability">maintainability</a>, <a href="https://en.wikipedia.org/wiki/Extensibility">extensibility</a>, and <a href="https://en.wikipedia.org/wiki/Software_testability">testability</a>. As Chris Richardson describes in his book, <a href="https://microservices.io/book">Microservices Patterns</a>, an application goes from “monolithic to mud” in its <a href="https://en.wikipedia.org/wiki/Software_deployment">deployment</a> architecture as its size increases. In general, organizations optimize by adopting various degrees of a <a href="https://microservices.io/patterns/monolithic.html">monolithic</a> or <a href="https://microservices.io/patterns/microservices.html">microservice</a> architecture depending upon their growth stage and organizational inclination. A simplified summary of the advantages and disadvantages of either approach for large applications is below, with green being the better approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*Ev8dF4d4zokR2l07wSE6HA.jpeg" /><figcaption>Source: <a href="https://microservices.io/patterns/">Microservices.io, Chris Richardson</a></figcaption></figure><p>Again borrowing from Chris Richardson’s <a href="https://microservices.io/book">“Microservices Patterns</a>”, the difference between these two approaches is described in the following application example.</p><h4>Monolithic Architecture: Keep It Simple, Startup! (KISS)</h4><p>At inception, applications are typically designed as a single deployable unit. It’s simple and easy to understand at the outset and scaling concerns mostly centered around capacity and availability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*k1K8CxjQZ7GenXhSJ8ZAtQ.png" /><figcaption>The example application monolithic architecture (1)</figcaption></figure><blockquote>“Despite having a logically modular architecture, the [example] application is packaged as a single WAR file and deployed on Tomcat. It is an example of the widely used monolithic style of software architecture, which structures a system as a single executable or deployable component. If the application was written in GoLang, it would be a single executable. A Ruby or NodeJS version of the application would be a single directory hierarchy of source code.”</blockquote><p>As the application grows in size and complexity, it gets harder to maintain and understand, development velocity slows, and failure risks increase. While there are ways to optimize the system, even the best teams find that they need to move to some form of a Microservices architecture.</p><blockquote>“On the one hand, a disciplined team can slow down the pace of their descent towards monolithic hell. They can work hard to maintain the modularity of their application. They can write comprehensive automated tests. But on the other hand, they cannot avoid the issues of a large team working on a single monolithic application. Nor can they solve the problem of an increasingly obsolete technology stack. The best that a team can do is delay the inevitable. In order to escape monolithic hell they must migrate to a new architecture: the Microservice architecture.”</blockquote><h4>Microservices: Solving for “Monolithic Hell”</h4><p>Richardson’s definition of Microservices is grounded in concepts derived from <a href="http://theartofscalability.com/">The Art of Scalability</a>(3) and the Scale Cube, its three-dimensional scalability model. In sum, while both X- and Z-Axis scaling improve application capacity and availability, Y-Axis scaling minimizes development and application complexity by splitting an application into its component services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*qTy6ThKgGmPOQRblv7hZpA.png" /></figure><p>The latter provides the definition for Microservices, “an architectural style that functionally decomposes an application into a set of services.”</p><p>As shown in the diagram of the Microservices architecture version of the example application below, many services correspond to the modules that described in the monolithic example. What’s different is that each service and its API is very clearly defined (<a href="https://github.com/microservices-patterns/ftgo-application">application code can be found here</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*ZIrdSAAuC5v4Av-0HQSVeA.png" /><figcaption>Microservice architecture-based version of the example application(1)</figcaption></figure><h4>Got Microservices? You Need Distributed Systems</h4><p>Okay, so you have a large application migrating to a Microservices architecture. You need to have a <a href="https://en.wikipedia.org/wiki/Distributed_computing">distributed computing system</a> in order to reap its benefits. A <em>distributed system</em> is defined on Wikipedia as a system whose components are located on different <a href="https://en.wikipedia.org/wiki/Computer_network">networked computers</a>, which communicate and coordinate their actions by <a href="https://en.wikipedia.org/wiki/Message_passing">passing messages</a> to one another(4) .</p><p>From IBM, “computers that are in a distributed system can be physically close together and connected by a local network, or they can be geographically distant and connected by a wide area network. A distributed system can consist of any number of possible configurations, such as mainframes, personal computers, workstations, minicomputers, and so on. The goal of distributed computing is to make <strong><em>such a network work as a single computer</em></strong>”(5).</p><p>Wait…what?</p><h4>How Do All-Kinds-of-Computers-Everywhere == One Computer?</h4><p>In a word, Communication. This is a whole other topic that is beyond the scope of this article but successful communication in a distributed system requires these three high-level parts:</p><ul><li><em>Nodes, </em>also known as <em>processes</em>, <em>agents</em>, or <em>actors, </em>are the individual entities in a distributed system. Individually running their own operations, they vary in nature from hardware devices to a software processes (6).</li><li>Connection via message protocols and software</li><li>Successful coordination and security</li></ul><p>For a quick overview of distributed system concepts, components, and terminology, check out <a href="https://github.com/aphyr/distsys-class">Kyle Kingsbury’s <em>Introduction to Distributed Systems</em></a>.</p><h4>References</h4><ol><li>Richardson, Chris. <em>Microservices Patterns: with Examples in Java</em>. Manning Publications, 2019.</li><li>“Microservices Pattern: A Pattern Language for Microservices.” <em>Microservices.io</em>, <a href="https://microservices.io/patterns/index.html.">https://microservices.io/patterns/index.html.</a></li><li>“The Art of Scalability.” <em>The Art of Scalability</em>, <a href="http://theartofscalability.com/">http://theartofscalability.com/.</a></li><li>“Message Passing.” <em>Wikipedia</em>, Wikimedia Foundation, 8 Nov. 2019, <a href="https://en.wikipedia.org/wiki/Message_passing.">https://en.wikipedia.org/wiki/Message_passing.</a></li><li><em>IBM Knowledge Center</em>, <a href="https://www.ibm.com/support/knowledgecenter/en/SSAL2T_8.2.0/com.ibm.cics.tx.doc/concepts/c_wht_is_distd_comptg.html.">https://www.ibm.com/support/knowledgecenter/en/SSAL2T_8.2.0/com.ibm.cics.tx.doc/concepts/c_wht_is_distd_comptg.html.</a></li><li>Joshi, Vaidehi. <a href="https://medium.com/baseds/many-nodes-one-distributed-system-9921f85205c4">“Many Nodes, One Distributed System,” https://medium.com/baseds/many-nodes-one-distributed-system-9921f85205c4</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36a90d5d8ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When and How to add Machine Learning to a Product Roadmap]]></title>
            <link>https://medium.datadriveninvestor.com/when-and-how-to-add-machine-learning-to-a-product-roadmap-f91bbc3b2776?source=rss-e7807f924c51------2</link>
            <guid isPermaLink="false">https://medium.com/p/f91bbc3b2776</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[agile-product-management]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[product-management]]></category>
            <dc:creator><![CDATA[Kenlyn Terai]]></dc:creator>
            <pubDate>Tue, 17 Sep 2019 17:55:53 GMT</pubDate>
            <atom:updated>2019-09-25T09:17:17.675Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PanC8qeh3-1n_A2rrkVLfA.jpeg" /><figcaption>Photo by <a href="https://www.twenty20.com/photos/7bff1611-ca46-4852-b9c0-5bf917003ae5">Bea Rose</a> via Twenty20</figcaption></figure><p>I recently contributed to an ongoing series called <a href="https://medium.com/@womeninproduct"><em>Ask Women in Product</em></a> by answering this question: “When and How do I Add Machine Learning to a Product Roadmap?”. Originally published in the <a href="https://medium.com/@womeninproduct/ask-wip-when-and-how-to-add-machine-learning-to-product-roadmap-f73fc38c1326">September 17, 2019 edition</a>, what follows is my answer in full. Thank you to <a href="https://medium.com/u/f6f82d9dceac">@mdy</a> for editing this piece!</p><p>While working as a global product manager at Agilent, I became enamored with advanced statistics and its business applications during my MBA at UCLA Anderson, where I studied modeling and prediction with <a href="https://www.linkedin.com/in/richard-stern-1b93697/">Dr. Richard Stern</a> and One-to-One Marketing and Marketing Research with <a href="https://www.anderson.ucla.edu/faculty-and-research/marketing/faculty/bodapati">Dr. Anand Bodapati</a>. When I later worked as an Engineering instructor and Developer, I sought best-practice insights from Machine Learning (ML) Product Management practitioners to understand how ML is utilized in building applications.</p><p><a href="https://www.datadriveninvestor.com/2019/02/08/machine-learning-in-finance/">Machine Learning in Finance | Data Driven Investor</a></p><p>Now that I’ve returned to product management work, I have integrated these experiences into a far better understanding of how to work ML into product roadmaps and into any applications I might build. Here’s what I’ve learned and I hope you find it helpful as well.</p><h3>Table of Contents</h3><p><strong>Introduction</strong><br> — What is Machine Learning?<br> — Artificial Intelligence &gt; Machine Learning &gt; Deep Learning<br><strong>When is a Machine Learning-based solution appropriate?</strong><br> — Problems that are well suited for ML-based solutions<br> — Problems that don’t need ML-based solutions<br><strong>What do I need to succeed?<br>How do I fit Machine Learning into my roadmap?</strong><br> — 1. Understand the business need<br> — 2. Formulate the problem hypothesis<br> — 3. Define clear measures of success<br> — 4. Assess your candidate projects<br> — 5. Confirm that you have the data you need to succeed<br> — 6. Establish healthy data collection practices<br> — 7. Tackle the risks and challenges<br> — 8. Expect to iterate<br><strong>Conclusion</strong><br><strong>Resources and References</strong></p><h3>Introduction</h3><p>Are you looking for ways to improve personalization, natural language processing (NLP), or search customization? Machine Learning (ML) could be the tool you need. This article will describe what Machine Learning is, what problems it can solve for you, and how to incorporate this toolkit into your product roadmaps. More importantly, this article also explains when machine learning is <em>not</em> the right tool for the job.</p><p>Note: There are several steps needed to take Machine Learning from concept to execution, including data preparation, model development, and the actual deployment processes. While product managers need to be actively involved in these stages, these are topics that — for now — are outside the scope of this article.</p><h3>What is Machine Learning?</h3><p>Arthur Samuel, a pioneer of AI research, provides us with a concise definition: “Machine Learning is the field of study that gives computers the ability to learn without being explicitly programmed.” Where traditional programming requires us to provide data and rules to generate answers, Machine Learning requires us to provide desired answers and data to generate rules.</p><p>In academics, Machine Learning is a subset of <a href="https://towardsdatascience.com/introduction-to-statistics-e9d72d818745">Data Science</a>, the study of data which involves developing methods of recording, storing, and analyzing data to effectively extract useful information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/0*moXauoWhOGG6AEFe" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/30/0*-kwuOv7SGmO7Cyl0" /><figcaption>Image credit:<a href="https://towardsdatascience.com/introduction-to-statistics-e9d72d818745"> https://towardsdatascience.com</a></figcaption></figure><h3>Artificial Intelligence &gt; Machine Learning &gt; Deep Learning</h3><p>Machine Learning (ML) is sometimes confused with Artificial Intelligence (AI) and Deep Learning (DL), which are related but differentiated. Whenever a machine completes tasks based on a set of stipulated rules that solve problems (i.e., algorithms), such an “intelligent” behavior is what is called Artificial Intelligence and <a href="https://towardsdatascience.com/clearing-the-confusion-ai-vs-machine-learning-vs-deep-learning-differences-fce69b21d5eb">includes ML and DL</a>. ML is a subset of AI, and DL is a subset of ML. The progression from AI through DL generally represents more human-independent rule definitions and, as such, require more and more data. The diagram below shows where ML and DL fall within the AI discipline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/0*a066UlwFZg3UwqAo" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/29/0*Ez6puKJrCwijxdjX" /><figcaption>Image credit:<a href="https://blog.stateofthedapps.com/growing-artificial-intelligence-with-blockchain-4ee14bff2974"> https://blog.stateofthedapps.com/</a></figcaption></figure><h3>When is a Machine Learning-based solution appropriate?</h3><h4>Problems that are well suited for ML-based solutions</h4><p>Good use cases for Machine Learning include problems that require personalization, ranking, classification, regression, clustering, or identifying anomalies. Note that the type of problem you want to solve will drive the choice of algorithm to use (e.g. for clustering, you would use k-means).</p><p>In general, for Machine Learning to make sense for a business, your problem should have these characteristics:</p><ul><li><strong>Requires complex logic that’s impractical to solve with human-defined rules, or heuristics</strong>. For example, search engines often have multiple phases of ranking that happen in series, such as initial retrieval, primary ranking, contextual ranking, and personalized ranking. This is a great application for Machine Learning.</li><li><strong>The problem will be scaling up very fast</strong>. If you expect that your problem will scale to thousands of users or more, then it could be a good use case for ML. Let’s say you have an online retail platform and expect to have thousands of customers avail of your new offer within three to six months. <a href="https://www.slideshare.net/EpsilonMktg/the-power-of-me-the-impact-of-personalization-on-marketing-performance/1">Retail customer expectations</a> being what they are, you need a personalized experience and could give a good justification for ML.</li><li><strong>Requires personalization at scale</strong>. Unless you can reduce the complexity of the problem space by, for example, creating solutions for a particular segment or category rather than for each individual, you’re better off using ML to define the rules you use.</li><li><strong>Require rules that change quickly over time</strong>. If your rules generally remain static year after year, then a heuristic solution is preferred. However, if your business’s success depends upon quick adaptation and rule changes, then ML is a good route. For example, if you have a search product and Ed Sheeran drops a new album, your algorithm needs to adapt in real-time and is amenable to an ML solution.</li><li><strong>Has a known, pre-defined end result</strong>. For example, in online retail, you want your model to provide recommendations which result in a sale. In search, typing “shirt” should return results with lists of shirts that are most likely to lead to a purchase.</li><li><strong>Does not require 100% accuracy</strong>. If business success can be achieved with a high <em>probability </em>of accuracy rather than with perfection, then ML is a good option. For example, recommendation systems will not be considered faulty if users don’t always want what is served. Users can still have a great experience and the program can learn from the lack of sales to deliver improved recommendations in the future.</li></ul><h4>Problems that don’t need ML-based solutions</h4><p>Some features of Google’s Gmail are great examples of when a heuristic-based solution is preferred. In the screenshot below, Gmail looks for phrases including words like “attachment” or “attached” to pop up a reminder when someone may have forgotten to attach a file. Although an ML system would most likely catch more potential mistakes, it would be far more costly to build. The heuristic solution provides good user experience and allows organizational resources to be used for more impactful projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*3pUSeoUPnptF279n" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/30/0*rn6oElx-CtTUt_F3" /><figcaption>A successful heuristic-based solution (Image by <a href="https://medium.com/google-design/human-centered-machine-learning-a770d10562cd">Google/Gmail</a>)</figcaption></figure><h3>What do I need to succeed?</h3><p>A successful Machine Learning project needs the following:</p><ul><li><strong>A clearly defined business problem</strong>. Machine Learning shifts engineering work from a deterministic process to an experimental one, so there is an even greater need to know what you want to achieve upfront.</li><li><strong>The right team. </strong>You’ll need a team with skills in both Data Science and Engineering. In Data Science, roles can include an ML Scientist, Applied Scientist, Data Scientist, and/or Research Scientist. In Engineering, roles can include a Business Intelligence Engineer, Data Engineer, Software Engineer, Development Manager, and/or Technical Program Manager.</li><li><strong>A grasp of the project’s potential risks and returns</strong>. Even if a project is feasible from an ML perspective, the level of effort needed to develop and maintain an ML-based solution may make such an approach impractical. For example, if your model needs to be updated very frequently in production, to the point where it requires a lot of maintenance, it may not be worth it.</li><li><strong>Enough data</strong>. You need at least thousands of rows of data for linear models and hundreds of thousands of rows for a neural network. If you don’t have the data, you’ll need strategies to acquire it, and may need to stick to heuristic-based approaches until you do.</li><li><strong>Data with a clear pattern. </strong>Since algorithms require patterns to learn from, you need to have a sense of what patterns exist in your data, even if you don’t know the precise pattern before you get started. You should be able to articulate these patterns qualitatively or have a gut feeling at the minimum.</li><li><strong>High-quality data</strong>. As the adage goes, “garbage in, garbage out.” Lean on your Data Scientists to help you determine your data’s status and/or how to acquire data that is:<br>1. sufficient in completeness and simplicity<br>2. relevant to the problem that you are solving<br>3. recent, reflecting users’ current behaviors<br>4. representative of the segment and timeframe you‘re addressing<br>5. unbiased<br>6. respectful of user privacy and is secure</li><li><strong>The right technologies</strong>. There are several open-source tools and platforms, such as<a href="https://aws.amazon.com/amazon-ai/"> Amazon AI</a>,<a href="https://www.tensorflow.org/"> TensorFlow</a> (originally developed by Google), and <a href="https://github.com/showcases/machine-learning">many others</a> that make machine learning accessible to virtually any company today.</li></ul><h3>How do I fit Machine Learning into my roadmap?</h3><p>While the specific details may vary from one project and company to another, these are the general steps that you’d need to consider.</p><h4>1. Understand the business need</h4><p>Start by avoiding the mistake made by many companies and product teams: don’t jump right into product strategies that start with Machine Learning as a solution and skip right to focusing on a meaningful problem to solve.</p><p>Machine Learning, like heuristics, is just another tool for solving human needs. If you and your stakeholders aren’t aligned on the business need, you’re just going to build a very powerful (and expensive) system that isn’t meaningful to your customers or your business.</p><h4>2. Formulate the problem hypothesis</h4><p>For each of the business needs identified in the preceding step, formulate and document the hypothesis that you intend to test. In general, your hypothesis statement will have the following parts:</p><ul><li>A change that you are testing (“Improving the search ranking with ML will…”)</li><li>A desired outcome (“… allow our customers to find the correct product…”)</li><li>Success metrics (“…in 15% less time.”)</li><li>A description of the Model’s output (“The model will score each possible product…”)</li><li>Predictors (“…by using products recently viewed by the customer, the types of products previously purchased, the monetary value of previous purchases, and our own understanding of what products are frequently brought together …”)</li><li>Target (“…to predict the product that the customer ultimately selects for purchase.”)</li></ul><h4>3. Define clear measures of success</h4><p>What does success look like if we were to solve the problem and meet the business need? You and your stakeholders need to get to a shared understanding of what that means, based on the problem hypothesis.</p><p>For example, do you expect certain performance indicators to move? Do you expect new business opportunities to be unlocked? In practical terms, are we talking about an increase in gross revenue? Improved targeting of marketing offers leading to a lower average cost for each newly-acquired customer? Increased customer satisfaction through an interactive, ML-based self-help system?</p><p>The more you can express success in terms of actual targets, the easier it will be for your team to stay focused and prove the business benefits of the ML effort.</p><h4>4. Assess your candidate projects</h4><p>With a defined business need, customer problems to solve, and a clear measure of success, assemble a team of UX/UI professionals, ML experts, and data scientists early in your roadmap definition process.</p><p>Create a 2x2 matrix that plots the impact and the effort needed for each candidate project, prioritize work with the highest impact/lowest effort, then rank product ideas by ROI as you iterate on features or projects to prioritize.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*diSONZyvETlc6ze0CNAHvw.png" /><figcaption>Left: Impact/Effort Matrix (created by the author). Right: User Impact/ML Impact matrix (Image credit: <a href="https://medium.com/google-design/human-centered-machine-learning-a770d10562cd">Google</a>)</figcaption></figure><p>Only high-impact products should be considered for an ML project. At Google, for example, teams can vote on which ideas could have the biggest user impact and which would be most enhanced by an ML solution, prioritizing those ideas which deliver a high impact for both. If there are several candidates, then plotting these ideas on a matrix of user impact vs. ML impact (i.e. impact on product improvement) can help you choose your project.</p><h4>5. Confirm that you have the data you need to succeed</h4><p>Evaluate your team’s data needs and whether the available data meets the criteria set forth in the previous section. ML models require a lot of data, are complex, and can take a long time to develop and test before achieving production-readiness.</p><p>You may discover that you don’t have enough data but you can see the need for an ML solution in your future. In this scenario, you will be better off launching a traditional MVP with simple heuristics to pave the way for developing an ML model. This is an excellent opportunity to establish a set of baseline data for your product. In this scenario, you’ll want to establish success metrics and design your system with metric instrumentation in mind.</p><p>If it turns out that you do have the data that you need, you’ll want to ensure that the system you want to improve with ML is receiving the data you want and is instrumented to collect your metrics of interest. You’ll also want to <a href="https://zulily-tech.com/2018/04/06/practical-a-b-testing/">A/B test</a> your current system against the ML model. At the minimum, your v1.0 ML model should maintain your current level of user satisfaction and other metrics.</p><h4>6. Establish healthy data collection practices</h4><p>With regards to the actual task of data collection, here are some excellent recommendations on how to gather quality and standardized data from users, based on <a href="https://www.linkedin.com/in/peterskomoroch/">Peter Skomoroch</a>’s recent <a href="http://blog.dominodatalab.com/machine-learning-product-management-lessons-learned/">Strata Data Conference presentation</a>.</p><ul><li>Guide user input when you can</li><li>Use auto-suggest fields</li><li>Validate user inputs, emails</li><li>Collect user tags, votes, and ratings</li><li>Track impressions, queries, and clicks</li><li>Sessionize logs</li><li>Disambiguate and annotate entities (company names, locations, etc.)</li></ul><p>As your user base grows, heuristics become burdensome. As you acquire enough data to begin an ML project, you’ll be in a good position to not only develop a model but also to A/B test your ML model against your heuristics.</p><h4>7. Tackle the risks and challenges</h4><p>ML projects come with their own sets of risks and challenges. You’ll want to address these risks head-on to keep your project on track.</p><ul><li>Be aware of the <a href="https://developers.google.com/machine-learning/crash-course/fairness/types-of-bias">types of bias</a> that might impact your model. Mitigate these biases by allowing your model to measure them, then take <a href="https://developers.googleblog.com/2018/04/text-embedding-models-contain-bias.html">steps to counteract the biases</a>.</li><li>Be aware that seemingly small UI changes may result in significant backend ML engineering work that may put the overall project at risk. For example, if the wording of a question is changed in your website or app, it can change the response from users and render your historical data useless. Be fully aware of the impact of any recommended changes, <a href="https://zulily-tech.com/2018/04/06/practical-a-b-testing/">A/B Test</a>, and get user feedback!</li><li>Even with the right data, you may still not end up with a working model. For example, <a href="https://developers.google.com/machine-learning/crash-course/generalization/peril-of-overfitting">if your model overfits</a> the <a href="https://developers.google.com/machine-learning/glossary/#training_set">training data</a>, over-learning the data’s details and noise, the model will fail to make correct predictions on new data. Data scientists can address this by “<a href="https://developers.google.com/machine-learning/glossary/#regularization">regularizing</a>” the model.</li><li>Asking for too much user data without any visible benefit can cause the user to abandon your product. Provide value to your users as early as possible before asking them for more data.</li><li>You need to have the appropriate security and privacy precautions in place any time your model includes or relies on personal data. Proactively consult with your company’s legal, safety, and security teams for advice in this area.</li></ul><h4>8. Expect to iterate</h4><p>Once your model is deployed, continue to iterate and improve on it. Easily 80% of the work happens <strong>after </strong>the first version of an ML model is shipped to production. This work includes model improvements as well as adding new signals and features into the model as more data becomes available and new insights come to light.</p><h3>Conclusion</h3><p>Machine Learning provides massively scalable solutions for recommendations, ranking, classification, anomaly identification, and more. Experimental in nature and time-consuming, ML projects require clear goal definitions and measures of success for evaluating the end results that are expected from your ML model.</p><p>As a PM, expect to manage stakeholder expectations around project objectives and deliverables, make prioritization tradeoffs, and ensure that the right data is selected for your model. Above all, expect to iterate, because the initial launch is just the first step in a complex, challenging, and rewarding journey.</p><h3>Resources and References</h3><ul><li>Harvard Business Review, <a href="https://hbr.org/2018/04/if-your-data-is-bad-your-machine-learning-tools-are-useless">If Your Data Is Bad, Your Machine Learning Tools are Useless</a></li><li><a href="https://developers.google.com/machine-learning/guides/rules-of-ml/">Google Developers, <em>Rules of Machine Learning, Best Practices for ML Engineering</em></a> by Martin Zinkevich</li><li><a href="https://www.productschool.com/">Product School</a>, <a href="https://www.youtube.com/watch?v=5z1Hz-rV4zY">Machine Learning for Product Managers</a> by <a href="https://www.linkedin.com/in/lozanoaguilera/">Ruben Lozano-Aguilera</a></li><li><a href="https://blog.dominodatalab.com/machine-learning-product-management-lessons-learned/">Machine Learning Product Management: Lessons Learned</a> by Ann Spencer</li><li><a href="https://christophergs.github.io/machine%20learning/2019/03/17/how-to-deploy-machine-learning-models/">How to Deploy Machine Learning Models</a> by Christopher Samiullah</li><li>A Veteran Data Scientist’s Perspective: <a href="https://zulily-tech.com/2018/07/03/managing-your-first-data-science-or-machine-learning-project/">Managing your First Data Science or Machine Learning Project </a>by Paul Sheets</li><li>Google Design, <a href="https://medium.com/google-design/human-centered-machine-learning-a770d10562cd">Human-Centered Machine Learning</a></li><li><a href="https://medium.com/towards-artificial-intelligence/the-50-best-public-datasets-for-machine-learning-d80e9f030279">Towards AI, <em>The 50 Best Public Datasets for Machine Learning</em></a> by Stacy Stanford and Roberto Iriondo</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fb2a0d6%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fb2a0d6%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href">https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f91bbc3b2776" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/when-and-how-to-add-machine-learning-to-a-product-roadmap-f91bbc3b2776">When and How to add Machine Learning to a Product Roadmap</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Final Project: React/Redux]]></title>
            <link>https://medium.com/@kenlynterai/final-project-react-redux-decf320c29d4?source=rss-e7807f924c51------2</link>
            <guid isPermaLink="false">https://medium.com/p/decf320c29d4</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[json-web-token]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Kenlyn Terai]]></dc:creator>
            <pubDate>Wed, 15 Nov 2017 21:17:17 GMT</pubDate>
            <atom:updated>2019-03-21T04:57:28.277Z</atom:updated>
            <content:encoded><![CDATA[<p>It was with a certain excitement and dread that I approached the final project. “It is supposed to be your magnum opus — a culmination of<br>all the skills you’ve learned so far,” they said. “Go wild!…you’re free to add on as much stuff as you’d like,” they said.</p><p>The latter endorsement was an invitation to too much fun, with frequent refiguring about how to scale the next coding obstacle. This is what I ended up building:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CngdaGr3g72h1UzmcU40wQ.png" /></figure><p><strong>Snappy Name</strong>: We/Mix</p><p><strong>Domain</strong>: A full CRUD music video playlist builder</p><p><strong>Why</strong>: Because music drives creativity and it’s fun</p><p><strong>Source API</strong>: <a href="http://www.theaudiodb.com/forum/viewtopic.php?f=6&amp;t=7">Audiodb.com</a> and <a href="https://developers.google.com/youtube/iframe_api_reference">YouTube’s iFrame Player API</a> utilized via the <a href="https://www.npmjs.com/package/react-youtube">react-youtube</a> package</p><p><strong>Authentication</strong>: The <a href="https://rubygems.org/gems/bcrypt/versions/3.1.11">bcrypt gem</a> and <a href="https://jwt.io/">JSON Web Tokens (HS256 algorithm)</a></p><p><strong>Rails API Testing</strong>: Model and request testing via <a href="https://github.com/rspec/rspec-rails">rspec-rails</a>, <a href="https://github.com/thoughtbot/shoulda-matchers">shoulda-matchers</a>, <a href="https://github.com/thoughtbot/factory_bot_rails">factory_bot_rails</a>, and <a href="https://github.com/stympy/faker">Faker</a></p><p><strong>Styling Packages</strong>: <a href="https://github.com/schrodinger/fixed-data-table-2">fixed-data-table-2</a>, <a href="https://github.com/socialtables/react-image-fallback">react-image-fallback</a>, <a href="https://react.semantic-ui.com/introduction">semantic-ui-react</a></p><p>I learned so much from doing this project which would encompass more than just one blog post. To begin with, I got to put Test Driven Development and JSON Web Token Authentication into practice. The following are some highlights:</p><h4>Creating a useful Rails API</h4><p>Although I’d worked through labs and understood the concepts in their individual parts, I had not yet created an API which could handle CRUD actions. It seemed like the best way to accomplish this was to take a Test Driven Development approach to ensure that I would build what I wanted.</p><p>I leaned on Luke’s series of Instructor Videos as guidelines in test buildout and ensuring that my API was coming through as expected. I got a lot of practice using <a href="https://www.getpostman.com/">Postman</a>, used only sporadically in API Development labs, and finally became really comfortable using it. I was also introduced to<a href="https://itunes.apple.com/us/app/rested-simple-http-requests/id421879749?mt=12"> RESTed</a>, another great tool to quickly format and make HTTP requests and view the response.</p><h4><strong>Authentication</strong></h4><p>I was curious about using JSON Web Tokens since it had not been introduced in the course material. Following one of Luke’s aforementioned study group videos for the initial build out on the backend, I dove into the “Wild West” of React Authentication to find my own solution. Here’s a summary of the steps I took to build mine:</p><h4><a href="https://github.com/kkterai/we-mix-api">Rails Backend: we-mix-api</a> (1)</h4><p><strong>Step 1: Implement password hashing and encryption with bcrypt</strong></p><ol><li>Enabled the <a href="https://github.com/codahale/bcrypt-ruby">bcrypt gem</a> in my <a href="https://github.com/kkterai/we-mix-api/blob/master/Gemfile">gemfile</a> for password hashing and encryption and ran bundle install</li><li><a href="https://github.com/kkterai/we-mix-api/blob/master/db/migrate/20171009204327_create_users.rb">Created a user migration</a> with :username, :password_digest, and :email attributes</li><li>Going to the user model, enabled has_secure_password to take advantage of ActiveRecord methods that tap into bcrypt (e.g. authenticate ). Also added validations for :email and :username presence and uniqueness.</li><li>Now routes are needed to enable creation of users on signup. In the config/routes.rb file, I added the `post ‘/signup’, to: “users#signup”` route</li><li>In the Users Controller,users_controller.rb, I created the signup method and a private `user_params` to make sure that only permitted parameters are included in User creation.</li><li>I added a <a href="https://github.com/kkterai/we-mix-api/blob/master/app/controllers/api/v1/sessions_controller.rb">Sessions Controller</a> and then wrote a basiclogin action.^</li><li>With both Users and Sessions Controllers set up to encrypt passwords and then authenticate Users, I turned to implementing JWT.</li></ol><p><strong>Step 2: Enable coding and decoding of user attributes with JSON Web Tokens</strong></p><ol><li>Added the <a href="https://rubygems.org/gems/jwt">jwt-gem</a> to my gemfile (JWT info: <a href="https://jwt.io/">https://jwt.io/</a>) and ran bundle install</li><li>Select a hashing algorithm — I ran with the default, HMAC (HS256)</li><li>I needed methods to create and decode JWT’s. To implement this, I created an <a href="https://github.com/kkterai/we-mix-api/blob/master/lib/auth.rb">auth.rb file in the </a><a href="https://github.com/kkterai/we-mix-api/blob/master/lib/auth.rb">lib folder</a>, built an `Auth` class, and then built create_token and decode_token class methods according to the video. The create_token method takes a User object as an argument and then creates a token associated with it.</li><li>Now to make these methods useful. In <a href="https://github.com/kkterai/we-mix-api/blob/master/app/controllers/api/v1/users_controller.rb">the Users Controller</a>, I want to create a token when a user signs up for my app. <a href="https://github.com/kkterai/we-mix-api/blob/master/app/controllers/api/v1/users_controller.rb">If a User has saved, then a token would be created at the same time</a>, effectively logging them in at the same time.</li><li>Turning to the Sessions Controller and session creation, the login action receives a user’s email and password and then finds a user by email and authenticated by their password. If both are true, a JWT token is created and sent to the client via JSON.</li></ol><p>^If present, comment out protect_from_forgery_with: :exception line in `application_controller.rb`. protect_from_forgery exists to protect Rails applications from Cross-Site Request Forgery (CSRF), a serious vulnerability from placing trust on the session identification cookies passed between browser and server. JSON Web Tokens would replace the function of Rails’ default CSRF protections.</p><h4><a href="https://github.com/kkterai/we-mix-app"><strong>React/Redux Client: we-mix app</strong></a></h4><p>On the React side, my goals were to enable Users to</p><ul><li>Login and CRUD their own video playlist</li><li>Prevent other users from seeing their playlist or perform any other action on the User’s account</li><li>Logout</li></ul><p>To accomplish this, I did the following:</p><ol><li>Created <a href="https://github.com/kkterai/we-mix-app/blob/master/src/containers/forms/LoginPage.js">LoginPage</a> and <a href="https://github.com/kkterai/we-mix-app/blob/master/src/containers/forms/SignUpPage.js">SignUpPage</a> Containers.</li><li>I decided that the JWT would be stored in localStorage, which is not in itself connected to the store. Because of this, I decided to place functions involved in Login and Signup We/Mix API calls in an <a href="https://github.com/kkterai/we-mix-app/tree/master/src/api"><strong>api directory</strong></a>. User sign up, or registration, occurs in a <a href="https://github.com/kkterai/we-mix-app/blob/master/src/api/userApi.js"><strong>UserApi Class</strong></a> containing a signup function which “POST’s” a new User’s email, username, and password to the create action in the Users Controller. User login occurs in a <a href="https://github.com/kkterai/we-mix-app/blob/master/src/api/sessionApi.js"><strong>SessionApi Class</strong></a><strong> </strong>containing a login function which “POST’s” a User’s credentials to the login action in the Sessions Controller. Both of these calls result in a returned JWT which is then stored in the window’s localStorage.</li><li>I still wanted to have Session and User actions connected to the store. I did this by</li></ol><p><strong>(1)</strong> importing bindActionCreators from redux, and connect from react-redux to both the <strong>LoginPage</strong> and <strong>SignUpPage containers.</strong></p><p><strong>(2)</strong> setting up a <a href="https://github.com/kkterai/we-mix-app/blob/master/src/actions/sessionActions.js"><strong>sessionActions file</strong></a> to hold sessions-related action creators. So far, these action creators set the received JWT to localStorage and clear the token from localStorage on logout.</p><p><strong>(3)</strong> Similarly, I set up a <a href="https://github.com/kkterai/we-mix-app/blob/master/src/actions/userActions.js"><strong>userActions file</strong></a><strong> </strong>to hold user-related action creators which set the received JWT to localStorage.</p><p><strong>(4) </strong>I am still considering <strong>adding actions</strong> to each of these files and <strong>dispatching them</strong> to the <strong>user_reducer</strong> to add an “authenticated” attribute to the store. However, it’s not yet clear that it would be helpful since I’ve successfully implemented an EnsureLoggedIn wrapper component, which brings me to…</p><p>4. Protection from other viewers: The Rails API only sends videos associated to the authorized user in the index action. I created an <a href="https://github.com/kkterai/we-mix-app/blob/master/src/containers/EnsureLoggedIn.js">EnsureLoggedIn wrapper component</a> to protect routes unless a user was logged in.</p><h4>Acknowledgments</h4><p>With all of the ideas in my head, I could not have accomplished this without the community at Learn and talking through ideas with friends and instructors. Special thanks go to Luke Ghenco for direction, Alice Balbuena for the invaluable study group and for taking time, and Chris Cole, David Kennell, and Jaci Hayden for their general support. Thank you!!</p><h3>References</h3><ol><li>Luke Ghenco, “<a href="http://instruction.learn.co/video_lectures/104">JWT Authentication With Rails</a>,” January 27, 2017</li><li>Sophie DeBenedetto, “<a href="http://www.thegreatcodeadventure.com/jwt-authentication-with-react-redux/">JWT Authentication with React + Redux</a>,” September 9, 2016</li><li>Adam Khoury, “<a href="https://www.youtube.com/watch?v=klLMeL7I4O0">JavaScript Storage Interface sessionStorage localStorage Tutorial</a>,” Oct 4, 2015</li><li>Raja Rao DV, “<a href="https://github.com/rajaraodv/react-redux-blog">React Redux CRUD App/react-redux-blog</a>,” Accessed November 2017 (<a href="https://medium.com/@rajaraodv/securing-react-redux-apps-with-jwt-tokens-fcfe81356ea0">Associated blog :Securing React Redux Apps With JWT Tokens</a>)</li><li>Scott Luptowski, “<a href="https://medium.com/the-many/adding-login-and-authentication-sections-to-your-react-or-react-native-app-7767fd251bd1">Adding Login and Authentication Sections to your React or React Native app</a>,” Aug 25, 2016</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=decf320c29d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Props and Data Flow in ReactJS]]></title>
            <link>https://medium.com/@kenlynterai/data-handling-in-reactjs-c53f66b45309?source=rss-e7807f924c51------2</link>
            <guid isPermaLink="false">https://medium.com/p/c53f66b45309</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Kenlyn Terai]]></dc:creator>
            <pubDate>Tue, 15 Aug 2017 18:51:38 GMT</pubDate>
            <atom:updated>2017-08-15T21:02:37.903Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>(or “Props are Awesome”)</strong></h4><p>ReactJS comes with a slew of new words and new definitions for existing ones. “Props” is no exception.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*yrTcL8iDMHUrJMb7XHS-AA.png" /><figcaption>Not ReactJS “props”</figcaption></figure><p>To understand the meaning of “props” in ReactJS, I turned to the context where it is used — in this case, React components.</p><h4>Components tell React what you want to render</h4><p>Facebook introduced <strong><em>declarative components</em></strong>, or <strong><em>components</em></strong> for short, as the heart of ReactJS (2). In fact, <strong>everything</strong> in ReactJS is a component made up of cheap-to-create <a href="https://facebook.github.io/react/docs/rendering-elements.html">React Elements</a>. Components return exactly one DOM element having <strong>only one parent element</strong>. If you are using <a href="https://facebook.github.io/react/docs/jsx-in-depth.html">JSX</a>, for example, you can only have one parent HTML element and all other elements must be children nested under that parent.</p><h4>Components vs. JS functions</h4><p>Breaking components down further, components are “conceptually like <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions">JavaScript functions</a>. They accept arbitrary, read-only inputs (<strong>props</strong>) and return <a href="https://facebook.github.io/react/docs/rendering-elements.html">React elements</a> describing what should appear on the screen.” (4) What does that mean for you and me? It means that our components can be more dynamic and a <strong>lot more</strong> reusable. (<a href="https://github.com/learn-co-students/react-props-v-000">Learn.co Props</a>)</p><p>As far as conventions go, Component names are always capitalized - so you’ll know a component when you see one in React.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*lJGnWPKtgQrawmuqaHIaBg.jpeg" /><figcaption>Modern Capitalization Rules</figcaption></figure><h4>The Anatomy of a Basic Component</h4><p>As any good JavaScript function would do, in order to return a value other than the default, a component must have a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return">return</a> statement that specifies the value to return. In this case, the default return value is <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined">undefined</a>.(3) There are only two requirements that <strong>define a JavaScript function as a React component</strong>:</p><ol><li>The function accepts a single “props” object argument with data</li><li>It returns a React element</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*GorzgGU4FQ-M_-8S95Icaw.png" /><figcaption>A simple “Functional” component</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*aNm317Zfs643jIZg0DDsBQ.png" /><figcaption>The equivalent “Class” component</figcaption></figure><p>Whether you declare a component <a href="https://facebook.github.io/react/docs/components-and-props.html#functional-and-class-components">as a function or a class</a>, <strong>it must never modify its own props</strong>. Such functions are called <a href="https://en.wikipedia.org/wiki/Pure_function">“pure”</a> because they do not attempt to change their inputs, and always return the same result for the same inputs. <strong>All React components must act like pure functions with respect to their props.</strong>(4)</p><h4>Immutable != Boring</h4><p>To sum up what props are in React, they</p><ul><li>Are data passed to components — values can be anything: a string, an array, functions, and so on</li><li>Are immutable</li><li>Enable components to become more reusable</li></ul><p>So, if props are read-only, what place do they have in creating dynamic web applications? You pass a prop to your component. What happens? <a href="https://genius.com/Langston-hughes-harlem-what-happens-to-a-dream-deferred-annotated#note-1040829">Does it dry up / Like a raisin in the sun?</a>…<a href="https://genius.com/Langston-hughes-harlem-what-happens-to-a-dream-deferred-annotated#note-1093223"><em>Or does it explode?</em></a><em>. </em>Nope — it can now be accessed by calling this.props in the render() function as well as most other React component methods.(6, 7)</p><p>Thanks to the <a href="https://tylermcginnis.com/imperative-vs-declarative-programming/">declarative programming approach</a> taken by React, you can just focus on what an application should look like and state the “address” of the props attribute you want expressed, instead of being concerned with manually updating DOM, adding and removing classes, and so on. Just tell React what the end result should be.</p><h4>What do Props have to do with Data Flow?</h4><p>There are basically two ways that data gets handled in React: <strong>props</strong> and <strong>state</strong> (available through this.state ). A third is context, not discussed here, which is more advanced and not currently guaranteed stable (<a href="https://facebook.github.io/react/docs/context.html">React Docs: Context</a>).</p><p>While a component can’t change its own <strong>props</strong>, it <em>can</em> change its <strong>state</strong>…Props and state are used as input for the <em>render()</em> method to determine its output. The render() method also calls the diff algorithm which recognizes any changes in the component and logs them for batching to the “real” DOM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nvQ3jAPwnU7cnlLMPNJnzA.png" /><figcaption>Credit: Tarun Sharma: “Understanding virtual DOM react js” <a href="https://www.youtube.com/watch?v=UH6dz6IGbK4">https://www.youtube.com/watch?v=UH6dz6IGbK4</a></figcaption></figure><h4>Example from React Docs</h4><p>Here is an example from <a href="https://facebook.github.io/react/docs/components-and-props.html">Components and Props </a>in the React Docs. This code renders “Hello, Sara” on the page:</p><pre>function Welcome(props) {<br>  return &lt;h1&gt;Hello, {props.name}&lt;/h1&gt;;<br>}</pre><pre>const element = &lt;Welcome name=&quot;Sara&quot; /&gt;;<br>ReactDOM.render(<br>  element,<br>  document.getElementById(&#39;root&#39;)<br>);</pre><p><a href="http://codepen.io/gaearon/pen/YGYmEG?editors=0010">Try it on CodePen.</a></p><p>Let’s recap what happens in this example:</p><ol><li>We call ReactDOM.render() with the &lt;Welcome name=&quot;Sara&quot; /&gt; element.</li><li>React calls the Welcome component with {name: &#39;Sara&#39;} as the props.</li><li>Our Welcome component returns a &lt;h1&gt;Hello, Sara&lt;/h1&gt; element as the result.</li><li>React DOM efficiently updates the DOM to match &lt;h1&gt;Hello, Sara&lt;/h1&gt;.</li></ol><p>This example does not include state, which I will go into as I learn more about it. For now, know that state is similar to props, but it is private and fully controlled by a component. For examples which <em>do</em> include state, see <a href="https://facebook.github.io/react/docs/state-and-lifecycle.html">State and Lifecycle</a> in the React Docs.</p><h4>When to use Props vs. State</h4><p><strong>State</strong> only gets used if a component has an <strong><em>internal value</em> </strong>that only affects that component and does not affect any of the rest of the app. If it only affects layout and nothing else, state may be appropriate. Aside from that, you want to use <strong>props</strong> (or “<strong>prop</strong>erties”) which are injected into every other component (1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bsS8ETUQqgBpAoT2D6tjmw.png" /><figcaption>Credit: Tarun Sharma: “Understanding virtual DOM react js” <a href="https://www.youtube.com/watch?v=UH6dz6IGbK4">https://www.youtube.com/watch?v=UH6dz6IGbK4</a></figcaption></figure><p>As good rule of thumb from Learn.co’s ReactJS <a href="https://github.com/learn-co-students/react-initial-state-v-000">Initial State</a> lesson, the best way to figure out if data should go in props or state is to ask <em>&#39;Will this data ever change?&#39;</em>. If not, it&#39;s a prop. If it will, it should go in state!</p><h3>References:</h3><p>(1) <a href="https://www.youtube.com/watch?v=qh3dYM6Keuw">ReactJS Tutorial #4 — State vs. Props and Application Data</a></p><p>(2) <a href="https://www.youtube.com/watch?v=XxVg_s8xAms">Facebook Developers (Tom Occhino and Jordan Walke) <em>Introduction to React.js</em></a><em> (2013)</em></p><p>(3) <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions">MDN web docs: JavaScript Functions</a></p><p>(4) <a href="https://facebook.github.io/react/docs/components-and-props.html">React Docs: Components and Props</a></p><p>(5) <a href="https://github.com/learn-co-students/react-initial-state-v-000">Learn.co Initial State</a></p><p>(6) <a href="https://github.com/learn-co-students/react-props-v-000">Learn.co Props</a></p><p>(7) <a href="https://genius.com/Langston-hughes-harlem-what-happens-to-a-dream-deferred-annotated">Langston Hughes — “A Dream Deferred”</a> (Why? Just ‘ cause it’s good poetry :-))</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c53f66b45309" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Introduction to ReactJS]]></title>
            <link>https://medium.com/@kenlynterai/introduction-to-react-js-dd2a2d1ae4d4?source=rss-e7807f924c51------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd2a2d1ae4d4</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Kenlyn Terai]]></dc:creator>
            <pubDate>Tue, 08 Aug 2017 04:04:36 GMT</pubDate>
            <atom:updated>2019-11-09T14:57:29.326Z</atom:updated>
            <content:encoded><![CDATA[<p>Among the first questions I had before getting into the React section of the <a href="https://www.flatironschool.com/programs/online-web-developer-career-course/">Flatiron School’s Online Full Stack Web Developer program</a> was, “what is the difference between React Native and ReactJS?” <a href="https://medium.com/@alexmngn/from-reactjs-to-react-native-what-are-the-main-differences-between-both-d6e8e88ebf24">As Alexis Mangin summarizes</a>, while they are very similar, “React Native is a framework, [whereas] ReactJS is a javascript library you can use for your website.” As a full stack web developer, I’m excited to be learning ReactJS! Onward to the first lesson, <a href="https://github.com/learn-co-students/javascript-virtual-dom-v-000">JavaScript Virtual DOM</a>.</p><p><strong>Note 11/09/19</strong>: Originally written in context to ReactJS <a href="https://github.com/facebook/react/releases/tag/v15.6.1">v15.6.1</a>, this has been reviewed to ensure it is current to <a href="https://github.com/facebook/react/releases/tag/v16.11.0">16.11.0</a>.</p><h3>Why React?</h3><p>From the <a href="https://facebook.github.io/react/blog/2013/06/05/why-react.html">React documentation</a>, React isn’t an MVC framework, “[it is] a [JavaScript] library for building composable user interfaces. It encourages the creation of <strong>reusable UI components</strong> which <strong>present data </strong>that <strong>changes over time </strong>(emphasis added).” Going into two key reasons more deeply…</p><h3>1) DOM trees are massive</h3><p>The popularity of dynamic web apps (<em>Single Page Applications</em> — SPAs) have come with large DOM trees which require constant updates, resulting in significant<strong> </strong>development and performance pain for developers. For example, as <a href="http://reactkungfu.com/2015/10/the-difference-between-virtual-dom-and-dom/">Bartosz Krajka states</a>, “if you [lose] the context of an event handler that you need to change, you have to dive really deep into the code to even know what’s going on. Both time-consuming and bug-risky.”</p><p>Instead of using templates, React breaks UI’s down into <strong>components. </strong>Therefore, instead of using low-level techniques like traversing the DOM tree manually, you simple <em>declare</em> how a component should look. In other words, React does the low-level calls to HTML DOM API methods for you!</p><h3>2) Fewer real DOM changes === higher performance.</h3><p>As great as automating DOM updates is, it does not meaningfully solve the performance issue. And this is exactly where React’s use of the <strong>Virtual DOM</strong> comes into play.</p><ul><li>The<strong> Virtual DOM is a technique </strong>which builds a <em>virtual</em> representation of what a document should look like.</li><li>Through <strong>reconciliation </strong>(<a href="http://jsfiddle.net/2h6th4ju/">JSFiddle example</a>), React automatically diffs and re-renders any changes made to data over time, unlike the manual changes required by various other approaches (e.g. <a href="https://code.angularjs.org/1.0.8/docs/guide/directive#reasonsbehindthecompilelinkseparation">Angular.js</a>).</li><li>Tremendous efficiency gains are realized through bundling, or<strong> “batching,” </strong>changes together and then implementing them at the same time, thus minimizing the number of <em>real, </em>or HTML<em>, </em>DOM modifications.</li></ul><p><a href="https://github.com/learn-co-students/javascript-virtual-dom-v-000">As noted</a>, Virtual DOM is an especially great choice when building apps where changes in the interface happen a <em>lot</em>.”</p><h4>About Performance — How does it work anyway?</h4><p>To begin with, let’s look at React’s two model data types that control a component, props and state. From the <a href="https://facebook.github.io/react/docs/thinking-in-react.html">React Docs</a>, <strong>props</strong> pass data from parent to child and are <strong>fixed</strong> throughout the lifetime of a component. <strong>state</strong>, on the other hand, is reserved only for <strong>interactivity</strong>, or data that changes over time. More on React State and Lifecycle <a href="https://facebook.github.io/react/docs/state-and-lifecycle.html">here</a>.</p><h4>React Components vs. Elements</h4><p>As for how diffs are found and calculated, we need to look again to the Virtual DOM. Detached from the hinderances of browser-specific implementation details, the Virtual DOM serves as React’s local and simplified copy of the HTML DOM, allowing React to do its computations quickly and efficiently. React Components and Elements are the keys to these computations.</p><p><strong>ReactElements</strong> are used most frequently and are “<a href="http://reactkungfu.com/2015/10/the-difference-between-virtual-dom-and-dom/">light, <strong>stateless</strong>, immutable, virtual representations of DOM element</a>s…[and] live in the Virtual DOM.”** (<a href="https://facebook.github.io/react/docs/react-api.html">React Docs</a>).</p><p><strong>ReactComponents</strong>, in contrast,<strong> </strong>are <strong>stateful</strong>, meaning that whenever their state changes, the component is rerendered. Though they don’t have access to the Virtual DOM, they are easily converted to ReactElements, which capture changes in the Virtual DOM.</p><h3>In Summary</h3><p>What I’ve learned so far: React provides significant development and performance gains over manual front-end methods. Instead of taking the slow process of manually changing the “real,” or HTML, DOM, it uses the Virtual DOM technique and its diff algorithm to implement changes in React like this:</p><ol><li>A change is made on a website which registers to a ReactComponent</li><li>The changed ReactComponentis then converted to aReactElement</li><li>TheReactElement is inserted to the virtual DOM</li><li>The diff algorithm compares and updates the Virtual DOM quickly and easily</li><li>Virtual DOM diffs are batched and then converted to the low-level (HTML DOM) code, which is executed in the DOM and optimized per browser.</li></ol><ul><li>* Facebook “recommends <a href="https://facebook.github.io/react/docs/introducing-jsx.html">using JSX</a> to describe what your UI should look like. Each JSX element is just syntactic sugar for calling <a href="https://facebook.github.io/react/docs/react-api.html#createelement">React.createElement()</a>”</li></ul><p><strong>References:</strong></p><p><a href="https://github.com/learn-co-students/javascript-virtual-dom-v-000">Learn.co — “JavaScript Virtual DOM”</a></p><p><a href="https://medium.com/@alexmngn/from-reactjs-to-react-native-what-are-the-main-differences-between-both-d6e8e88ebf24">Alex Mangin — “What Are the Main Differences Between ReactJS and React-Native?”</a></p><p><a href="https://facebook.github.io/react/blog/2013/06/05/why-react.html">React documentation</a></p><p><a href="http://reactkungfu.com/2015/10/the-difference-between-virtual-dom-and-dom/">Bartosz Krajka — “The Difference Between Virtual DOM and DOM”</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd2a2d1ae4d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[jQuery Rails Project — a Gifty App Encore]]></title>
            <link>https://medium.com/@kenlynterai/jquery-rails-project-gifty-encore-994bf7837ab0?source=rss-e7807f924c51------2</link>
            <guid isPermaLink="false">https://medium.com/p/994bf7837ab0</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[jquery]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[Kenlyn Terai]]></dc:creator>
            <pubDate>Mon, 31 Jul 2017 23:32:41 GMT</pubDate>
            <atom:updated>2019-07-22T15:20:58.764Z</atom:updated>
            <content:encoded><![CDATA[<p>Reaching the Rails jQuery Project felt like an achievement, but it turns out that there was so much more ahead. I spent time reviewing <a href="https://learn.co/">Learn</a> lessons and videos, reading some <a href="https://github.com/getify/You-Dont-Know-JS">You Don’t Know JS</a>, viewing You Tube tutorials, and breaking and building things. Some highlights are below.</p><h3>First things</h3><p>Learn says, “<strong>Do not use </strong><strong>remote: true in this application.” </strong>So I had to ask, “why not/what is abstracted away?” In sum, <strong>remote:true</strong>adds AJAX via JavaScript under the hood when you either add <strong>remote:true</strong> to Rails’ form builders or by using <a href="http://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html#built-in-helpers"><strong>built-in Helpers</strong></a> .</p><h4><em>Abstracted components</em></h4><p>Rails uses a technique called “<a href="https://en.wikipedia.org/wiki/Unobtrusive_JavaScript">Unobtrusive JavaScript</a>” to handle attaching JavaScript to the DOM. Instead of “Inline JavaScript”, which mixes JavaScript into HTML by placing scripts directly inside of HTML elements, Unobtrusive JavaScript separates concerns by placing JavaScript in separate files. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cJWu8R7dgTJ0UNTeol9Plw.png" /><figcaption>Inline JavaScript</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qA0ABACv1AwlD5czJcld9A.png" /><figcaption>Unobtrusive JS: HTML</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*X26FmshTswsOeJg26Aw1EQ.png" /><figcaption>Unobtrusive JS: JavaScript</figcaption></figure><p>From the <a href="http://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html">Rails Guides: Working with JavaScript in Rails</a>:</p><p>“<em>Unobtrusive JavaScript is generally considered to be a best-practice within the front-end community… Because of Unobtrusive JavaScript, any Rails ‘Ajax helpers’ are actually in two parts: the JavaScript half and the Ruby half. Unless you have disabled the Asset Pipeline, </em><a href="https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts/rails-ujs.coffee"><em>rails-ujs</em></a><em> provides the JavaScript half, and the regular Ruby view helpers add appropriate tags to your DOM.</em>”</p><p>For example, in “Gifty,” there is a form which allows gift givers to ask questions about wished-for items:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*mWYFWSEDv-uAsQ2r0qfKIw.png" /><figcaption>The “Ruby View Half”: /list_items/show.html.erb — Comment form HTML and Rails Form helpers</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*kjwFs3nMcyvq4xo5QNx1AA.png" /><figcaption>Resulting HTML</figcaption></figure><p>These forms are submitted via AJAX with this JavaScript code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*7nC1RGr-SaSlZ5e-goKoww.png" /><figcaption>The “JavaScript Half” : javascripts/list_items.js</figcaption></figure><p>With <strong>remote:true</strong>, <strong><em>the Ruby View Helpers and Javascripts are rolled into one,</em></strong> submitting the form as before:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*khrhC5YwBtG0UeapMlWvJw.png" /><figcaption><strong>Ruby Views and Javascript Rolled into one: </strong>/list_items/show.html.erb — Comment form, remote:true added</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*xX3Wm7LflrJyReQdpANIxg.png" /><figcaption>Resulting HTML</figcaption></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F26ufnwz3wDUli7GU0%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F26ufnwz3wDUli7GU0%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F26ufnwz3wDUli7GU0%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a3ec61fb03686c13a930eea3981ca86/href">https://medium.com/media/0a3ec61fb03686c13a930eea3981ca86/href</a></iframe><p>And the form is submitted by AJAX — <em>no written code needed</em>!</p><h4><strong>Debugging XHR Object Errors, Debugging JavaScript, Debugging…</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c6b6pfnJLeSMg8qW4MGjQQ.png" /><figcaption>Photo of red nemesis</figcaption></figure><p>After getting through different phases of anger and denial, I finally came to accept that I would have to confront those red XHR objects if I was going to get a working app. It was time for more review.</p><h4><strong>AJAX</strong></h4><p>To understand AJAX, I had to go back to the beginning and review <a href="http://celineotter.azurewebsites.net/world-wide-web-http-request-response-cycle/">the Request and Response Cycle</a>. Here is an explanation from <a href="http://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html#an-introduction-to-ajax">the Rails Guides</a> : “When you type http://localhost:3000 into your browser&#39;s address bar and hit &#39;Go,&#39; the browser (a.k.a the &#39;client&#39;) makes a request to the server. It parses the response, then fetches<strong> all associated assets</strong>, like JavaScript files, stylesheets and images. It then assembles the page. If you click a link, it does the same process: fetch the page, fetch the assets, put it all together, show you the results.”</p><p><strong><em>But what if I don’t want all the things? Enter XHR and AJAX</em></strong></p><p>Instead of going through the entire cycle all over again, it’s possible to request <strong>only the server data that we need</strong> via the <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest"><strong>XMLHttpRequest</strong></a>. In other words, you can retrieve data from a URL without having to do a full page refresh. But how is this possible, you ask? The <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest"><strong>XMLHttpRequest object</strong></a>, or <strong>XHR</strong>, is a JavaScript API that allows us to transfer data between a client and a server. This has resulted in billions of happy users who experience only a partial page update without disrupting what they are doing. XMLHttpRequest is used heavily in <a href="https://developer.mozilla.org/en-US/docs/AJAX"><strong>AJAX</strong></a> (Asynchronous JavaScript + XML) programming.</p><p>As defined in Jesse James Garrett’s article, <a href="http://adaptivepath.org/ideas/ajax-new-approach-web-applications/"><strong>AJAX: A New Approach to Web Applications</strong></a>:</p><blockquote>Ajax isn’t a technology. It’s really several technologies, each flourishing in its own right, coming together in powerful new ways. Ajax incorporates:</blockquote><blockquote>- standards-based presentation using XHTML and CSS;</blockquote><blockquote>- dynamic display and interaction using the Document Object Model;</blockquote><blockquote>- data interchange and manipulation using XML and XSLT;</blockquote><blockquote>- asynchronous data retrieval using <a href="http://www.xml.com/pub/a/2005/02/09/xml-http-request.html">XMLHttpRequest</a>;</blockquote><blockquote>- and <a href="http://www.crockford.com/javascript/javascript.html">JavaScript</a> binding everything together.</blockquote><p>Instead of loading a webpage, at the start of the session, the browser loads <strong>an Ajax engine</strong> — written in JavaScript and usually tucked away in a hidden frame (see diagram, below). This engine is responsible for both rendering the interface the user sees and communicating with the server on the user’s behalf.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bWeIqd_YqUFmMt-OkTlxQg.png" /></figure><p>The result? A much better user experience!</p><p><strong>Now back to the regularly scheduled error…</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rbexwneAfpuG2DYV2np5Fg.png" /></figure><p>As an illustration, this line provided the url, <a href="http://localhost:3000/list_items/undefined">http://localhost:3000/list_items/undefined</a>. /undefined told me that an id was not being defined correctly. The second half jquery.self... told me that that it originated somewhere from a jQuery method. I found the possible culprit near the top of one of my functions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*9foNQ6HhCNRRdqravgmVkw.png" /></figure><p>I had to learn what value of id the $.get() method was receiving, so I placed a debugger just under var id , like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9FAs5k_w3qdcoyOCQi8xmg.png" /></figure><p>I then clicked on the “next” link at the top of the page, which called the nextListItem function and triggered debugger in the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*GvUbNCIRbuRWjzP2VaroAA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*-_sS742tJbsoe8aG2RR5sA.png" /></figure><p>Reconfirming that the debugger was located as expected, I went to the JavaScript console and typed “id” to see what value id contained. Voila! It was undefined!…but why?? So I took a careful look at my code and discovered that while the HTML page had “js-next” defined as a <strong>class</strong>, I had it defined as an <strong>id</strong> in JavaScript.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*3BNxl_x3eZrRY7xfMsxBqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/191/1*WsMVi2zG2-DTgTsFff67GA.png" /><figcaption>left:<strong> class </strong>“js-next” ; right: <strong>id</strong> “js-next”</figcaption></figure><p>It worked after fixing the code!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/189/1*hTIGJSd2nTf_PAqsL_KaJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*3BNxl_x3eZrRY7xfMsxBqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*WNYuR_dwKXhq6tINvL0Blg.png" /></figure><p><strong>Summing up</strong></p><p>In the end, the continuing process of building out a jQuery front end for the Gifty app has been an invaluable experience. I’ve learned even more than I’ve described and look forward to React.js!</p><p><strong>References:</strong></p><p><a href="https://learn.co/tracks/full-stack-web-dev-with-react/advanced-javascript/accessing-remote-apis-with-javascript/xhr">Learn.co: XHR</a></p><p><a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest">Mozilla’s MDN web docs: XMLHttpRequest</a></p><p><a href="https://learn.co/tracks/full-stack-web-dev-with-react/advanced-javascript/accessing-remote-apis-with-javascript/jquery-ajax-and-callbacks">Learn.co: jQuery AJAX and Callbacks</a></p><p><a href="http://guides.rubyonrails.org/working_with_javascript_in_rails.html">Rails Guides: Working with JavaScript in Rails</a></p><p><a href="https://www.w3schools.com/jquery/jquery_ref_ajax.asp">jQuery AJAX Methods</a></p><p><a href="https://www.tutorialspoint.com/javascript/javascript_events.htm">JavaScript Events</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=994bf7837ab0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Learning Journey Continues: My Rails Assessment Project]]></title>
            <link>https://medium.com/@kenlynterai/the-learning-journey-continues-my-rails-assessment-project-2692ab864f5b?source=rss-e7807f924c51------2</link>
            <guid isPermaLink="false">https://medium.com/p/2692ab864f5b</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Kenlyn Terai]]></dc:creator>
            <pubDate>Mon, 08 May 2017 18:46:12 GMT</pubDate>
            <atom:updated>2017-05-09T15:03:37.188Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EMuDrN8gLR7AcfUiv3qXEg.png" /></figure><p>At long last, I’ve submitted my Flatiron School/Learn Rails project, <a href="https://github.com/kkterai/gifty-app">“Gifty”</a>, an application that simplifies gift giving. The premise: Enable users to find out what friends would love as gifts, create a shopping list for these gifts, and to know whether or not someone else has already bought the item(s). You can find the <a href="https://github.com/kkterai/gifty-app">Github repo here</a> and a <a href="https://drive.google.com/file/d/0BxTfGFwB1IsuYm81VW15NU0ydU0/view">video walkthrough here</a>.</p><p>There were many lessons learned during this project, including but not limited to an introduction to deployment (differences between Figaro and dotenv gems), deeper understanding of Activerecord and ORMS in general, and an expanding view of what can be done in Rails.</p><p>While my Rails Project is complete, I’m not calling it “done.” With feature ideas, bug fixes, and UI improvements on the works, I’m looking forward to seeing how far it can be developed!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2692ab864f5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails: Active Record Validations]]></title>
            <link>https://medium.com/@kenlynterai/rails-active-record-validations-part-1-20085908e6ff?source=rss-e7807f924c51------2</link>
            <guid isPermaLink="false">https://medium.com/p/20085908e6ff</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Kenlyn Terai]]></dc:creator>
            <pubDate>Thu, 17 Nov 2016 21:51:24 GMT</pubDate>
            <atom:updated>2017-07-31T23:59:00.067Z</atom:updated>
            <content:encoded><![CDATA[<p>Working through the Flatiron BnB lab in Learn.co’s Rails section has been a great challenge. In the throes of this, I want to share some lessons learned about Active Record Validations in under a five minute read for you, another committed Learner.</p><p>First, why validate? In Google, various searches around “unvalidated data” , “database”, and “web application” resulted in a common result: unvalidated input is one of the most — if not <strong><em>the </em></strong>most — critical areas of Web Application security vulnerability. If developers allow input into databases without validating first, they put those databases at risk by leaving applications open to attack via SQL injection.</p><p>If you are now convinced to get on the Validation Train, you are probably wondering, “HOW do I do it?” Validations essentially ensure that only valid data is saved into a database. From the perspective of Rails, Model-level validations are the best choice in most circumstances and will be the focus here.</p><p><strong>The Object Life Cycle: The “When” of Active Record(AR) Validations</strong></p><p>Rails runs validations before saving an AR object to the database. There are two key points in time that have convenient validation-triggering methods:</p><ul><li>Between when a new AR object is created and when a SQL <strong>INSERT</strong> operation is sent to the database (Methods: CREATE,CREATE! ,SAVE,SAVE!)</li><li>Between when an <strong>existing record</strong> is edited in an edit form and when a SQL <strong>UPDATE</strong> operation is sent to the database (Methods:UPDATE,UPDATE!)</li></ul><p>If errors are produced at any of these points, the object will not be saved to the database. Note that you can also run validations on your own. VALID? triggers your validations and returns true if no errors were found in the object, and false otherwise.</p><p>After running validations, an object’s collection of errors can be accessed by calling the errors.messagesinstance method. If this collection is empty, then the object is considered valid.</p><p><strong>Active Record: Pre-Defined Validation Helpers</strong></p><p>Here is a list of the available helpers from <a href="http://guides.rubyonrails.org/active_record_validations.html#validation-helpers">Rails Guides: Active Record Validations — Validation Helpers</a>, below.</p><p><em>Helpers used within specific model classes:</em></p><ul><li><a href="http://guides.rubyonrails.org/active_record_validations.html#acceptance">acceptance</a>: validates that a checkbox on the user interface was checked when a form was submitted.</li><li><a href="http://guides.rubyonrails.org/active_record_validations.html#validates-associated">validates_associated</a>: When you try to save your object, valid? will be called upon each one of the associated objects.</li><li><a href="http://guides.rubyonrails.org/active_record_validations.html#confirmation">confirmation</a>: Two text fields must receive exactly the same content (e.g. email confirmation). Must be used along with a presence check and case sensitivity defaults to true.</li><li><a href="http://guides.rubyonrails.org/active_record_validations.html#exclusion">exclusion</a>: Validates that specific attribute values are <strong>not</strong> included.</li><li><a href="http://guides.rubyonrails.org/active_record_validations.html#format">format</a>: Validates the attributes&#39; values by testing whether they match a given regular expression.</li><li><a href="http://guides.rubyonrails.org/active_record_validations.html#inclusion">inclusion</a>: Validates that specified attributes’ values are included.</li><li><a href="http://guides.rubyonrails.org/active_record_validations.html#length">length</a>: Validates the length of attribute values. Constraint options include :minimum, :maximum ,:in(or :within), and :is.</li><li><a href="http://guides.rubyonrails.org/active_record_validations.html#numericality">numericality</a>: Validates that your attributes have only numeric values. Default is to convert a value to a Float; set :only_integer to true to allow only integral numbers. There are additional constraint options available, such as :greater than. See documentation for details.</li><li><a href="http://guides.rubyonrails.org/active_record_validations.html#presence">presence</a>: Can not only validate that specified attributes are not empty, but can also validate the presence of an association. In addition, you can also validate presence of associated records by using the :inverse_of option for the association. See documentation for validating presence of a boolean field.</li><li><a href="http://guides.rubyonrails.org/active_record_validations.html#absence">absence</a>: Validates that the specified attributes are absent.</li><li><a href="http://guides.rubyonrails.org/active_record_validations.html#uniqueness">uniqueness</a>: Validates that the attribute’s value is unique right before the object gets saved.</li><li><a href="http://guides.rubyonrails.org/active_record_validations.html#validates-each">validates_eac</a>h: This helper validates attributes against a block.</li></ul><p><em>Helpers which register custom validations across many model classes:</em></p><ul><li><a href="http://guides.rubyonrails.org/active_record_validations.html#validates-with">validates_with</a>: This helper passes the record to a <strong>separate class</strong> where custom validations have been defined. This separate class inherits from <strong>ActiveModel::Validator.</strong></li></ul><p><strong>Implementing Active Record Helpers</strong></p><p>Good for minimizing lines of code, each helper accepts an arbitrary number of attribute names. With a single line of code you can add the same kind of validation to several attributes! For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*5phqTY9orONYQSjcEfP2yw.png" /></figure><p>All but the <a href="http://guides.rubyonrails.org/active_record_validations.html#validates-each">validates_eac</a>h and <a href="http://guides.rubyonrails.org/active_record_validations.html#validates-with">validates_with</a> methods must be registered by using the validates class method.</p><p>All of the helpers accept the :on and :message options; :on defining when the validation should be run and :messagedefining what message should be added to the errors collection if it fails. You can find more on these options’ use <a href="http://guides.rubyonrails.org/active_record_validations.html#common-validation-options">here</a>.</p><p><strong>References and further reading</strong></p><ul><li><a href="https://www.wired.com/2016/05/hacker-lexicon-sql-injections-everyday-hackers-favorite-attack/">Hacker Lexicon: SQL Injections, an Everyday Hacker&#39;s Favorite Attack</a></li><li><a href="http://guides.rubyonrails.org/active_record_validations.html">Active Record Validations - Ruby on Rails Guides</a></li><li><a href="http://rubular.com/">Rubular: a Ruby regular expression editor and tester</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20085908e6ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shopstik: A Sinatra Portfolio Project]]></title>
            <link>https://medium.com/@kenlynterai/shopstik-a-sinatra-portfolio-project-fc64b3d6a380?source=rss-e7807f924c51------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc64b3d6a380</guid>
            <category><![CDATA[sinatra]]></category>
            <category><![CDATA[twitter-bootstrap]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Kenlyn Terai]]></dc:creator>
            <pubDate>Sat, 05 Nov 2016 07:41:29 GMT</pubDate>
            <atom:updated>2016-11-05T07:41:29.388Z</atom:updated>
            <content:encoded><![CDATA[<p>What is “Shopstik?” A simple, friendly Sinatra web app that allows users to create secure personal accounts and create lists, edit, and delete items. This project was exciting in that it is the first web app that I’ve built. Here’s an overview of the project and how it works.</p><p><strong>Defining the Functionality and MVC</strong></p><p>I spent some time up front on my white board deciding what I wanted my app to do, what level of complexity it should have, and what views I needed.</p><p><em>Models:</em> In the end, I decided on two classes: a User class which would have_many :itemsand an Items class which would belong_to Users. The defined migrations are pictured below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*lDo1edljOTD-9p6ZP1CVjw.png" /><figcaption>CreateUsers migration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*J5DLSEStI6mF8-YbXNX59Q.png" /><figcaption>CreateItems migration</figcaption></figure><p><em>Views:</em> Developed for a CRUD app, there are erb files to support creating new users and items, viewing items in a list, editing single items, and deleting items.</p><p><em>Controllers:</em> There is a Users Controller and Items Controller which inherit from an Application Controller (configuration defined, below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*E-beGip60GySIcGfgp238Q.png" /></figure><p><strong>User Experience</strong></p><p><em>Welcome and error messages:</em> Since Sinatra does not come with flash messages like Rails does, I used the ‘rack-flash3’ gem to have session-based flash messages for user signup and login.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rr4IoASr4bDMahJatDLPkg.png" /></figure><p><em>HTML development and Mobile-First</em>: Since many companies take a “mobile first” approach to responsive app and website development, I tried my hand at working with Bootstrap templates as a first attempt. I found good sources of inspiration at <a href="http://bootsnipp.com/">http://bootsnipp.com/</a>. This effort resulted in a consistent clean and simple UI, pictured above and below.</p><p>For more information about this app visit my <a href="https://github.com/kkterai/shopstik-app">Github repository</a> or view this <a href="https://drive.google.com/open?id=0BxTfGFwB1IsuUWFtTmc0Z1ozUlU">video walkthrough</a>. Thanks for reading!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T20oxnQaQs7Ta5zOiLxVYQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc64b3d6a380" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic Website Components: An Overview]]></title>
            <link>https://medium.com/@kenlynterai/creating-a-basic-website-an-overview-ffc08a802928?source=rss-e7807f924c51------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffc08a802928</guid>
            <dc:creator><![CDATA[Kenlyn Terai]]></dc:creator>
            <pubDate>Tue, 01 Nov 2016 00:11:01 GMT</pubDate>
            <atom:updated>2017-07-31T23:45:32.354Z</atom:updated>
            <content:encoded><![CDATA[<p>Within Flatiron’s Full stack web development program, I’ve had the opportunity to learn Hypertext Markup Language (HTML) and am only beginning to get an idea of its capabilities. Creative Bloq has some gorgeous examples of websites created with HTML (see below).</p><p><a href="http://www.creativebloq.com/web-design/examples-of-html-1233547">23 amazing HTML examples</a></p><p>Where does someone begin to create something like this? What is “Hypertext Markup Language” anyway? What makes it work? Here’s a brief summary:</p><p><strong>Markup Language</strong></p><p>As you read this blog, you are looking at <strong>your browser’s interpretation of the markup language</strong> (in this case, HTML) sent by the server.</p><blockquote><a href="https://en.wikipedia.org/wiki/Markup_language"><strong>Markup language</strong></a><strong>:</strong> a system for <a href="https://en.wikipedia.org/wiki/Annotation">annotating</a> a <a href="https://en.wikipedia.org/wiki/Document">document</a> in a way that is <a href="https://en.wikipedia.org/wiki/Syntax_(logic)">syntactically distinguishable</a> from the text. The idea and terminology evolved from the “marking up” of paper manuscripts when editing authors’ <a href="https://en.wikipedia.org/wiki/Manuscript">manuscripts</a> in publishing. In <a href="https://en.wikipedia.org/wiki/Digital_media">digital media</a> physical mark up was replaced by <a href="https://en.wikipedia.org/wiki/HTML_element">tags</a>. Examples: <a href="https://en.wikipedia.org/wiki/HTML">HTML</a>, <a href="https://en.wikipedia.org/wiki/CSS">CSS</a>, <a href="https://en.wikipedia.org/wiki/DSSSL">DSSSL</a>, <a href="https://en.wikipedia.org/wiki/XSL-FO">XSL-FO</a>, <a href="https://en.wikipedia.org/wiki/Troff">troff</a>, <a href="https://en.wikipedia.org/wiki/XML">XML</a>, <a href="https://en.wikipedia.org/wiki/XLink">XLink</a>, and <a href="https://en.wikipedia.org/wiki/XPath">XPath</a></blockquote><p><strong>Using HTML</strong></p><p>Along with <a href="https://en.wikipedia.org/wiki/Cascading_Style_Sheets">Cascading Style Sheets</a> (CSS), and <a href="https://en.wikipedia.org/wiki/JavaScript">JavaScript</a>, HTML is one of three key technologies for Web Development. <a href="https://en.wikipedia.org/wiki/Web_browser">Web browsers</a> receive HTML documents from a <a href="https://en.wikipedia.org/wiki/Webserver">webserver</a> or from local storage and render them into multimedia web pages.</p><p>There are three components involved in creating a web page with HTML:</p><ol><li>Browser software: Default characteristics for every item of HTML markup are defined in the browser, and these characteristics can be altered or enhanced by the web page designer’s additional use of Cascading Style Sheets (<a href="https://en.wikipedia.org/wiki/Cascading_Style_Sheets">CSS</a>).</li><li>Server: Delivers HTML documents and other content by Hypertext Transfer Protocol (<a href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">HTTP</a>).</li><li>HTML Document: Contains the markup that is interpreted by the browser.</li></ol><p>That’s how to make a website in its most basic form. Enjoy creating!</p><p><strong>Further reading:</strong></p><ul><li><a href="https://www.w3.org/">W3C</a></li><li><a href="http://diveintohtml5.info/semantics.html#new-elements">Semantics - Dive Into HTML5</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffc08a802928" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>