<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Chris Kevin Sundberg</title>
    <atom:link href="/feed.xml" rel="self" type="application/rss+xml"/>
    <link>https://chriskevin.github.io/</link>
    <description>A website with blog posts and pages</description>
    <pubDate>Fri, 12 May 2023 00:28:57 +0000</pubDate>
    
      <item>
        <title>Functional Programming - Part 2: Semi Groups, Monoids, Functors and Monads</title>
        <link>/2018/11/16/fp-part2-functors-monads.html</link>
        <guid isPermaLink="true">/2018/11/16/fp-part2-functors-monads.html</guid>
        <description>&lt;p&gt;&lt;strong&gt;This is part of a series about developing your skills as a software developer. Last time when we talked about functional programming we only touched &lt;a href=&quot;https://chriskevin.github.io/chrisunleashed/2018/09/28/fp-part1-java-kotlin-js.html&quot;&gt;the basics&lt;/a&gt;. Beyond this point we start heading down the rabbit hole, which in this case goes very deep. All the way down to Category Theory. Now programming and mathematics start to get interrelated. However in this article we will try to stay more close to the practical applications in programming and leave the advanced math for a later time.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Category Theory?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Prof Frisby gives this simplified explanation, “Category theory is an abstract branch of mathematics that can formalize concepts from several different branches such as set theory, type theory, group theory, logic, and more. It primarily deals with objects, morphisms, and transformations, which mirrors programming quite closely.”, &lt;a href=&quot;https://mostly-adequate.gitbooks.io/mostly-adequate-guide/ch05.html#category-theory&quot;&gt;Prof. Frisby Ch.05 - Coding by Composition&lt;/a&gt;. In reality it is a bit more complex than that, but delving deeper right now will not do us much good. However there are some basic math that we need to look at to make more sense of &lt;strong&gt;Semi Groups&lt;/strong&gt;, &lt;strong&gt;Monoids&lt;/strong&gt;, &lt;strong&gt;Functors&lt;/strong&gt; and &lt;strong&gt;Monads&lt;/strong&gt;. The concepts that are of interest to us are &lt;strong&gt;associativity&lt;/strong&gt;, &lt;strong&gt;commutativity&lt;/strong&gt; and &lt;strong&gt;identity&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is associativity?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Associativity can be represented by a simple addition &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(x + y) + z = x + (y + z) = x + y + z&lt;/code&gt;. Where grouping and applying an operator produces the same result as apply them separately in sequence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is commutativity?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Commutativity is the same as associativity but the order does not affect the result. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x + y = y + x&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is identity?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Identity is when you combine a binary operator (e.g. + or ·) with a &lt;a href=&quot;https://en.wikipedia.org/wiki/Identity_element&quot;&gt;neutral element&lt;/a&gt; (e.g. 0 for addition or 1 for multiplication). &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x + 0 = x or x · 1 = x&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is composition?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We talked about composition last time but it is good to do a quick repetition here as well. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(f ∘ g)(x) = g(f(x))&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Semi Group?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now what is this semi group thing? Simply put it is a type that has a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;concat&lt;/code&gt; method and is associative. &lt;a href=&quot;https://egghead.io/lessons/javascript-combining-things-with-semigroups&quot;&gt;Prof. Frisby gives a good detailed explanation of Semi Groups&lt;/a&gt;. While most of us have never though about it we have actually used semi groups several times. Both String and a List are semi groups since both of these can be concatenated and are associative.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Monoid?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A monoid is a semi group which also has a neutral element. So String is not just a semi group but also a monoid since it has &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;&quot;&lt;/code&gt; as a neutral element and the same thing goes for List which has &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[]&lt;/code&gt;. Other monoids are addition and multiplication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the point of knowing about Semi Groups and Monoids?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;They tell us additional details about our computations. If we know something is a semi group then we also know that there is an unsafe (breaking) computation that we also need to handle while on the other hand the monoid can guarantee us a value since it has it’s neutral element (empty value).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Functor?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A much simplified explanation of a functor is a type that is a container of a value. This container type has an interface which is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.map&lt;/code&gt; method which takes a function as an argument. In practice what you do is put a value inside of the container type and then you tell it to transform the containing value by passing a function to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map&lt;/code&gt; method. This will return a new instance of the same container type but with the new value.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;A psuedo code example of a functor.

container = Container.of(123) // Container(123)

container.map(x -&amp;gt; x * 2) // Container(246)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;What are Functors useful for?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The previous example was of the most basic type of functor called the &lt;strong&gt;Identity&lt;/strong&gt; functor. This is related to the identity function and identity property, but all of that is outside of scope for this article. What is more interesting is that there are other types of functors and every functor has an internal context. Take for example the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;List&lt;/code&gt; functor which holds a list of values. When calling &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map&lt;/code&gt; it will internally iterate through the list of values that it holds. This is where it starts to get very powerful, from the outside you just call the same &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map&lt;/code&gt; method with any generic function and it just works. The functor abstracts away all the tedious details.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Another pseudo code example of functors.

list = List.of(1, 2, 3) // List(1, 2, 3)

list.map(x -&amp;gt; x * 2) // List(2, 4, 6)

Externally they look the same, but interally the the functor handles the application of the function differently in relation to the functors internal context.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;What is a Monad?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Just like the explanation of what a functor is, this is also going to be a bit over simplified. But to keep it understandable you can say that a monad is a functor with an additional &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.of&lt;/code&gt; method which is more or less a factory method and a chain/join/bind (depending on programming language) method is a monad. The join function is used for flattening monads when they become nested e.g. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Monad(Monad(value))&lt;/code&gt;. There are also three laws that they need to follow to truly be monads, associativity, right identity and left identity. (I will provide an update later where I explain these laws properly).&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Pseudo example of a monad.

monad = Monad.of(1) // Monad(1)

monad.map(x -&amp;gt; x + 1) // Monad(2)
monad.map(someFunctionReturningAMonad) // Monad(Monad(1))

