<?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 Charles Bayley on Medium]]></title>
        <description><![CDATA[Stories by Charles Bayley on Medium]]></description>
        <link>https://medium.com/@charlesbayley?source=rss-d3497305bffe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*v44Cqq2bKsCscA7s.</url>
            <title>Stories by Charles Bayley on Medium</title>
            <link>https://medium.com/@charlesbayley?source=rss-d3497305bffe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 09:46:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@charlesbayley/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[Lets Learn About Git Branching!]]></title>
            <link>https://medium.com/@charlesbayley/lets-learn-about-git-branching-4098124a8b0e?source=rss-d3497305bffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/4098124a8b0e</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Charles Bayley]]></dc:creator>
            <pubDate>Tue, 08 May 2018 03:30:45 GMT</pubDate>
            <atom:updated>2018-05-08T03:30:45.535Z</atom:updated>
            <content:encoded><![CDATA[<p>So, what is branching anyways? Branching is the way we split history while using git, as well as most other RCS’s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*qoG_JWK_5X4NIUmql10GKg.png" /></figure><p>It can be visualized as something like the image to the left.</p><p>Now, why should you use branching? Branching developed as a solution to developers disrupting one another during mid-development. Imagine you are working on a project with other developers, you may want to use branches to develop without fear that the other developers code will break yours before it is finished.</p><p>Lets say you finish your feature. Now what? You have to get your code mixed in with what the other developers have done! To do that git provides a few different commands. The two we will take a look at are merge and rebase.</p><p>How do you do it? You can create a new branch with git branch &lt;branch&gt; . Alternately you can do it with git checkout -b &lt;branch&gt; if you want to checkout the branch after its creation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*aSA60fLzWpgwzdWiKcJzbA.png" /></figure><h3>Merging</h3><p>Merging is the first command you can use to recombine your histories.</p><p>Say we are on the master branch and we want to merge in the changes on the apple branch. We could accomplish that like so git merge apple .</p><p>Usually merging is like the image to the right; a new commit with two parents, the commit where the head branch, master, was, and the commit where the branch being merged in, apple, is. It is important to note that the head branch moves up to the merged commit.</p><p>There is another kind of merge called a fast-forward merge. The difference is the merge could be completed without a two parent commit, so the head branch simply moves to the same commit as the merged in branch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*lz53P4Jvd8WJajvow-wM1w.png" /></figure><h3>Rebase</h3><p>Rebase is another way of combining branches.</p><p>If we are on the branch apple, and want to place our changes onto master we could do it with git rebase master .</p><p>That command will creates copies of a branch apple’s commits all the way back to where it diverged and then places those commits on top of the branch master. The branch apple will be moved to the copied commits as well.</p><h3>Comparison</h3><p>You may be asking, which one should I use? Good, I’m here to answer!</p><p>Merge is good when you want to preserve the history exactly as it was created. This is a reasonably position if you don’t mind the extra complexity that comes with it. The extra complexity is usually mild if you are working on a smaller team. This is my default way of combining histories since I like to preserve the history.</p><p>Rebase can be good if you want to simplify the history of a branch. You achieve this simpler history by sort of just pretending the branching never happened. This become much more useful if you are in larger teams and the complexity of a correct history becomes to hard to follow, therefore defeating one of the main points of using a RCS in the first point!</p><p>I’ve supplied a few more images to demonstrate my point about the complexity/truth trade-off below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*fGAJnOCCFNxus6qGgkvQiQ.png" /><figcaption>Complex Merge</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*R1LGZ3VsN3E3rrZweGbdjg.png" /><figcaption>Complex Rebase</figcaption></figure><h3>Conclusion</h3><p>I hope you you learned something here!</p><p>The tool used to create the images is <a href="http://git-school.github.io/visualizing-git/">http://git-school.github.io/visualizing-git/</a> .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4098124a8b0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to C# Operator Overloading]]></title>
            <link>https://medium.com/@charlesbayley/introduction-to-c-operator-overloading-d69912f2c648?source=rss-d3497305bffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/d69912f2c648</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Charles Bayley]]></dc:creator>
            <pubDate>Fri, 27 Apr 2018 01:17:39 GMT</pubDate>
            <atom:updated>2018-04-27T01:17:39.618Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever wanted to use operators such as +, or *, with your custom C# object? If so, this is where you can learn the basics.</p><p>Suppose we have an object representing people like this:</p><pre>public class Person<br>{<br>    public string FirstName;<br>    public string LastName;<br>}</pre><p>Now, I want to be able to create children using two people like this:</p><pre>var dad = new Person { FirstName = &quot;Stevie&quot;, LastName = &quot;Ray&quot; };<br>var mom = new Person { FirstName = &quot;Lucy&quot;, LastName = &quot;Lu&quot; };</pre><pre>// Create a child with Stevie and Lucy<br>var child = dad + mom;</pre><p>Without using operator overloading you could accomplish this via a normal method as such:</p><pre>public class Person {<br>    // Properties hidden<br>    public Person MakeChild(Person otherPerson) {<br>        return new Person {<br>            FirstName = otherPerson.LastName,<br>            LastName = this.LastName<br>        };<br>    }<br>}</pre><p>Then making a child could be done like:</p><pre>var child = dad.MakeChild(mom);</pre><p>Adding a feature like that does work, but for a reproduction operation, it feels a bit unnatural. That is where operator overloading comes into play.</p><p>To overload an operator you have to use the keyword operator followed by the operator you wish to overload. Additionally, the operator must be a method.</p><p>Lets re-implement our MakeChild operation using:</p><pre>public class Person {<br>    // Properties hidden<br>    public static Person operator +(Person leftPerson, Person rightPerson) {<br>        return new Person {<br>            FirstName = rightPerson.LastName,<br>            LastName = leftPerson.LastName<br>        };<br>    }<br>}</pre><p>Now we can make children in the more natural way:</p><pre>var child = dad + mom;</pre><h3>Dangers</h3><p>There is one thing to watch out for when using operators in this way. Make sure you only use them where it really makes sense. Don’t throw them all your code just because they are cool.</p><h3>Opinions</h3><p>I tend to only use operators to add functionality to numeric and math based objects such as currency and vectors. I think it is, usually, better to reserve their use to places where the meaning of the operator is well known, like adding $1.27 with $13.46.</p><p>I hope you enjoyed learning about operator overloading in C#!</p><h3>Working Example</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80490a7c369a7d9a469964e88f13b6c1/href">https://medium.com/media/80490a7c369a7d9a469964e88f13b6c1/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d69912f2c648" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Object Oriented Interfaces]]></title>
            <link>https://medium.com/@charlesbayley/introduction-to-object-oriented-interfaces-90d055acb64c?source=rss-d3497305bffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/90d055acb64c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[interfaces]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Charles Bayley]]></dc:creator>
            <pubDate>Fri, 13 Apr 2018 16:20:35 GMT</pubDate>
            <atom:updated>2018-04-13T16:20:35.833Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello there reader! Today I’m going to explain interfaces that are so common to object oriented styles of programming.</p><p>Lets imagine a world where all animals either have thorns or do not. Now lets say all animals with thorns can poke other animals.</p><p>For example, (new Hedgehog(&quot;Sonic&quot;)).Poke(new Dog(&quot;Benny&quot;)); is how we would have a hedgehog poke a dog.</p><p>For example, say we have an army of thorny animals. We could include both hedgehogs and thorny dragons. Even though they are very distantly related with one being a mammal and the other being a reptile.</p><p>Using inheritance alone the only way to get these animals into one type would be to allow our army to include any animals. Not good, this is an army made for poking and not all animal:</p><pre>var army = new List&lt;Animal&gt;();<br>army.Add(new Hedgehog(&quot;Sonic&quot;));<br>army.Add(new Dog(&quot;Benny&quot;));<br>army.Add(new ThornyDragon(&quot;Pickles&quot;));<br>army.ForEach(animal =&gt;<br>{<br>    // This won&#39;t work since not all animals know how to poke<br>    animal.Poke(new Rabbit(&quot;Rabbit&quot;));<br>}</pre><p>The solution to this problem is interfaces!</p><p>Lets create an interface for all thorny animals called IThorny:</p><pre>interface IThorny<br>{<br>    void Poke(Animal toBePoked);<br>}</pre><p>Unlike classes, interfaces are pretty useless on their own. To be useful we must implement the interface onto some classes:</p><pre>class Animal<br>{<br>    string Name { get; set; }<br>}</pre><pre>class Hedgehog : Animal, IThorny<br>{<br>    void Poke(Animal toBePoked)<br>    {<br>        Console.WriteLine($&quot;The hedgehog {this.Name} has poked {toBePoked.Name} with those tiny thorns hedgehogs have.&quot;);<br>    }<br>}</pre><pre>class ThornyDragon : Animal, IThorny<br>{<br>    void Poke(Animal toBePoked)<br>    {<br>        Console.WriteLine($&quot;{this.Name} the thorny dragon slaps {toBePoked.Name} with a thorny tail.&quot;);<br>    }<br>}</pre><p>Now we can allow all thorny animals to implement our new IThorny interface. Then we can build our army of IThornies instead of animals:</p><pre>var army = new List&lt;IThorny&gt;();<br>army.Add(new Hedgehog(&quot;Sonic&quot;));<br>army.Add(new ThornyDragon(&quot;Pickles&quot;));<br>    <br>var rabbit = new Rabbit(&quot;Rabbit&quot;));<br>army[0].Poke(rabbit);<br>army[1].Poke(rabbit);</pre><p>The above example would now work since we know everything that is an IThorny can poke animals.</p><p>To summarize, interfaces allow programmers to group abilities to preform actions within a type without specifying how that action is done. I hope you can see the value of being able to adding types to classes without specifying functionality.</p><p>Thanks for ready and I hope you enjoyed!</p><p>Working example below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8ec8a457f2ca27d69ffbfe13aed4459/href">https://medium.com/media/c8ec8a457f2ca27d69ffbfe13aed4459/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90d055acb64c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Re-implementation of Array Higher Order Functions in JavaScript]]></title>
            <link>https://medium.com/@charlesbayley/re-implementation-of-array-higher-order-functions-in-javascript-e0768d668872?source=rss-d3497305bffe------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0768d668872</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[functional-programming]]></category>
            <dc:creator><![CDATA[Charles Bayley]]></dc:creator>
            <pubDate>Mon, 19 Mar 2018 19:33:27 GMT</pubDate>
            <atom:updated>2018-03-21T13:22:35.948Z</atom:updated>
            <content:encoded><![CDATA[<h4>Examples of Map Without Higher Order Functions</h4><p>Say we have an array like:</p><pre>const numbers = [1, 2, 3, 4, 5];</pre><p>Now say we want to square all elements of this array. We may do that as:</p><pre>const squaredNumbers = [];</pre><pre>for (let i = 0; i &lt; numbers.length; i++) {<br>    squaredNumbers.push(numbers[i] * numbers[i]);<br>}</pre><p>Lets do the same thing but this time, lets double the elements:</p><pre>const doubledNumbers = [];</pre><pre>for (let i = 0; i &lt; numbers.length; i++) {<br>    doubledNumbers.push(arr[i] * 2);<br>}</pre><p>Now, I happen to see a place for abstraction here. Let me explain: Both of these examples are taking an existing array and pushing each and every element into a new array after running some modification code on that element.</p><p>Lets pull the examples apart a bit more so you can see what I mean:</p><pre>const squaredNumbers = [];</pre><pre>const square = (number) =&gt; {<br>    return number * number;<br>}</pre><pre>for (let i = 0; i &lt; numbers.length; i++) {<br>    const element = numbers[i];<br>    squaredNumbers.push(square(element));<br>}</pre><p>Now lets refactor the doubling example:</p><pre>const doubledNumbers = [];</pre><pre>const double = (number) =&gt; {<br>    return number * 2;<br>}</pre><pre>for (let i = 0; i &lt; numbers.length; i++) {<br>    const element = numbers[i];<br>    doubledArr.push(double(element));<br>}</pre><p>With both examples I pulled out the code that modifies the elements into its own function and I set the current element as a variable to make it clear we are only operating with the elements one at a time.</p><h4>Re-implementation of map</h4><p>Now I want to make code that does the same thing as above with a single function call, as follows:</p><pre>const map = (operation, array) =&gt; { <br>    /* TODO: implementation below */<br>}</pre><pre>const squaredNumbers = map(numbers, square);<br>const doubledNumbers = map(numbers, double);</pre><p>Now lets implement a map function:</p><pre>const map = (array, operation, thisArg = undefined) =&gt; {<br>    const newArray = [];<br>    for (let index = 0; index &lt; array.length; index++) {<br>        const element = array[index];<br>        const newElement = operation.call(thisArg, element,<br>                index, array);<br>        newArray.push(newElement);<br>    }<br>    return newArray;<br>}</pre><p>This code should now be completely equivalent to the following:</p><pre>const map = (array, operation, thisArg = undefined) =&gt; {<br>    return array.map(operation, thisArg);<br>}</pre><p>I hope you enjoyed!</p><h4>Working example</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42d5a8df1941b5f37166d810a2230738/href">https://medium.com/media/42d5a8df1941b5f37166d810a2230738/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0768d668872" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>