<?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 Alex S. on Medium]]></title>
        <description><![CDATA[Stories by Alex S. on Medium]]></description>
        <link>https://medium.com/@alxsanborn?source=rss-a7533f026c3d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kTlJGsKxbUkrpFLH_LHwgA.gif</url>
            <title>Stories by Alex S. on Medium</title>
            <link>https://medium.com/@alxsanborn?source=rss-a7533f026c3d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 20:53:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alxsanborn/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[Source Control in Github]]></title>
            <link>https://medium.com/@alxsanborn/source-control-in-github-f8610fd306f3?source=rss-a7533f026c3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8610fd306f3</guid>
            <category><![CDATA[collaboration]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Alex S.]]></dc:creator>
            <pubDate>Thu, 26 Jan 2017 18:56:44 GMT</pubDate>
            <atom:updated>2017-01-30T22:48:21.948Z</atom:updated>
            <content:encoded><![CDATA[<p>Or how I learned why it’s important to create branches when you’re doing a project.</p><p>When I first started learning to write code, I was really reluctant about creating branches. It wasn’t that I was a stranger to the concept of losing your work. Coming from an English major background and having taught for a few years, I was very familiar with computers losing your work or “losing your work” or “my #{computer} ate my homework.” When I wrote papers, I always took the extra measure of clicking the save icon with the picture of the floppy disk every time I had written an important paragraph, even when I knew that in this day and age, MS word autosaves.</p><p>In programming, the convention to saving work requires saving it in a minimum of two places. The local save and then the save on your Github repository. It’s like saving an essay on the computer and on Dropbox, but the reason for saving it to both is not just to play it safe in case one or the other breaks down but because it’s necessary to document work publicly for others to see it. For this reason it’s necessary to properly document each change through clear <a href="http://chris.beams.io/posts/git-commit/">commit messages</a> and BRANCHES.</p><p>First off, what is branching? The word “branch” actually provides a really good metaphor for what it is. If your master branch is the centrally located trunk, the individual branches provide content that stem from but ultimately feed back into the trunk. Each branch, though directly related to the trunk in some way, is partitioned apart from the branches — meaning each will contain its own content. It’s actually a really organized way of saving your work. For instance, say you’re writing an essay called “Chivalry in <em>Knight of the Burning Pestle</em>” (a 16th Century English Play) and you are suddenly inspired to inegrate a comparison to Shakespeare’s <em>Henry IV</em>. Do it. But you should create a branch and add all of your changes to a branch called “henry-iv.” This way, if you change your mind tomorrow or your professor reads your rough draft and thinks you’re going down a troublesome route, you can just delete it, rather than have to read through the essay six times to eradicate all sentences containing mention of <em>Henry IV</em>.</p><p>Here’s how you move back and forth between branches….</p><ol><li>To ‘initiate’ the start of a new branch:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*tn615GEatZ3IdKbMcyyxcQ.png" /></figure><p>Especially when you work on your own projects alone, it’s very easy to want to skip this step and just push straight to the master branch. You remember your own workflow, and you remember that three days ago, you added the method that you now realized contains a bug that you need to fix, and so you’re confident that you definitely know where and when the code went wrong and how you’re going to fix it, and these extra steps just kind of slow you down….right? Wrong. The problem is that you ALONE remember. It’s like the organized slob: you alone remember where you put your keys, but if you’re ever in a situation where you need someone else to find them, you’re screwed. And it’s good to establish organized work habits every time you code so that way when you do work on a team, you don’t need to think twice about how you’re going to structure your work flow for your colleagues.</p><p>You can make any number of branches….For example: front-end, controllers, models, #{whatever} function, etc. And if there’s a problem with some specific feature, branching makes it much easier to see all of the code that relates to the feature, track all of the changes, and isolate the problem, rather than wade through the master branch commit message by commit message.</p><p>2. After you’ve made your changes, commit and push to the local branch as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*lgxoMSLMKrfxxpW_ivthig.png" /></figure><p>Here is how you merge:</p><ul><li>Switch back to the master branch after you’ve ‘git push’ed to the read-me (or whatever) branch:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*40eYpNilaX8_6vGlK009WQ.png" /></figure><ul><li>Merge your changes:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*-KIIC8S_2zxYlOdV8iN6RA.png" /></figure><ul><li>From here, you’ll need to get on your Github repository and click on the green button that says “Compare &amp; pull request”:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*dNtwMs79-DGYRbuVwoRCCQ.png" /></figure><ul><li>Add in any additional comments you want to make and click “Create pull request”:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8-Phq2P9TBX2W8u3yEgkMQ.png" /></figure><ul><li>You’ll land on this page where you’ll have the option to click on “Merge pull request” when you want to merge:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*eV5Tv562VhUAqeSRsym6rg.png" /></figure><p>…..What’s convenient about working on branches is that you can make as many commits as you want before final merging the branch into the master. I made two commits below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*2ydUzQN0EccynxWIFLNKvg.png" /></figure><ul><li>***What’s also nice about branching is that it’s much more convenient to revert if you’ve realized you made a mistake! Let’s see what happens when you click the button that says “Revert”….</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*fYHvT4d9xGaGZhSbMiqNUA.png" /></figure><ul><li>It opens a new pull request to revert the changes! Very convenient and clear.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MZPw38ZZrOq9tSGxc5q_gg.png" /></figure><ul><li>From there, make the pull request. Github will structure your revert as a separate branch in itself, as shown below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EXDX67OHiWSq7AfyvkehsA.png" /></figure><p>All your changes will be reverted in a convenient and clear manner, and you can fix your code as necessary. I learned this lesson the hard way when I was working on a project recently. I had spent a few days working on the front-end parts, when I realized I wanted to start over and create my routes and controllers in a test-driven manner. However, because I had been pushing straight to the master branch, and nothing else, the process of reverting was less ‘clean.’ I ended up doing a ‘git reset’ to the commit I wanted to reset back to and started over from there. However, the commit message history creates a lot of guesswork for outsiders who want to view y work:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vQav-DFttl-Ok9-gBvArRg.png" /><figcaption>First set of commit messages</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*XJBt_N1RFLG1AoOQRjdIlg.png" /><figcaption>“Do-over” set of commit messages</figcaption></figure><p>Roughly the same actions performed on the code here (routes, controllers…), but different dates and commit message numbers. Was I doing edits and building on previous work? Reverting? An outsider would have to examine the commits thoroughly and do some guesswork about what I was doing exactly. I ended up leaving a comment (dialog bubble next to the copy/paste symbol) next to all of my reset changes, but it’s really not the best practice. I guess the moral of this story is, when you consistently follow organized workflow practices throughout, you’re better positioning yourself to adequately communicate your work to others.</p><p>Part two will account for what happens when there’s a merge conflict, which usually happens when you’re working in groups….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8610fd306f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Material UI Date Picker and Time Picker]]></title>
            <link>https://medium.com/@alxsanborn/material-ui-date-picker-and-time-picker-930df28dc1d7?source=rss-a7533f026c3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/930df28dc1d7</guid>
            <category><![CDATA[material-ui]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[time-picker]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[datepicker]]></category>
            <dc:creator><![CDATA[Alex S.]]></dc:creator>
            <pubDate>Mon, 07 Nov 2016 01:54:56 GMT</pubDate>
            <atom:updated>2016-11-07T01:54:56.117Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m going to talk about the Material UI <a href="http://www.material-ui.com/#/components/date-picker">Date Picker</a> and <a href="http://www.material-ui.com/#/components/time-picker">Time Picker</a>, specifically highlighting, based on my experience working with these components, what a developer can and can’t do with these. Material UI is a library with Google-like front-end components for React.js. The Date Picker is a component that allows a user to pick a date on a calendar visual pop-up, and the Time Picker is another component that allows a user to pick a time on a clock visual pop-up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*UZN0QGHpKOlL_ImjDiFtxQ.png" /><figcaption>Default image for Date Picker</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*Wl05tgYFZPBvPNFfIPeewg.png" /><figcaption>Default image for Time Picker</figcaption></figure><p>There are options that allow developers to customize the colors and a few other features on these components (see documentation), but for the most part this is what you get.</p><p>For my project, it was necessary for my users to be able to choose a date and a time. Material UI does not provide an integrated, single field Date &amp; Time Picker at the moment. When I did research, some people suggested <a href="https://github.com/ripjar/material-datetime-picker">this alternative</a>, but if you’d like to just stick to the Material UI components, keep reading. I was ok with having each as separate fields. My biggest concern was: since dates and times are stored as a DateTime object in a database, how would I combine the information from each separate field to be one, single object? There are two possible ways to do this.</p><p>My approach was:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a727a5238dec3392f2e7e80be109b04/href">https://medium.com/media/5a727a5238dec3392f2e7e80be109b04/href</a></iframe><ul><li>Lines 9 &amp; 10: Designate separate state fields for <em>date</em> and <em>time</em> in the constructor.</li><li>Lines 53 &amp; 54: Date Picker and Time Picker fields are listed separately, and the value attributes for each have their respective state fields.</li><li>Lines 53 &amp; 54: Separate event listeners for <em>date</em> and <em>time</em>.</li><li>Lines 19–21 &amp;&amp; 23–25: Set up the argument this way (event followed by the date/time); the date/time will be rendered as the second argument, after the event. Use setState to set the new state to the the value(<em>date</em> or <em>time</em>) in the field as I did.</li><li>Lines 27–33: This is where the ‘magic’ happens. Even though so far,<em> date</em> and <em>time</em> have been separate fields in state, for some reason, either React or the Material UI component seem to ‘know’ that the two need to be combined together and do just that. On line 29, the field <em>date_time</em> would correspond to whatever you’ve chosen to name that attribute in your database (my project interacted with a Rails API). But as you can see, I only needed to assign <em>this.state.date</em> and to that attribute and it takes both date and time!</li><li>Line 32: Make sure that after the form gets submitted, you’re resetting the date and time fields back to null.</li></ul><p>This approach was the most simple and requires the least lines of code. But it might be a bit confusing if someone else is trying to read your code for them to follow how exactly date and time are being rendered in your form submissions. They might even assume you’ve forgotten something and begin tinkering with your code that already works.</p><p>Using <a href="http://momentjs.com/">Moment.js</a>, a module for parsing and manipulating time in JavaScript is a very transparent way to show other developers exactly what is going on with the two objects. So you’d install and import Moment.js however you want to (I use npm, personally), and then you’d insert the following lines of code in your handleSubmit function, between lines 27 &amp; 28, right before you grab the values and insert them into the object that will get sent back to the database. Your handleSubmit function might look something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e9d34760946946e8759cba9375bf7da/href">https://medium.com/media/2e9d34760946946e8759cba9375bf7da/href</a></iframe><p>Lines 2–10: All of the logic, showing how you’re rendering the time and date into the single DateTime object.</p><p>Line 12: Assigning the new object (renderedDateTime) to the <em>date_time</em> attribute in the database (in my case, the Rails API).</p><p>Thank you for reading. If you’ve noticed any errors or you have any suggestions for how this could be done better, please feel free to leave a comment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=930df28dc1d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Forms in React.js / Redux using Material UI]]></title>
            <link>https://medium.com/@alxsanborn/forms-in-react-js-redux-using-material-ui-ec08c2ce23bc?source=rss-a7533f026c3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec08c2ce23bc</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[material-ui]]></category>
            <dc:creator><![CDATA[Alex S.]]></dc:creator>
            <pubDate>Fri, 04 Nov 2016 04:02:12 GMT</pubDate>
            <atom:updated>2016-11-04T16:52:46.835Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I will go over creating forms in React.js using <a href="http://www.material-ui.com/#/">Material UI</a>, specifically to highlight what is essential in the React.js form. Material UI is a component library that provides Google-like front-end for React, specifically. You can see the React project that corresponds to this post <a href="https://github.com/alxsanborn/houseMate-React">here</a>.</p><p>Using Material UI with React throws a wrench in pretty much whatever you thought you knew about forms, but if you can figure out how to work it in React, you will feel like the master of forms.</p><p>If you’re interested in seeing the entire file (imports, submit button, everything….), scroll down all the way to the bottom. React and Redux are super complex and sometimes it really helps to see how all of the code functions together as a whole. Otherwise, keep reading. I’ll break down each part of the code as I talk about it. If you want to compare to the current documentation, what I’m doing is pretty similar to <a href="https://facebook.github.io/react/docs/forms.html">building a form with uncontrolled components</a>.</p><p>First off, I think it’s much cleaner to build a React.js/Material UI form using state, rather than without state. I’ll explain what happens when you just try to use refs later. For now, here is my basic form with state:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a52cbbb1d43de517bc3a28550b269908/href">https://medium.com/media/a52cbbb1d43de517bc3a28550b269908/href</a></iframe><p>Here’s a breakdown of what’s going on in the input tags (TextField, DatePicker, etc.):</p><blockquote>hintText: Not super essential to get the form to work, but definitely essential for your user in terms of basic UI/UX.</blockquote><blockquote>Event Listener(onChange): This is <strong>extremely essential</strong>. Without this, especially if you have two or more fields, your form input fields will freeze and you will be unable to type anything. Another way to think about this: if you set the default value of your initial state as an empty string (or whatever), having an input field that does not respond to change forces the input field to remain in whatever the initial state is.</blockquote><blockquote>Value: Not essential. The form works with or without it.</blockquote><p>*****If you’re using Material UI for the submit buttons, format your code the way we did above(putting each button in an array called ‘actions’) in the render but outside of the ‘return.’ I can’t explain why you need to do this, only that when I tried to put the buttons inside the form tags, none of my seed data would load and the page was unresponsive. We used onTouchTap instead of onClick/onSubmit as the Event Listener because according to the documentation, it’s supposed to be more responsive. Material UI can also be used for mobile devices, and that’s what onTouchTap corresponds to, ideally.</p><p>Notice that in each Event Listener, there is a different handler function for each field’s change. Here is what that looks like in the code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7d1931e9e7133f9f38923fb51d424e4/href">https://medium.com/media/e7d1931e9e7133f9f38923fb51d424e4/href</a></iframe><p>Each Event Handler is designed to respond to and set the state of each input field individually. I’ll go over the formatting for the time and date handlers in a future post. As of now, for text inputs, you’ll be grabbing the value via ‘event.target.value.’</p><p>When your user is ready to submit, you can just integrate all of your states into an object, the same way you would do it otherwise in Redux:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1757bfb2effa445d2b0c1ddcd0e09041/href">https://medium.com/media/1757bfb2effa445d2b0c1ddcd0e09041/href</a></iframe><p>If you want to attempt a stateless React component, you are able to use refs as an alternative. So for example:</p><blockquote>&lt;TextField hintText=”What chore needs to be completed?” refs={‘name’} /&gt;</blockquote><blockquote>&lt;TextField hintText=”What else?” refs={‘otherName’} /&gt;</blockquote><p>I wanted to see what would happen, so I put in a debugger in the handleSubmit function (before line 2 in the above snippet) so that I could enter debugger mode right after clicking, but before the fields could populate. This is what it would take to retrieve the value of name from the field:</p><blockquote>this.refs.name.refs.component.input.value</blockquote><p>Similarly, this is what it took to retrieve the value of the ‘otherName’ from the other field:</p><blockquote>this.refs.otherName.refs.component.input.value</blockquote><p>Very messy.</p><p>Anyways, thanks for reading and I hope this helps anyone struggling with integrating React with Material UI form components. This was my solution, but I’m sure there are better ones out there. If you have any suggestions for how I can improve this, please feel free to comment.</p><p>And here is the all of the code in that component, as promised:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c957e63058488f6aac9f5a92e94fece0/href">https://medium.com/media/c957e63058488f6aac9f5a92e94fece0/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec08c2ce23bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Black-Box and White-Box Testing -10/4/16]]></title>
            <link>https://medium.com/@alxsanborn/black-box-and-white-box-testing-5a7adbef4a5e?source=rss-a7533f026c3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a7adbef4a5e</guid>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[rspec]]></category>
            <category><![CDATA[spy]]></category>
            <dc:creator><![CDATA[Alex S.]]></dc:creator>
            <pubDate>Sat, 29 Oct 2016 22:24:11 GMT</pubDate>
            <atom:updated>2016-10-29T22:24:39.399Z</atom:updated>
            <content:encoded><![CDATA[<p>My post will discuss and explore two different methods of testing: black-box testing. When we test, it’s important not only to write working tests, but also to understand why we test for certain components.</p><p>Black-box testing: The test checks for what the code is supposed to do, it’s functionality, not necessarily how it does it. For example -</p><blockquote>def add_two(num)</blockquote><blockquote>num + 2</blockquote><blockquote>end</blockquote><p>An Rspec black-box test would be written in the following manner -</p><blockquote>RSpec describe #add_two do</blockquote><blockquote>it “adds two” do</blockquote><blockquote>test_num = 2</blockquote><blockquote>expect(test_num.add_two).to eq 4</blockquote><blockquote>end</blockquote><blockquote>end</blockquote><p>The black-box test checks that our output produces the expected sum and nothing else. One reason this is useful is for the most basic reason that you do need to check whether your code does what it says it will do. One way to optimize this test is to think of all the possible scenarios and see if your code will break. For example, when you put in “.5,” will your code break? Do you want your code to account for decimals or do you want it to throw an error. Either way, you want your code to be prepared for as many possibilities imaginable. But, it doesn’t test for everything. So for example, if you wanted to write the following code:</p><blockquote>Class Redundant</blockquote><blockquote>attr_accessor :num</blockquote><blockquote>def initialize(num)</blockquote><blockquote>@num = num</blockquote><blockquote>end</blockquote><blockquote>def add_two</blockquote><blockquote>num + 2</blockquote><blockquote>end</blockquote><blockquote>def subtract_two</blockquote><blockquote>num — 2</blockquote><blockquote>def redundant</blockquote><blockquote>subtract_tw0(add_two(add_two(num)))</blockquote><blockquote>end</blockquote><blockquote>end</blockquote><p>If we write the following test:</p><blockquote>describe Redundant do</blockquote><blockquote>describe ‘#redundant’ do</blockquote><blockquote>before do</blockquote><blockquote>@equation = Redundant.new(2)</blockquote><blockquote>end</blockquote><blockquote>it “adds two” do</blockquote><blockquote>test_num = 2</blockquote><blockquote>expect(test_num.redundant).to eq 4</blockquote><blockquote>end</blockquote><blockquote>end</blockquote><blockquote>end</blockquote><blockquote>end</blockquote><p>The test will pass, but we can’t use it to check how many times the #add_two method was called to check for redundancies in this code. This is why white-box testing is helpful. White-box testing checks for how the code is working, the internal structure. For example, when we look at the Sinon testing framework, we have the possibility of checking for the following:</p><blockquote>spy.withArgs(arg1[, arg2, ...]);</blockquote><blockquote>Creates a spy that only records calls when the received arguments match those passed to withArgs. This is useful to be more expressive in your assertions, where you can access the spy with the same call.</blockquote><blockquote>spy.callCount</blockquote><blockquote>The number of recorded calls.</blockquote><blockquote>spy.called</blockquote><blockquote>true if the spy was called at least once</blockquote><blockquote>spy.calledOnce</blockquote><blockquote>true if spy was called exactly once</blockquote><blockquote>spy.calledTwice</blockquote><blockquote>true if the spy was called exactly twice</blockquote><blockquote>spy.firstCall</blockquote><blockquote>The first call</blockquote><blockquote>spy.secondCall</blockquote><blockquote>The second call</blockquote><p>One distinction made between white-box and black-box testing when I was doing my research was that you want to use white-box testing when you’re doing object-oriented programming and you want to check how different components of your code are interacting with each other. This is important because even if your code returns the desired output, the black-box test may give you a false-positive. We want to make sure the code returns the desired output because we intended it to do so in that fashion, rather than because of some other accidental factor. Being able to break down how many times a method was called or tracking which arguments were passed can help us determine such factors. Returning to our redundant code….</p><blockquote>it(‘should call addTwo once’, function()</blockquote><blockquote>{ var spy = sinon.spy(Redundant, ‘addTwo’); //Pass (Object, method) in as optional variables</blockquote><blockquote>Redundant({ num: 2 }, function() { });</blockquote><blockquote>expect(spy.calledOnce).tobeTruthy(“addTwo function was called more than once”)}</blockquote><p>This would return false and help the programmer to recognize that he or she has written redundant code.</p><p>So what is the “happy medium” between the two? It’s Grey-box testing! Even though the term for it is “Grey-box testing,” which suggests some sort of middle ground, Grey-box testing actually means that a programmer ought to make sure they write both kinds of black-box and white-box tests. I guess it also kind of just goes along with being thorough, but I think it’s good to have these frameworks in mind when one is thinking about what needs to be tested in an app.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a7adbef4a5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unicode — 9/19/2016]]></title>
            <link>https://medium.com/@alxsanborn/unicode-9-19-2016-8ec3d3630aeb?source=rss-a7533f026c3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ec3d3630aeb</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[unicode]]></category>
            <dc:creator><![CDATA[Alex S.]]></dc:creator>
            <pubDate>Sat, 29 Oct 2016 21:50:43 GMT</pubDate>
            <atom:updated>2016-10-29T21:50:43.577Z</atom:updated>
            <content:encoded><![CDATA[<p>Unicode (as defined by Wikipedia) is is a computing industry standard for the consistent encoding, representation, and handling of text expressed in most of the world’s writing systems. To paraphrase, it’s the standard system for representing text script characters. The governing body and members include representatives from companies like Microsoft, Apple, Google, Paypal, Intel, IBM, etc. Why is it important for us as web developers to know this? Well, on the most basic level, take a look at line 4 ….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*liBQ6OQbrBVUbX2Bpiy90A.png" /></figure><p>This is unicode! This is how a browser knows that you’re writing in English and how to decipher the English alphabet to render whatever you’re trying to render. It’s all contained in that single line in the HTML header. This is the default that renders when you type in HTML in your file to get the basic HTML template that most text editors give you. So you don’t need to worry about including every time, my point was more of an FYI. But…let’s say that a page renders with a bunch of random symbols that you did not intend to render. That happens because the developer has implemented the incorrect Unicode codeset to read the data.</p><p>Unicode is categorized by different alphabets. Here is a very basic, cut and dry explanation of how we can understand the organization:</p><ul><li>Languages sharing letters from the Latin alphabet will all draw on the “Latin” set of characters, languages sharing letters from the Greek alphabet will all draw on the “Greek” set of characters, Bopomofo (Chinese) has its own set, Korean has its own set, etc.</li><li>English, along with Spanish, French German, etc. all fall under the Latin subset.</li><li>The Latin codesets get divided into other subsets. We start off with Basic Latin, or ASCII (American Standard Code for Information Interchange).<strong> </strong>From there, in order to account for characters like ä, ñ, etc. (sounds/letters that exist in other Latin script-based European languages), Unicode developed “Latin-1 Supplement.” There are several other Latin codesets available such as IPA, Phonetic, Extended (which seems to be for classical Latin).</li><li>Basically, what happened is when the C programming language was being written, the letters that were being considered were the ones used in American English. Then when programmers from other countries wanted to program in C, they just continued to build on the original ASCII. It became messy, especially when Asian alphabets tried to integrate into this system. Hence the need for an organization like Unicode to standardize script outputs.</li></ul><p>So what’s the deal with UTF-8, UTF-16, UTF-32? I’ll try to explain it as best as I can, but I’m just learning about this too. In UTF-8, 1 byte holds 8 bits. In UTF-16, 1 byte holds 16 bits. Most likely because the original designers of C were American, ASCII manages to fit perfectly within the encoding lengths of UTF-8. Unique letters in the other Latin-based languages more or less build on already existing scripts in the ASCII template so it is possible for these languages to exist in as UTF-8 scripts. Typically, it is more advantageous for Asian languages to use UTF-16 over UTF-8. For instance (taken from a Stack Overflow discussion):</p><blockquote>A small example where UTF-16 is actually better than UTF-8:</blockquote><blockquote>Consider the Chinese letter “語” — its UTF-8 encoding is:11101000 10101010 10011110</blockquote><blockquote>While its UTF-16 encoding is shorter:10001010 10011110</blockquote><p>UTF-8 optimizes storage space, whereas you’re more easily able to store information that differs more in complexity from as you increase the size of that end number. This obviously gets more complicated — like I’ve been discussions that say that UTF-16 is not so much the compromise of UTF-8 and UTF-32 as it actually receives the worst of both worlds, and apparently Windows uses a UTF-16 system but still manages to output n ASCII. And then there’s the question of emojis and how they fit into this Unicode codeset (yes, emojis are also a script!). For now, I’ll end this post with this final thought:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*DO8vS3sXhDWHfWlqXaupzQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ec3d3630aeb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Grammar of Rails — 8/19/16]]></title>
            <link>https://medium.com/@alxsanborn/the-grammar-of-rails-8-19-16-fb1ca98d8263?source=rss-a7533f026c3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb1ca98d8263</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[syntax]]></category>
            <dc:creator><![CDATA[Alex S.]]></dc:creator>
            <pubDate>Sat, 29 Oct 2016 21:33:58 GMT</pubDate>
            <atom:updated>2016-10-29T21:33:58.131Z</atom:updated>
            <content:encoded><![CDATA[<p>I had a hard time learning Rails at first. There. I said it. Maybe it’s a little bit embarrassing because the Rails is supposed to be extremely easy to learn, but they say admitting you have a problem is half the battle. Onwards.</p><p>After Googling a bit, I discovered that a lot of the typical difficulty that people tend to have with Rails is because they are complete beginners who want to build a web app, heard through the grapevine that Rails is easy, and think that it’s going to be more or less like Wix or Weebly. I don’t claim to be an advanced programmer by any means, but having a foundation in Ruby programming has helped me parse through the processes and relationships involved in building a web app. And most of the advice I have read has been (more or less): understand Ruby or any other server-side language. I would say that is solid advice and that this blog post is not for the audience who has never dabbled in code.</p><p>Before learning Rails, I had relatively pleasant experiences learning SQL and Sinatra. I think the “grammar” of both appealed to me. For example, a basic SQL command is typically structured as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*N68e2rQxMgodsTIEPm3tZg.png" /></figure><p>Or similarly, in Sinatra:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*eqovnZZWIinEE9a5UKZAmA.png" /></figure><p>Yes, it’s pretty structured and unforgiving. But what I like about SQL is that the language very clearly delineates the action and where the action is performed. It goes back to basic reading comprehension practices. When you’re reading a difficult passage, one of the best strategies you can use to break it down is to ask yourself: where is the action and who/what is performing the action. Basic principles of formulating “active” sentences. SQL and Sinatra very explicitly exhibit these patterns. Whereas this is the Rails structural equivalent of the above Sinatra code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*A9xoGzKa3cnZmoAtxHDSYw.png" /></figure><p>When I read this, I’m reminded of my former students who believe that contorting their sentence structure and throwing in random four syllable synonyms for what they really mean will make them sound “smarter.” It doesn’t. It only frustrates their readers (or their writing instructors) who have to parse through fluff and confusion to identify the action of their sentences. However, unlike an essay, Rails provides a way to manually pry into what these verbs are. Typing in “rake routes” in my Terminal yields the following cheat sheet:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*xLj2gz29tofBqZE_ARjcoA.png" /></figure><p>As you can see, there is so much implied within that single line of code! I’ll parse it out by column.</p><p>Column 1: Calling on pages just got easier. For example, instead of calling on ‘/student/:id’ you can save yourself the extra few seconds and call on student(@student) to call on the instance of any specific student.</p><p>Column 2: Verbs!</p><p>Column 3: Rails generates these patterns based on convention (Rails principle: convention over configuration). In Sinatra, pages like “index,” “new,” etc. are labelled as such because of convention, but calling the page where one would print out all instances of a class as “index” is an otherwise arbitrary name. However, Rails understands index, new, create, and show (code is not displayed in line 2, sorry for any confusion!) as commands (this is how convention really takes root in Rails) and generates standard URI patterns that describe what the page does.</p><p>Column 4: This column corresponds to the file nomenclature in your text editor. Implicitly, even though in this case, you have free rein to name your files what you want, if you want Rails to work correctly, you should name your files following the nomenclature. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/152/1*9H6pBqbngvccmzp79n9WZA.png" /></figure><p>The only file that is unnecessary is the create.html.erb file. If you look at its verb in column 2, you’ll see that unlike the others that correspond to GET, it corresponds to POST. In Rails, if POST is present, Rails will implicitly/behind the scenes perform the action, so you don’t have to make a new erb page for create.</p><p>Why is this better? Productivity. The Sinatra way forces the programmer to write out 11 lines of code for three commands, whereas Rails only requires one line of code for four commands. I’m still not sure I’ve fully warmed up to Rails, but writing this post has definitely helped clarify some of the confusion I experienced when I first encountered Rails.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb1ca98d8263" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Self in Ruby — 8/3/16]]></title>
            <link>https://medium.com/@alxsanborn/understanding-self-in-ruby-2850386983cf?source=rss-a7533f026c3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2850386983cf</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[self]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Alex S.]]></dc:creator>
            <pubDate>Sat, 29 Oct 2016 19:33:46 GMT</pubDate>
            <atom:updated>2016-10-29T21:20:27.458Z</atom:updated>
            <content:encoded><![CDATA[<p>Self is one concept I struggled with while learning Ruby class methods. I wasn’t sure what self referred to. I began to realize that my understanding of self depended on understanding the contexts and purposes of self.</p><p>One thing to fundamentally understand about self: self will always call on the instance of the class.</p><ul><li>Each time you create a new object using the class (object_1 = Class.new), (object_2 = Class.new), etc. object_1 and object_2 are instances of the class.</li><li>When each of these instances (object_1, object_2, etc.) are created, Ruby will “attach” a code/number, along with the returns of any methods in the class. (example: &lt;Class:0x007f8de283bd88 @method_1: nil&gt;.</li><li>Why is it useful to have the instance identifier numbers? If you create an instance of a class that (for whatever reason) contains the exact same information for each field (ex. two instances of @first_name = “Bob” and @dinner = “lasagna”), this is a useful way for you and the computer to distinguish these separate instances. After, it is possible for two different people, both with the first name of “Bob” to eat lasagna for dinner, correct?</li></ul><p>Uses of self:</p><ol><li>Anytime we might want to store instances of the class. One way you might do that is in the initialize method. For example:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*8WQ5ZAzTSNgRT3CBlLz6TA.png" /></figure><p>As you can see, in line 16, when we call the method .view_all_dogs, we return all of the instances of the class Dog created thus far (fido [line 14] &amp; misty [line 15]). Line 6 in the initialize method is where the instance is actually stored. Line 10 provides us with a way to call this method on the class.</p><p>2. Similarly, if we need to return just the instance of the particular class, we can do the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*8WQ5ZAzTSNgRT3CBlLz6TA.png" /></figure><p>Line 19 calls the view_dog method on the instance of fido and returns it. This is denoted in line 13.</p><p>3. Whenever we need to convert an instance method into a class method. Again, referencing the first screenshot example of code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*8WQ5ZAzTSNgRT3CBlLz6TA.png" /></figure><p>Looking at line 9, we can see that self was added to the method. This is how we transform an instance method to a class method. It is necessary to do this because we are describing information about the entire class (the class instances of each dog).</p><p>If we try to return all instances of Dog using an instance method, we get the following error message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*elzX9IH2zD79ocwGrJxacQ.png" /></figure><p>“fido”, as an instance of of the Dog class can call on an instance method (as in example 2 of self above), but Dog, as a class, must be paired with a class method (self.method_name). When we want to ask the class for comprehensive information about it, we must call on it as a class, rather than as an instance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2850386983cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lodash — Javascript]]></title>
            <link>https://medium.com/@alxsanborn/lodash-javascript-eb8ab1cd5bfe?source=rss-a7533f026c3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb8ab1cd5bfe</guid>
            <category><![CDATA[abstraction]]></category>
            <category><![CDATA[lodash]]></category>
            <category><![CDATA[shortcuts]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Alex S.]]></dc:creator>
            <pubDate>Sat, 29 Oct 2016 19:14:19 GMT</pubDate>
            <atom:updated>2016-10-29T19:14:19.537Z</atom:updated>
            <content:encoded><![CDATA[<p>Lodashes (literally, _) are just more shortcuts that help us as programmers write and execute code quicker. The official documentation for how to use them is linked <a href="https://lodash.com/">here</a> and if you import modules via npm, here is their <a href="https://www.npmjs.com/package/lodash">npm install page</a>. Import and then read on….</p><p>When I first encountered this new syntax, I kept seeing everywhere that it was super useful, and in what contexts it might be used. This was nice, but I struggled on the more basic level of what exactly the _ was replacing and what could be attached to it. If you’re familiar with Ruby, the Lodash will make a lot of sense.</p><p>Every lodash function is structured in the following way</p><blockquote>var _ = require(“lodash”)</blockquote><blockquote>_.[lodash method](variables being passed through)</blockquote><blockquote>OR</blockquote><blockquote>var array = [1];</blockquote><blockquote>var other = _.concat(array, 2, [3], [[4]])</blockquote><blockquote>console.log(other); // =&gt; [1, 2, 3, [4]]</blockquote><blockquote>console.log(array); // =&gt; [1]</blockquote><p>Breaking it down:</p><ul><li>_</li></ul><p>The _ is a bit arbitrary, mainly because it depends on what variable you’ve named as how you’re importing it. For example, if you did this:</p><blockquote>var cat = require(“lodash”)</blockquote><p>You’d just write your lodash function like this:</p><blockquote>cat.concat(array, 2, [3], [[4]])</blockquote><p>In other words, the _ is just an arbitrary trademarking convention, more or less. But the convention is tidy and an efficient way of reminding you which library you’re pulling from.</p><ul><li>[lodash methods]</li></ul><p>Available lodash methods are listed on the documentation <a href="https://lodash.com/docs/4.16.4">here</a>. There’s about 100 of them you can use, including methods like flatten, forEach, isDate…etc. Similar to Ruby, these methods are <strong><em>abstractions</em></strong> of messier JS syntax, but this isn’t an official language or part of JS. It’s just a add-on library meant to help you write code quicker. This <a href="http://colintoh.com/blog/lodash-10-javascript-utility-functions-stop-rewriting">blog post</a> has a pretty good run-down of the 10 most useful/likely situations in which you can use the lodash.</p><ul><li>(variables being passed through)</li></ul><p>How/which variables (i.e. an array? an array and a variable?…) get passed through is indicated in the documentation too.</p><p>This post was fairly short and simple, but hopefully helpful. Once I managed to break down what exactly was going on with the syntax (as well as read the documentation…. 👍), things started to click and I now feel a lot more confident about using this fairly simple, easy to use library of shortcuts.</p><p>Thank you for reading. If you have any questions, comments, or if you’ve spotted any inaccuracies, please feel free to reach out!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb8ab1cd5bfe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>