nestedMonad.chain(someFunctionReturningAMonad) // Monad(1)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;What are Monads useful for?&lt;/strong&gt;
Like functors, monads are very versatile since they all expose the same simple interface through &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map&lt;/code&gt; but internally the can solve different problems. One of these is the &lt;strong&gt;Maybe/Optional&lt;/strong&gt; monad. Internally it handles whether a value exists or not. When calling &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map&lt;/code&gt; it will check if it has a value, if it does it will apply the provided function otherwise ignore it. This allows you to build up a computation of things that should happen given that the value exists. It is first at the end that you will need to consider what to do if the value does not exist. Either you return the Maybe or you handle it at the end of your mapping chain. This produces very clean code and you eliminate the need of indenting and nesting that if/else statements create. A some monads are also sum types. Other notable monads are Either that returns one of two possible values (values can be of different types), &lt;strong&gt;Try&lt;/strong&gt; that handles success or failure cases, &lt;strong&gt;IO/Task/Future&lt;/strong&gt; that handle execution of code that have side effects or are asynchronous.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Sum type?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Maybe monad is usually implemented as a sum type where the sum is a &lt;strong&gt;Just/Some&lt;/strong&gt; and a &lt;strong&gt;Nothing&lt;/strong&gt; type. The Just will apply functions when &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map&lt;/code&gt; is called while Nothing will instead ignore it. It is also the Just that is the only one that actually contains a value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you model your program based on mathematical concepts you reap several benefits. You reduce the amount of code and keep it DRY by reusing powerful abstract data types (semi groups, monoids, monads, etc.). The underlying mathematical laws gives you a solid framework which allows you to reason about your program in a better way. You can prevent and detect problems easier, simplify and optimise by relying on the deterministic properties of said laws.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;General&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/3870088/a-monad-is-just-a-monoid-in-the-category-of-endofunctors-whats-the-proble%E2%85%BF&quot;&gt;A monad is just a monoid in the category of endofunctors, what’s the probleⅿ? - Stack Overflow&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.microsoft.com/en-us/research/publication/tackling-awkward-squad-monadic-inputoutput-concurrency-exceptions-foreign-language-calls-haskell/&quot;&gt;Tackling the awkward squad: monadic input/output, concurrency, exceptions, and foreign-language calls in Haskell - Microsoft Research&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.tomharding.mAe/2017/03/08/fantas-eel-and-specification-2/&quot;&gt;Fantas, Eel, and Specification 2: Type Signatures · Tom Harding&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.johndcook.com/blog/2014/03/03/monads-are-hard-because/&quot;&gt;Monads are hard because … - John D. Cook&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://cdsmith.wordpress.com/2012/04/18/why-do-monads-matter/&quot;&gt;Why Do Monads Matter? - Chris Smith&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Java&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.baeldung.com/vavr-either&quot;&gt;Introduction to Vavr’s Either - Baeldung&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.baeldung.com/vavr-try&quot;&gt;Guide to Try in Vavr - Baeldung&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.baeldung.com/vavr-future&quot;&gt;Introduction to Future in Vavr - Baeldung&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.sitepoint.com/how-optional-breaks-the-monad-laws-and-why-it-matters/&quot;&gt;How Optional Breaks the Monad Laws and Why It Matters - Marcello La Rocca&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.vavr.io/&quot;&gt;Vavr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;JavaScript&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://mostly-adequate.gitbooks.io/mostly-adequate-guide/&quot;&gt;Professor Frisby’s Mostly Adequate Guide to Functional Programming&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://egghead.io/courses/professor-frisby-introduces-composable-functional-javascript&quot;&gt;Professor Frisby Introduces Composable Functional JavaScript&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.humblespark.com/blog/extensible-effects-in-node-part-1&quot;&gt;Extensible Effects in Node.js, Part 1 - HumbleSpark&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://medium.com/@tzehsiang/javascript-functor-applicative-monads-in-pictures-b567c6415221&quot;&gt;Javascript Functor, Applicative, Monads in pictures – Medium&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://medium.com/@luijar/the-observable-disguised-as-an-io-monad-c89042aa8f31&quot;&gt;The Observable disguised as an IO Monad – Luis Atencio – Medium&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/fantasyland/fantasy-land&quot;&gt;Fantasy Land Specification&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://folktale.origamitower.com/docs/v2.0.0/&quot;&gt;Folktale 2.0&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;F#&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;table&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;[Monoids without tears&lt;/td&gt;
          &lt;td&gt;F# for fun and profit](https://fsharpforfunandprofit.com/posts/monoids-without-tears/)&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;table&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;[Railway Oriented Programming&lt;/td&gt;
          &lt;td&gt;F# for fun and profit](https://fsharpforfunandprofit.com/rop/)&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Fri, 16 Nov 2018 00:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>James Bond’s Guide to Functional Programming, Part 1</title>
        <link>/2018/10/15/james-bond-fp-1.html</link>
        <guid isPermaLink="true">/2018/10/15/james-bond-fp-1.html</guid>
        <description>&lt;p&gt;&lt;strong&gt;I had this little anecdote hiding in my notes and thought it deserved some limelight. Most of it was an improvised interpretation that my friend Rickard Lund came up with, when I taught him the basics of functional programming and mentioned professor Haskell Curry (which he thought sounded like a potential Bond villain).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bond:&lt;/strong&gt; “Do you expect me to talk?”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Professor H. Curry:&lt;/strong&gt; “Oh ho ho no Mr. Bond, I expect you to compose… or rather, de-compose.”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bond:&lt;/strong&gt; “You’re insane! You can’t destroy all of the United States!”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Professor H. Curry:&lt;/strong&gt; “Oh no Mr. Bond, you misunderstand. I was talking about the states in your crappy imperative code. Those are what I will destroy.”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bond:&lt;/strong&gt; “It’ll never work! Your plan has too many variables!”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Professor H. Curry:&lt;/strong&gt; “On the contrary Mr. Bond. Variables are exactly what I don’t have.”&lt;/p&gt;
</description>
        <pubDate>Mon, 15 Oct 2018 00:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Code Review</title>
        <link>/2018/10/12/code-review.html</link>
        <guid isPermaLink="true">/2018/10/12/code-review.html</guid>
        <description>&lt;p&gt;&lt;strong&gt;This is part of a series about developing your skills as a software developer. Code reviews are something that any organisation concerned with quality should encourage their developers to do. The following is the result from a discussion with my colleague Simon Forsberg who has for the past year been responsible as Sigma’s Tomorrow Pilot for Clean Code and Code Review. For the curious check out &lt;a href=&quot;http://www.sigmaitc.se/tomorrow-pilot&quot;&gt;Sigma Tomorrow Pilot&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a code review?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A code review is an inspection of the code changes, normally in a commit or pull request. It is usually done one on one but it can sometimes be a good idea to involve more people as well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why should we do code reviewing?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are at least two benefits to code reviews. The first one is to maintain a consistent level of quality, in which you should try and detect issues that automated static code analysis is not very good at finding. A good code review can help keep technical debt at a minimum. The second is knowledge sharing, every finding is a topic for discussion and has the potential for teaching both the person being reviewed and the reviewer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who should do a code review?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Everyone can review code! Both beginners and experienced programmers. While experienced programmers might think more about the overall architecture and how to reduce complexity, everyone can come with feedback regarding for example the readability of the code. Reviewing code is also a good way to develop yourself as a programmer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How should a proper code review be structured?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is a good idea to have a checklist ready before starting a code review, there are a lot of things to keep a look out for and you do not want to miss anything of importance. Preferably the change set should be as small as possible, this is related to the same reasons you want to keep your commits small. Which we discussed in &lt;a href=&quot;https://chriskevin.github.io/chrisunleashed/2018/08/31/mastering-git.html&quot;&gt;Mastering Git&lt;/a&gt;. 
On a related note, Kent Beck wrote two interesting articles on the concepts of Limbo, which is basically taking small change sets to the extreme. See &lt;a href=&quot;https://medium.com/@kentbeck_7670/limbo-scaling-software-collaboration-afd4f00db4b&quot;&gt;Limbo: Scaling Software Collaboration - Kent Beck&lt;/a&gt; and &lt;a href=&quot;https://medium.com/@kentbeck_7670/limbo-on-the-cheap-e4cfae840330&quot;&gt;Limbo on the Cheap - Kent Beck&lt;/a&gt; for a more in depth elaboration.&lt;/p&gt;

&lt;p&gt;Regardless of the size of the change set it is important that the person being reviewed explains the intent. Otherwise the reviewer might focus on just the quality. But good code is not very useful if it fails to do what it was intended for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What should you keep a look out for?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Depending on the reviewers experience you can likely expect something between the following two levels. Since experience affects the quality of the review itself it is yet again a good idea to have a standardized checklist for your organisation so that you can judge when you might need a extra look from a more seasoned developer.&lt;/p&gt;

&lt;p&gt;Basic level&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Is the code easily understandable?&lt;/li&gt;
  &lt;li&gt;Is the code following standards and guidelines?&lt;/li&gt;
  &lt;li&gt;Are classes/functions too complicated?&lt;/li&gt;
  &lt;li&gt;Is the code easy to test and debug?&lt;/li&gt;
  &lt;li&gt;Is there any duplication?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Expert level&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Is the code meeting non functional requirements?
    &lt;ul&gt;
      &lt;li&gt;Does the code have handle scalability?&lt;/li&gt;
      &lt;li&gt;Are there any security concerns?&lt;/li&gt;
      &lt;li&gt;Is the performance acceptable?&lt;/li&gt;
      &lt;li&gt;Is the code easy to maintain?&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Does the code align with the architecture?&lt;/li&gt;
  &lt;li&gt;Is the code following Object Oriented Analysis &amp;amp; Design or Functional principles (depending on paradigm/language)?&lt;/li&gt;
  &lt;li&gt;Are there any unresolved issues found by static code analysis?&lt;/li&gt;
  &lt;li&gt;Is the coverage good enough?&lt;/li&gt;
  &lt;li&gt;Is control flow and exception handling done in a clean way?&lt;/li&gt;
  &lt;li&gt;Is logging done properly?&lt;/li&gt;
  &lt;li&gt;Is there any potential for refactoring?&lt;/li&gt;
  &lt;li&gt;Is the code’s intent clear?&lt;/li&gt;
  &lt;li&gt;Is the commit/pull request of good quality?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For more in depth elaborations on all these review subjects have a look at the following two articles &lt;a href=&quot;https://www.evoketechnologies.com/blog/code-review-checklist-perform-effective-code-reviews/&quot;&gt;Code Review Checklist - To Perform Effective Code Reviews - Surender Reddy Gutha&lt;/a&gt; and &lt;a href=&quot;https://blog.jetbrains.com/upsource/2015/07/23/what-to-look-for-in-a-code-review/&quot;&gt;What to look for in a code review - JetBrains&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What constructive feedback can I give?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can always give constructive feedback. If you cannot find any issues, then be nice and clear about that. If you think the code is good then praise the person that had written it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are there any good tools that are helpful while doing a review?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The most common tool is utilizing Pull Requests. Pull requests are made in such a way that somebody needs to review and approve the code before it can be merged. Be aware that pull requests are for merging branches and may therefore contain many commits. Huge pull requests have a tendency to be overlooked. If you are working trunk based and want to review at the commit level then &lt;a href=&quot;https://www.gerritcodereview.com/&quot;&gt;Gerrit&lt;/a&gt; is an alternate. &lt;a href=&quot;https://github.com/&quot;&gt;GitHub&lt;/a&gt; and &lt;a href=&quot;https://bitbucket.org/&quot;&gt;BitBucket&lt;/a&gt; also have great support for code review. You can review both commits and pull requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Should code reviews only be conducted within an organisation or is it a good strategy to make code available for anyone to review?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You should primarily focus on making code reviews routine within your organisation, mostly because of the risk that code may be sensitive or have licensing that prohibits it from being exposed to a third party. However if you have parts that are non sensitive and are under consideration for becoming open source then putting it on &lt;a href=&quot;https://codereview.stackexchange.com/help/on-topic&quot;&gt;Code Review StackExchange&lt;/a&gt; for example can be a good idea to get additional feedback. Keep in mind that any code published there falls under the Creative Commons Share-alike license. Another alternative is to hire a consultant with expertise in code quality, this can allow you to get an independent view on your overall coding while still adhering to licensing and sensitivity by requiring the consultant to sign a proper contract and with agreements.&lt;/p&gt;
</description>
        <pubDate>Fri, 12 Oct 2018 00:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Functional Programming in Java, Kotlin and JavaScript - Part 1: The Power Of Pure Functions</title>
        <link>/2018/09/28/fp-part1-java-kotlin-js.html</link>
        <guid isPermaLink="true">/2018/09/28/fp-part1-java-kotlin-js.html</guid>
        <description>&lt;p&gt;&lt;strong&gt;This is part of a series about developing your skills as a software developer. Most developers today work with a multi paradigm language. You probably started out with imperative and object oriented programming. Those of us with a background in Java or JavaScript have most likely started transitioning to a declarative style after discovering the benefits of lambdas and higher order functions. However what most don’t realize is that this is the gateway into functional programming.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why should I learn functional programming?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What was the appeal of lambdas and higher order functions? You most likely felt that you could write a lot less code without compromising readability, right? By just learning to utilize functions properly you can reap several benefits:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Simpler code that is easier to reason about.&lt;/li&gt;
  &lt;li&gt;Code that is more reliable.&lt;/li&gt;
  &lt;li&gt;Code that is easier to test.&lt;/li&gt;
  &lt;li&gt;Code that requires less debugging.&lt;/li&gt;
  &lt;li&gt;Code that is more reusable.&lt;/li&gt;
  &lt;li&gt;Code that can leverage powerful optimizations when needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It will also become apparent that most object oriented design patterns can be replaced by just utilizing functions properly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the minimum needed for functional programming?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The definition of functional programming lacks a precise answer. But several developers mention first class functions, function purity and referential transparency as the fundamental parts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are first class functions?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is a language feature that allows functions to be assigned to variables (preferably constants) or used as arguments to other functions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is function purity?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Function purity is when a function is deterministic and free from side effects. In other words the same given input should always produce the same expected output. If a function mutates any of it’s given arguments, returns a random or other generated value or does operations such as I/O then the function is not considered pure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of function purity&lt;/strong&gt;&lt;/p&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/function-purity/function-purity.java&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/function-purity/function-purity.kt&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/function-purity/function-purity.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;&lt;strong&gt;What is referential transparency?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A function is referentially transparent when it can be replaced with it’s value without changing the programs behavior. If the function is not pure then it is called referentially opaque.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is so good about referential transparency?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For this I will quote Wikipedia. “The importance of referential transparency is that it allows the programmer and the compiler to reason about program behavior. This can help in proving correctness, simplifying an algorithm, assisting in modifying code without breaking it, or optimizing code by means of memoization, common subexpression elimination, lazy evaluation, or parallelization.” Also see an elaborate answer on Quora, &lt;a href=&quot;https://www.quora.com/Why-is-referential-transparency-a-good-idea&quot;&gt;Why is referential transparency a good idea? - Quora&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is memoization?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Memoization is a technique to store the result of a computation for a given input. The next time the function is called with the same argument it returns the stored result instead of running the computation again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When is memoization useful?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are running expensive computations on data that is recurring. Another use case could be when doing transformations on elements in a list. Using a memoized function for operations such as map or reduce could potentially improve performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of memoization&lt;/strong&gt;&lt;/p&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/memoization/memoization.java&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/memoization/memoization.kt&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/memoization/memoization.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;&lt;strong&gt;What more can you do with functions?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can also curry, compose and partially apply.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is currying?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Currying is a mathematical transformation of a function with several arguments into a function that takes one argument which returns another function that takes one argument. Once each of these one argument functions have been applied then the last one applied will return the result.
This is the mathematical definition &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f:(X x Y) -&amp;gt; Z&lt;/code&gt; which can be curried to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;h:X -&amp;gt; (Y -&amp;gt; Z)&lt;/code&gt; where &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;h(x)(y) = f(x,y)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Currying sounds very mathematical, what practical use does it have?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Currying on it’s own is not very useful. However it let’s us leverage partial application and function composition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of currying&lt;/strong&gt;&lt;/p&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/curry/curry.java&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/curry/curry.kt&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/curry/curry.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;&lt;strong&gt;What does composition mean in the case of functions?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Function composition is a mathematical way of chaining functions together. The only requirement is that the functions are unary (single argument). What you get is very similar to the pipe operator in bash. You give the first function some input, that function will produce output which is given as input to the next function etc. until we end up at the last function which will give us the final result. What is notable about compose is that it is right to left base (for mathematical reason). There is usually a left to right version available which is called pipe, depending on your preference.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When should I use function composition?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whenever you have two or more functions that you want to combine to create a more complex function. Another example is when you are calling &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map&lt;/code&gt; several times on a collection with different transformations. Instead of calling &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map&lt;/code&gt; three times, which will iterate over the entire collection three times (and also create a new instance). You could instead compose the functions to create a new function and call it once using only one &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of function composition&lt;/strong&gt;&lt;/p&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/function-compose/function-compose.java&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/function-compose/function-compose.kt&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/function-compose/function-compose.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;&lt;strong&gt;What is partial application?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Partial application is when you apply one argument to a function that takes several arguments. This ties back to currying, what you actually do is apply an argument to the outer function which then returns the next unary function storing the applied argument as a closure. When you apply the last function it will evaluate using all the provided arguments and return the result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When is partial application useful?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It let’s you write very generic functions that you can “configure” to make them more specific. This is reusability at it’s finest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of partial application&lt;/strong&gt;&lt;/p&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/partial-application/partial-application.java&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/partial-application/partial-application.kt&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/partial-application/partial-application.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;&lt;strong&gt;What is pointful/pointfree?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Pointful is when you call a function explicitly with it’s arguments. Pointfree is when you only reference a function without explicitly stating any arguments. An example of this is a higher order function that takes a function as an argument and implicitly calls it with the expected arguments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why should I prefer pointfree style?&lt;/strong&gt;
This is more or less a personal preference, but if you lean more towards eliminating unnecessary code then pointfree is the way to go.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of pointful/pointfree&lt;/strong&gt;&lt;/p&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/pointfree/pointfree.java&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/pointfree/pointfree.kt&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;https://gist-it.appspot.com/https://github.com/chriskevin/programming-idioms/blob/master/pointfree/pointfree.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;&lt;strong&gt;Java Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://dzone.com/articles/java-8-automatic-memoization&quot;&gt;Do it in Java 8: Automatic memoization - Pierre-Yves Saumont&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://dzone.com/articles/whats-wrong-java-8-currying-vs&quot;&gt;What’s Wrong with Java 8: Currying vs Closures - Pierre-Yves Saumont&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://dzone.com/articles/whats-wrong-java-8-part-ii&quot;&gt;What’s Wrong in Java 8, Part II: Functions &amp;amp; Primitives - Pierre-Yves Saumont&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://dzone.com/articles/whats-wrong-java-8-part-vi&quot;&gt;What’s wrong in Java 8, part VI: Strictness - Pierre-Yves Saumont&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://dzone.com/articles/how-to-create-an-immutable-class-in-java&quot;&gt;How to Create an Immutable Class in Java - Hussein Terek&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=15X0qFtBqiQ&quot;&gt;Functional Programming with Java 8 by - Venkat Subramaniam&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.vavr.io/&quot;&gt;Vavr&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://immutables.github.io/&quot;&gt;Immutables&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Kotlin Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arrow-kt.io/&quot;&gt;Arrow&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;JavaScript Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://drboolean.gitbooks.io/mostly-adequate-guide-old/content/&quot;&gt;Professor Frisby’s Mostly Adequate Guide to Functional Programming&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Fri, 28 Sep 2018 00:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Design Patterns</title>
        <link>/2018/09/14/design-patterns.html</link>
        <guid isPermaLink="true">/2018/09/14/design-patterns.html</guid>
        <description>&lt;p&gt;&lt;strong&gt;This is part of a series about developing your skills as a software developer. We are all facing the problem of software entropy and would like to reuse code as much as possible. Back in 1995 the book Design Patterns by Erich Gamma, John Vlissides, Ralph Johnson och Richard Helm was published, as a first step towards more reusable code.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are design patterns?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Design patterns are general, reusable solutions to common problems in a given context. &lt;a href=&quot;https://en.wikipedia.org/wiki/Software_design_pattern&quot;&gt;Software Design Patterns - Wikipedia&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do we need design patterns?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It depends on several factors. The context of the specific problem, the capabilities of the programming language and what programming paradigm you follow. Without taking all of these things into consideration a design pattern could potentially introduce more complexity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What types of patterns are there?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Creational, structural and behavioral.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can you apply a design pattern to any language or paradigm?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are using a multi-paradigm language then it is probably possible to implement all or at least most of them. However as implied earlier, whether you need them is up to the features of the programming language and paradigm. Most of the patterns (GOF) where based on imperative and object oriented programming. A purely functional language would solve it using functional idioms that are baked into the language.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is an idiom?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An idiom is also a reoccuring pattern, but usually smaller than a software design pattern. An imperative idiom would be for example a for loop, while functional idioms are higher order functions, currying or function composition, to name a few.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are there any better alternatives than the GOF patterns?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As has been pointed out, most of the design patterns are not useful in a purely functional language. Peter Norvig made a comparison in 1996 where 16 out of the 32 patterns were not necessary by utilising features in dynamic languages (Lisp, Dylan), see &lt;a href=&quot;http://www.norvig.com/design-patterns/&quot;&gt;Design Patterns in Dynamic Languages&lt;/a&gt;. The same stands true in multi-paradigm languages that are functional like, it is usually more practical to use a functional idiom before a design pattern. Venkat Subramaniam shows some examples of this in one of his Java talks &lt;a href=&quot;https://www.youtube.com/watch?v=e4MT_OguDKg&quot;&gt;Design Patterns in the Light of Lambda Expressions&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While the idea of having reusable design patterns is nice, they have not been updated much since they were conceived in 1995. Also they were based heavily on the software industry at the time that was heavily dominated by object oriented programming. Since then a lot of issues have been pointed out when it comes to object oriented programming. Functional programming has meanwhile reemerged and increased in popularity. Where a lot of the new features that are added to the existing leading languages have origins in purely functional languages.&lt;/p&gt;

&lt;p&gt;Based on these observations I think that it would be interesting to follow up with an article about “OOP vs. FP” as well as “Design Patterns vs. Functional Idioms”. Where we compare the design pattern implementation in several popular languages against the functional alternative, if applicative to said languages.&lt;/p&gt;
</description>
        <pubDate>Fri, 14 Sep 2018 00:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Mastering Git</title>
        <link>/2018/08/31/mastering-git.html</link>
        <guid isPermaLink="true">/2018/08/31/mastering-git.html</guid>
        <description>&lt;p&gt;&lt;strong&gt;This is part of a series about developing your skills as a software developer. We use different tools on a daily basis and one of the most frequently used is Git. Usually we just care about its version handling capabilities, however there is so much more value that we could get from the tool by just being a bit more mindful of how we use it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do you attain a clean and useful commit log?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To be able to make good use of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git blame&lt;/code&gt; och &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git log&lt;/code&gt; then it is important to write good commit messages. Chris Beam talks about The seven rules of a great Git commit message, which are still as relevant today as when they were first conceived, &lt;a href=&quot;https://chris.beams.io/posts/git-commit/&quot;&gt;How to Write a Git Commit Message - Chris Beam&lt;/a&gt;. But it is not enough just to write good commit messages, you also need to work with small commits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why should you do several smaller commits?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The purpose of each commit becomes clearer when it focuses on a specific addition/change/delete. Commands such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git log&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git shortlog&lt;/code&gt; become a lot more useful and the same goes for debugging when a bug is accidentally introduced.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Should I mix formatting and style changes together with code changes?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No, you should keep formatting and style changes to a separate commit to make the intent and purpose clear.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How can I use Git for debugging?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git blame&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git bisect&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git grep&lt;/code&gt; depending on how much information you have related to the bug. Read &lt;a href=&quot;https://dzone.com/articles/debugging-with-git&quot;&gt;Debugging with Git - Kristina Pomorisac&lt;/a&gt; for more details.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How can I use the commit history to find useful information?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git log&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git shortlog&lt;/code&gt; are really powerful commands. They have tons of filters to help you extract the information that you want. John Kagga explores the most useful use cases in his article &lt;a href=&quot;https://medium.com/the-andela-way/exploring-the-git-log-command-9117b9ff3c2c&quot;&gt;Exploring the Git log command – The Andela Way - John Kagga&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I pick the best suited branch strategy?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Picking the right branch strategy is mostly up to how your team wants to work. The general advice is to avoid deeply nested branches, also nested branches should have a short lifespan to avoid horrific merges. Atlassian have some good comparisons between strategies &lt;a href=&quot;https://www.atlassian.com/git/tutorials/comparing-workflows&quot;&gt;Comparing Workflows&lt;/a&gt;. Trunk based workflow is also an interesting alternative. Take a look at &lt;a href=&quot;https://stackoverflow.com/questions/42135533/what-are-the-pros-and-cons-of-using-a-trunk-based-vs-feature-based-workflow-in-g&quot;&gt;What Are the Pros and Cons of Using a Trunk-based VS. Feature-based Workflow - Stackoverflow&lt;/a&gt; for a discussion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When should I merge and rebase?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use rebase to get changes from the top of the hierarchy and merge when you want to move your changes back to the top. By rebasing into your feature branch you can avoid unnecessary merge commits. And when your branch is synched with the branch that you want to merge into then a fast-forward merge is done, which does not produce merge commits either. Derek Gourlay explains all of this in more detail &lt;a href=&quot;https://www.derekgourlay.com/blog/git-when-to-merge-vs-when-to-rebase/&quot;&gt;Git - When to Merge vs. When to Rebase - Derek Gourlay&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When is it appropriate to squash my commits?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have WIP commits or small fixes like misspelling etc. then it is a good idea to squash them together to form one commit. But as stated earlier about keeping commits clean it is important that each commit still has a clear intent. If squashing produces a single commit that is still understandable without an elaborate description, then by all means squash. Steven Schwenke elaborates more on this in &lt;a href=&quot;https://dzone.com/articles/git-to-squash-or-not-to-squash&quot;&gt;Git: To Squash or Not to Squash? - Steven Schwenke&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When should I tag my commits?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Tags should be used to mark up special commits, usually to indicate a new version. &lt;a href=&quot;https://semver.org/&quot;&gt;Semantic Versioning&lt;/a&gt; and &lt;a href=&quot;https://github.com/staltz/comver&quot;&gt;Compatible Versioning&lt;/a&gt; are two good schemes to follow. This makes it easy to find a specific point and maintain a changelog with all features up until that point. Version tagging is also better to automate in your CI pipeline by reading from one of your manifests. Whether it being Maven pom.xml, Gradle build.gradle or npm package.json. The good thing with tags is that they are also easy to create/update/delete retroactively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why should I keep my stash and local branches tidy?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the beginning you might not think much about what you put in your stash or the branches that you checkout. However it does not take long until you will be overrun with a long list of discarded stuff. Run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git stash list&lt;/code&gt; to see your entire stash. If you use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git stash pop&lt;/code&gt; a lot then you might have a pretty clean list. However if you use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git stash apply&lt;/code&gt; then stash will not be removed. It is easy to clean your stash with either &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git stash clear&lt;/code&gt; if you want to get rid of everything or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git stash drop&lt;/code&gt; for a specific stash.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the most useful Git Hooks?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You should run your local testing on a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pre-commit&lt;/code&gt; hook. I know some people would argue that this is annoying and want to do it on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pre-push&lt;/code&gt; only. However there are some good points to why you should do it for every commit. The first one is when you are working trunk based, then waiting until push is too late. In this case each and every commit should be stable and production ready so that your team mates can review and ok it. The second point is that if you get code style and test errors at push then you need to create another commit to add those. Then you should squash that commit together with the one(s) you were trying to push. So basically you just added more manual steps when you could have had a closer feedback loop and fixed the problems early.&lt;/p&gt;

&lt;p&gt;It is also nice to add some visual feedback to the current state after a commit. I usually add &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git status&lt;/code&gt; to my &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;post-commit&lt;/code&gt; hook. I also got a tip from &lt;a href=&quot;https://codereview.stackexchange.com/users/31562/simon-forsberg?tab=profile&quot;&gt;Simon Forsberg&lt;/a&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git log --branches --decorate --graph --oneline --all&lt;/code&gt;. This visualizes a graph of commits from all branches together with commit hash and a short log message.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you start looking into Git in depth, then you realize that there is a lot more to it than expected. I think that I have managed to highlight and answer many useful questions. In all likelihood I will get back to this article as soon as I have learned more and update it with some more good questions and answers. In the meantime you should take a look at the misc resources that I discovered while researching. There is a good take away from all of them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Miscellaneous tips&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The most comprehensive resources can be found at &lt;a href=&quot;https://github.com/git-tips/tips&quot;&gt;https://github.com/git-tips/tips&lt;/a&gt; and &lt;a href=&quot;http://ohshitgit.com/&quot;&gt;Oh shit, git!&lt;/a&gt; (perfect for those situations when you know you messed up). If you want in depth knowledge then the official &lt;a href=&quot;https://git-scm.com/book/en/v2&quot;&gt;Git Book&lt;/a&gt; is still your best read.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://8thlight.com/blog/kevin-liddle/2012/09/27/mind-your-git-manners.html&quot;&gt;Mind Your Git Manners - Kevin Liddle&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://help.github.com/articles/github-community-guidelines/&quot;&gt;GitHub Community Guidelines&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://fossbytes.com/git-stats-git-visualization/&quot;&gt;Git Stats — Cool Visualisations For Local Git Statistics With Contribution Calendars&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://cdemyanovich.github.io/git_out_of_trouble/&quot;&gt;Git Out of Trouble&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://sethrobertson.github.io/GitBestPractices/&quot;&gt;Git Best Practices - Seth Robertson&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://gitimmersion.com/&quot;&gt;Git Immersion&lt;/a&gt; - Great step by step training for different commands and scenarios&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.gerritcodereview.com/&quot;&gt;Gerrit Code Review&lt;/a&gt; - Code review tool.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://gvfs.io/&quot;&gt;GVFS&lt;/a&gt; - Microsoft took Git one step further.&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Fri, 31 Aug 2018 00:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Skills Development</title>
        <link>/2018/08/27/skills-development.html</link>
        <guid isPermaLink="true">/2018/08/27/skills-development.html</guid>
        <description>&lt;p&gt;&lt;strong&gt;This is the first part in a series about developing your skills as a software developer. To learn efficiently, you first need to learn how to learn, which is easy to overlook. Because of this I want to share the routines, habits and strategies that have helped me with my personal development.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why should I spend time and energy on developing my skills?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Being a software developer demands that you are used to dealing with changes. You need to be up to date with the current de facto standards, while also looking beyond the horizon to avoid being stuck on a sinking ship. Be mindful however that the invested time in learning something new should always benefit yourself by adding personal value. It should feel fun and engaging and that it will enable you more freedom through more options. Having both breadth and detailed knowledge enables you to shape the world instead of following the crowd. You will also come to the realization that you have the ability to give back, that you can teach others what you know and at the same time strengthen your own competence further. In time you will be more effective by working smarter and can instead focus on the challenges that interest you.&lt;/p&gt;

&lt;p&gt;Feeling motivated? Whatever the case I will proceed to discuss some strategies on learning smarter and more efficiently. Some of them will feel obvious, however repetition is also a means of learning. Should you want to commit all the way then I suggest that you read my article &lt;a href=&quot;/chrisunleashed/2018/08/27/daily-routine.html&quot;&gt;My Ideal Daily Routine&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good habits for various situations.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Hang out with people more experienced and knowledgeable than yourself. It will make you aware of what you do not know, while simultaneously letting you take part of their knowledge and experience. Business man Warren Buffett has said “It’s better to hang out with people better than you. Pick out associates whose behavior is better than yours and you’ll drift in that direction.”&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Spend 1 to 3 hours a day on studying. If you are having a hard time allocating time for studying, then try to plan an entire week from time to time where you push yourself a little extra. If you are listening to or watching recordings, try doing it in 1.5x or 2x speed. It is usually not a issue to perceive the important parts.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Avoid getting stuck to ideologies, it limits your thinking and clouds your judgement. Instead be open to the thought that everything you know may be wrong and could potentially be replaced with something better. Strive to become aware of what you do not know and spend time to prove yourself wrong. Not only will this let you see the bigger picture but also give you an advantage in an argument. Also be honest to others about your shortcomings and act responsibly by learning to answer that question until next time.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Have constructive discussions, to make it meaningful it is paramount to understand the respondents argument. Take your time to listen thoroughly and analyze before coming up with a counter argument, avoid getting stuck in bike shedding discussions.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Teach others what you know. While reading is useful, it just can’t beat the impact that teaching has on learning. It helps you in identifying parts that you still have not fully grasped and is necessary to revisit. Be active in lectures and workshops, you will learn more that way than just listening and taking notes.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Challenge yourself and your surroundings. Or as John F. Kennedy put it “We choose to go to the Moon in this decade and do other things, not because they are easy, but because they are hard; because that goal will serve to organize and measure the best of our energies and skills, because that challenge is one that we are willing to accept, one we are unwilling to postpone, and one we intend to win, and the others, too.”&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Write down what you know that you do not know, or rather write down all the questions you have regarding a topic. Then rate them and prioritize based on which questions are of great importance with a high return on personal value. The result will become your personal well informed study plan.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Seven strategies for software developers&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Regard everything as tools, even code is just a tool and should be replaceable with better tools.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;RTFM (Read The Fucking Manual) as some might say. Skim through documentation and API’s, you will always learn something new and sometimes be positively surprised. Use &lt;a href=&quot;https://devdocs.io/&quot;&gt;DevDocs&lt;/a&gt; to find documentation on most libraries.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Use a REPL if there is one available for the programming language that you are learning. It is a quick way of trying out functions or a certain idiom to understand how it works.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Do coding exercises, also known as “kata”. &lt;a href=&quot;https://www.codewars.com/&quot;&gt;codewars&lt;/a&gt; has exercises with varying difficulty and support for many popular languages.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Use &lt;a href=&quot;https://github.com/&quot;&gt;GitHub&lt;/a&gt; frequently, if you are going to try out a new technology then create a repository. Also do everything as professionally as you would for a real customer. The additional effort will pay off later when you realise that you will need to do it in a real case scenario. When you already have a repository you can expand it when you want to learn more technologies or just improving and refactoring it will also improve your skills. Having a public repository is also a good way to show that you have experience using technologies that you might not have the opportunity to use at work.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Become an active contributor to open source projects, preferably the ones that you use frequently. This will give you insight to how the tools work and also allow you to collaborate with developers from the around the globe.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Make use of &lt;a href=&quot;https://stackoverflow.com/&quot;&gt;Stack Overflow&lt;/a&gt; or &lt;a href=&quot;https://codereview.stackexchange.com/&quot;&gt;Code Review&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Miscellanous Tips&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I can recommend a few YouTube channels, &lt;a href=&quot;https://www.youtube.com/channel/UCtxCXg-UvSnTKPOzLH4wJaQ&quot;&gt;Coding Tech&lt;/a&gt;, &lt;a href=&quot;https://www.youtube.com/channel/UC_QIfHvN9auy2CoOdSfMWDw&quot;&gt;Strange Loop&lt;/a&gt; and &lt;a href=&quot;https://www.youtube.com/user/Computerphile&quot;&gt;Computerphile&lt;/a&gt;. Together they cover a wide range of tech and programming related topics.&lt;/p&gt;

&lt;p&gt;GitHub has a collections page on open source projects &lt;a href=&quot;https://github.com/collections&quot;&gt;https://github.com/collections.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So with that, I hope that I have helped you open your mind and set you on a smarter course in your personal journey in becoming a better software developer.&lt;/p&gt;
</description>
        <pubDate>Mon, 27 Aug 2018 00:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>My Ideal Daily Routine</title>
        <link>/2018/08/27/daily-routine.html</link>
        <guid isPermaLink="true">/2018/08/27/daily-routine.html</guid>
        <description>&lt;p&gt;&lt;strong&gt;I believe that in order to perform at your best, it is necessary to have well established daily routines. The following is my ideal daily routine and something that I am always aiming for, although I do admit that committing to a routine requires hard work and discipline.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Sleep has a huge impact on your brain function and if you want to remember as much as possible each day. Then it is invaluable to get at least 7 hours of sleep each night.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Make sure to start your day early, preferably around 04.30 - 05.00. Initially it might feel challening but will become more natural with time.  The benefit however is that you can complete all of your critical tasks before lunchtime, where your energy levels usually drop.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Prefer a cold bath/shower over your morning coffee. Combined with the right breathing technique you will become more alert, the immune system will be triggered and you will become stronger mentally and physically. Check out &lt;a href=&quot;https://www.youtube.com/watch?v=mxCGDFlH1_k&quot;&gt;Wim Hof “The Iceman”&lt;/a&gt; for more inspiration.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;If it’s possible for you then stick to a whole food plant based diet. It’s the easiest way to keep your body healthy and at peak condition. If you want to optimize your diet further then &lt;a href=&quot;https://nutritionfacts.org&quot;&gt;nutritionfacts.org&lt;/a&gt; has lot’s of scientific unbiased information.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Also make sure to give yourself time for at least 30 minutes of physical activity.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;When you need to think or be creative it is more efficient to do it while taking a walk, this activates you mind. If you are having a meeting it is also better to do this during a walk.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;At the end of the day you should reflect and analyse what you have learned during the day. It is good to write down notes to help your long term memory to remember what was important.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Plan the following day and select two to six of your most valuable tasks that you should complete. Doing so will allow you to start the following day focused on what is important.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Avoid spending your last waking hour in front of a screen, prioritize taking a walk or read a book instead.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So this is what I do my best to follow each day. As a side note if you have a strategy that you believe in and choose to compromise it because of how hard it is to follow in the beginning or because of other things that you think are more urgent. Then remember that you are hurting yourself in the long term by not investing in what will make you smarter and more efficient and open up more time for important tasks.&lt;/p&gt;
</description>
        <pubDate>Mon, 27 Aug 2018 00:00:00 +0000</pubDate>
      </item>
    
      <item>
        <title>Introducing Chris Unleashed</title>
        <link>/2018/08/26/intro.html</link>
        <guid isPermaLink="true">/2018/08/26/intro.html</guid>
        <description>&lt;p&gt;&lt;strong&gt;This is not my first attempt at blogging and I think my previous efforts died out because of a lack of purpose and value. After a time of pondering I have found my mission and this will be my way of sharing the journey with you.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For a long time I thought that imperative and object oriented programming was the best path for a software professional. But after stumbling into functional programming I began to change my mind as I learned more and more of the functional idioms. Now in retrospect I know that all the good features that are being added to existing object oriented programming languages have their origin in functional ones.&lt;/p&gt;

&lt;p&gt;Then I heard about Bret Victor in James Somers article &lt;a href=&quot;https://www.theatlantic.com/technology/archive/2017/09/saving-the-world-from-code/540393/&quot;&gt;The Coming Software Apocalypse&lt;/a&gt; and watched his talks &lt;a href=&quot;https://www.youtube.com/watch?v=PUv66718DII&quot;&gt;Inventing on Principle&lt;/a&gt;, &lt;a href=&quot;https://www.youtube.com/watch?v=8pTEmbeENF4&amp;amp;t=923s&quot;&gt;The Future of Programming&lt;/a&gt; and &lt;a href=&quot;https://www.youtube.com/watch?v=ZfytHvgHybA&quot;&gt;Stop Drawing Dead Fish&lt;/a&gt;. I also came in contact with interesting languages such as &lt;a href=&quot;http://play.witheve.com/&quot;&gt;Eve&lt;/a&gt;, &lt;a href=&quot;https://www.luna-lang.org/&quot;&gt;Luna&lt;/a&gt; the visual programming language and the knowledge based programming language &lt;a href=&quot;https://www.wolfram.com/language/&quot;&gt;Wolfram Language&lt;/a&gt;. Not to mention the vast amount of programming paradigms that exist beyond the ones that most of us know of.&lt;/p&gt;

&lt;p&gt;There is no denying that there is a huge world outside of our little bubble that is todays software industry and I cannot shake off the feeling that we might have strayed away from the path that we should be on.&lt;/p&gt;

&lt;p&gt;So basically that is what I want to do with Chris Unleashed. To dig deeper into the tried and proved paths, but also examine and praise those that diverged, the ideas that were too obscure and way ahead of their time.&lt;/p&gt;
</description>
        <pubDate>Sun, 26 Aug 2018 00:00:00 +0000</pubDate>
      </item>
    
  </channel>
</rss>
