<?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 Zsolt Nagy on Medium]]></title>
        <description><![CDATA[Stories by Zsolt Nagy on Medium]]></description>
        <link>https://medium.com/@Z501t?source=rss-6e7ffb89db6b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Bz6aBIZQaMqNUkIArl5oGg.png</url>
            <title>Stories by Zsolt Nagy on Medium</title>
            <link>https://medium.com/@Z501t?source=rss-6e7ffb89db6b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 21:49:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Z501t/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[Effective Learning for Software Developers]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@Z501t/effective-learning-for-software-developers-be1738aa2c61?source=rss-6e7ffb89db6b------2"><img src="https://cdn-images-1.medium.com/max/820/1*1vIDggYOcrsIARCrzb0GzQ.jpeg" width="820"></a></p><p class="medium-feed-snippet">Software developer degrees or bootcamps don&#x2019;t guarantee that you are set for life.</p><p class="medium-feed-link"><a href="https://medium.com/@Z501t/effective-learning-for-software-developers-be1738aa2c61?source=rss-6e7ffb89db6b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@Z501t/effective-learning-for-software-developers-be1738aa2c61?source=rss-6e7ffb89db6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/be1738aa2c61</guid>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Zsolt Nagy]]></dc:creator>
            <pubDate>Wed, 15 Aug 2018 22:45:13 GMT</pubDate>
            <atom:updated>2018-09-13T23:54:07.193Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Introduction to ImmutableJs]]></title>
            <link>https://medium.com/@Z501t/introduction-to-immutablejs-6b4b0fc30d5b?source=rss-6e7ffb89db6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b4b0fc30d5b</guid>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[immutablejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[immutable]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Zsolt Nagy]]></dc:creator>
            <pubDate>Sun, 28 Jan 2018 18:00:21 GMT</pubDate>
            <atom:updated>2018-01-28T18:00:21.131Z</atom:updated>
            <content:encoded><![CDATA[<p>This story was originally published on <a href="http://www.zsoltnagy.eu/">zsoltnagy.eu</a> (<a href="http://www.zsoltnagy.eu/introduction-to-immutable-js/">link</a>) on September 6th, 2015.</p><p>Most developers emphasize immutability when dealing with functional programming. Code written in functional style is testable, because the functions operate on data treated as immutable. In practice though, I see this principle violated from time to time. I will present one way to force yourself to eliminate side effects in your code: using <a href="https://github.com/facebook/immutable-js">immutable.js</a>.</p><h3>Immutable.js to the rescue</h3><p>You can use <a href="https://github.com/facebook/immutable-js">Immutable.js</a> in your code by installing it as an npm module or loading the source file <a href="https://github.com/facebook/immutable-js/blob/master/dist/immutable.min.js">immutable.min.js</a>.</p><p>Let’s explore an immutable map as our first example. A map is basically an object consisting of key-value pairs.</p><pre>var person = Immutable.Map({<br>    name: &#39;John&#39;,<br>    birth: 594687600000,<br>    phone: &#39;12345678&#39;<br>});</pre><pre>var changePhone = function( person, newPhone ) {<br>    return person.set( &#39;phone&#39;, newPhone );<br>};</pre><pre>var person2 = changePhone( person, &#39;87654321&#39; );<br>console.log( person2 == person, person2 === person );<br>// false false</pre><pre>console.log( person.get( &#39;phone&#39; ), person2.get( &#39;phone&#39; ) );<br>// 12345678 87654321</pre><pre>console.log( person.phone, person2.phone );<br>// underfined undefined</pre><p>First, a person is created with the name, birth and phone attributes. The changePhone function returns a new immutable map. When the changePhone function is executed, person2 is created as a return value, and person2 is strictly different than person. The phone numbers of each person map can be accessed via the get method. The properties of the maps are hidden behind the get/set interface, therefore they cannot be directly accessed or modified.</p><pre>var person3 = changePhone( person, &#39;12345678&#39; );<br>console.log( person3 == person, person3 === person );<br>// true true</pre><pre>var person4 = changePhone( person, &#39;87654321&#39; );<br>var person5 = changePhone( person4, &#39;12345678&#39; );<br>console.log( person5 == person, person5 === person );<br>// false false</pre><p>The immutable abstraction is intelligent enough to detect when an attribute is changed to the same value as before. In this case, both == and === comparisons return true, as the return of the o.set method is o. In all other cases, a real change takes place, and a new object reference is returned. This is why person5 is not equal to person even though they have the exact same keys and values. Mind you, in many real-life scenarios, person is supposed to be a thrown-away value after a modification takes place, therefore a comparison between person and person5 is rarely useful.</p><p>If we wanted to check the equality of attribute key-value pairs of person and person5, we can use the equals method of the immutable map interface:</p><pre>console.log( person5.equals( person ) );<br>// true</pre><p>Immutable data structures are amazing, but we don’t always need them. For instance, we normally send JSON payloads to the server instead of an immutable.js data structure. Therefore, there is a need to convert the immutable.js data structure into a JavaScript object or a JSON string.</p><pre>person5.toObject()<br>// Object {name: &quot;John&quot;, birth: 594687600000, phone: &quot;12345678&quot;}</pre><pre>person5.toJSON()<br>// Object {name: &quot;John&quot;, birth: 594687600000, phone: &quot;12345678&quot;}</pre><pre>JSON.stringify( person5 )<br>// &#39;{&quot;name&quot;:&quot;John&quot;,&quot;birth&quot;:594687600000,&quot;phone&quot;:&quot;12345678&quot;}&#39;</pre><p>Both the toObject and the toJSON methods return a JavaScript object representation of the immutable map. As a consequence of the return value of toJSON, JSON.stringify can directly be used on immutable data structures to create a JSON string for serialization.</p><p>Assuming proper usage of immutable data structures, maintainability of our application is expected to improve. Using immutable data structures indeed results in side-effect free code.</p><h3>Immutable.js data structures</h3><p>Immutable.js has the following data structures:</p><ul><li>List,</li><li>Stack,</li><li>Map,</li><li>OrderedMap,</li><li>Set,</li><li>OrderedSet,</li><li>Record,</li><li>lazy Seq.</li></ul><p>Let’s briefly explore all of these data structures.</p><p><strong>List</strong>: a List is an immutable representation of a JavaScript array. The usual array operations are available with the twist that their return value is a new immutable object whenever the content of the original object is changed.</p><pre>var qwerty = Immutable.List([&#39;q&#39;,&#39;w&#39;,&#39;e&#39;,&#39;r&#39;,&#39;t&#39;,&#39;y&#39;]);</pre><pre>qwerty.size<br>// 6</pre><pre>var qwertyu = qwerty.push( &#39;u&#39; );<br>// Object {size: 7, _origin: 0, _capacity: 7, _level: 5, _root: null…}</pre><pre>var qwert = qwertyu.pop().pop();<br>// Object {size: 5, _origin: 0, _capacity: 5, _level: 5, _root: null…}</pre><pre>var wertArray = qwert.shift().toJSON();<br>// [&quot;w&quot;, &quot;e&quot;, &quot;r&quot;, &quot;t&quot;]</pre><pre>var qwertyuiArray = qwert.concat( &#39;y&#39;, &#39;u&#39;, &#39;i&#39; ).toJS();<br>// [&quot;q&quot;, &quot;w&quot;, &quot;e&quot;, &quot;r&quot;, &quot;t&quot;, &quot;y&quot;, &quot;u&quot;, &quot;i&quot;]</pre><p><strong>Stack</strong>: first in, last out data structure, defined with the usual operations. The serialized equivalent of a stack is an array, where the element with index 0 corresponds to the element to be popped. All elements of the stack can be accessed without popping via the get method. However, our only options for modifying the stack are to push and pop.</p><pre>var filo = new Immutable.Stack();<br>// Object {size: 0, _head: undefined, __ownerID: undefined, __hash: undefined, __altered: false}</pre><pre>var twoStoreyStack = filo.push( &#39;2nd floor&#39;, &#39;1st floor&#39;, &#39;ground floor&#39; );</pre><pre>twoStoreyStack.size<br>// 3</pre><pre>twoStoreyStack.get()<br>// &quot;2nd floor&quot;</pre><pre>twoStoreyStack.get(1)<br>// &quot;1st floor&quot;</pre><pre>twoStoreyStack.get(2)<br>// &quot;ground floor&quot;</pre><pre>var oneStoreyStack = twoStoreyStack.pop();<br>var oneStoreyJSON = JSON.Stringify( oneStoreyStack );<br>// &#39;[&quot;1st floor&quot;,&quot;ground floor&quot;]&#39;</pre><p><strong>Map</strong>: we have already seen the Map data structure in action. It is the immutable.js representation of a JavaScript object.</p><p><strong>OrderedMap</strong>: an ordered map is a mixture of objects and arrays. It can be treated as an object with the feature that its keys are ordered based on the order in which they were added to the map. Modifying the value belonging to an already added key does not result in a change of the order of keys.</p><p>The order of the keys can be re-defined using the sort or sortBy methods, returning a new immutable ordered map.</p><p>The dangerous part about using an ordered map is that its serialized form is a simple object. Given that some languages such as PHP also treat their objects as ordered maps, in theory, communicating via order maps could work. In practice, I don’t recommend this form of communication for the sake of clarity.</p><pre>var basket = Immutable.OrderedMap()<br>    .set( &#39;Captain Immutable 1&#39;, 495 )<br>    .set( &#39;The Immutable Bat Rises 1&#39;, 995 );</pre><pre>console.log( basket.first(), basket.last() );<br>// 495 995</pre><pre>JSON.stringify( basket );<br>// &#39;{&quot;Captain Immutable 1&quot;:495,&quot;The Immutable Bat Rises 1&quot;:995}&#39;</pre><pre>var basket2 = basket.set( &#39;Captain Immutable 1&#39;, 695 );<br>JSON.stringify( basket2 );<br>// &#39;{&quot;Captain Immutable 1&quot;:695,&quot;The Immutable Bat Rises 1&quot;:995}&#39;</pre><pre>var basket3 = basket2.sortBy( function( value, key ) {<br>    return -value;<br>} );</pre><pre>JSON.stringify( basket3 );<br>// &#39;{&quot;The Immutable Bat Rises 1&quot;:995,&quot;Captain Immutable 1&quot;:695}&#39;</pre><p><strong>Set</strong>: A Set contains an array of unique elements. All usual operations are available. In theory, the order of elements in the set should not matter.</p><pre>var s1 = Immutable.Set( [2, 1] );<br>var s2 = Immutable.Set( [2, 3, 3] );<br>var s3 = Immutable.Set( [1, 1, 1] );</pre><pre>console.log( s1.count(), s2.size, s3.count() );<br>// 2 2 1</pre><pre>console.log( s1.toJS(), s2.toArray(), s3.toJSON() );<br>// [2, 1] [2, 3] [1]</pre><pre>var s1S2IntersectArray = s1.intersect( s2 ).toJSON();<br>// [2]</pre><p><strong>OrderedSet</strong>: An OrderedSet is a Set with elements ordered according to the time of addition. When the order of elements matter, use an ordered set.</p><pre>var s1 = Immutable.OrderedSet( [2, 1] );<br>var s2 = Immutable.OrderedSet( [2, 3, 3] );<br>var s3 = Immutable.OrderedSet( [1, 1, 1] );</pre><pre>var s1S2S3UnionArray = s1.union( s2, s3 ).toJSON();<br>// [2, 1, 3]</pre><pre>var s3S2S1UnionArray = s3.union( s2, s1 ).toJSON();<br>// [1, 2, 3]</pre><p><strong>Record</strong>: a record is like a JavaScript class with default values for some keys. When instantiating a record, the values for the keys defined in the record can be given during instantiation. In absence of a value, the default value of the record is used.</p><pre>var Canvas = Immutable.Record( { width: 1024, height: 768 } );</pre><pre>console.log( &#39;constructor &#39;+ typeof Canvas );<br>// constructor function</pre><pre>var myCanvas = new Canvas();<br>myCanvas.toJSON()<br>// Object {width: 1024, height: 768}</pre><pre>myCanvas.width<br>// 1024</pre><pre>var myResizedCanvas = new Canvas( {width: 400, height: 300} );<br>myResizedCanvas.width<br>// 400</pre><p><strong>Seq</strong>: sequences are lazy finite or infinite data structures. Elements of a Seq are only evaluated on demand. Depending on the type of sequence, we can talk about a KeyedSeq, an IndexedSeq or a SetSeq. Finite and infinite sequences can be defined using</p><ul><li>Immutable.Range(),</li><li>Immutable.Repeat(),</li><li>a mutation of a seq using a functional utility such as map, filter.</li></ul><p>Finite Seqs can also be defined using enumeration.</p><pre>var oneToInfinitySeq = Immutable.Range( 1 );<br>var isEven = function( num ) { return num % 2 === 0; }<br>var evenPositiveSeq = oneToInfinitySeq.filter( isEven );<br>var firstTenPositivesSeq = evenPositiveSeq.take(10);<br>firstTenPositivesSeq.toJSON();<br>// [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]</pre><pre>var firstTenElements = Immutable.Repeat( /* undefined */ )<br>    .map( Math.random )<br>    .take( 10 )<br>    .toJSON();<br>// generates an array of ten random numbers</pre><p>One of the benefits of lazy evaluation is that infinite sequences can be defined. Another one is performance. As a riddle, try to determine the console messages emitted by the following code:</p><pre>var toUpper = function( item ) {<br>    var upperItem = item.toUpperCase();<br>    console.log( item + &#39;has been converted to &#39;+ upperItem );<br>    return upperItem;<br>}</pre><pre>var seasons = Immutable.Seq( [&#39;spring&#39;,&#39;summer&#39;,&#39;fall&#39;,&#39;winter&#39;] )<br>    .map( toUpper );</pre><pre>console.log( ‘Item at index 1: ‘, seasons.get( 1 ) );<br>console.log( ‘Item at index 0: ‘, seasons.get( 0 ) );<br>console.log( ‘Seasons in an array: ‘, seasons.toJS() );</pre><p>The results may be surprising. Given that evaluation is lazy and we are dealing with a finite data structure, elements of the seasonsSeq can be accessed directly. Therefore, the upper case version of each element is calculated on demand. When the toJS method of seasons is called, all four elements are calculated from scratch. By default, there is no memorization in lazy sequences. Therefore the result is:</p><pre>summer has been converted to SUMMER</pre><pre>Item at index 1: SUMMER</pre><pre>spring has been converted to SPRING</pre><pre>Item at index 0: SPRING</pre><pre>spring has been converted to SPRING</pre><pre>summer has been converted to SUMMER</pre><pre>fall has been converted to FALL</pre><pre>winter has been converted to WINTER</pre><pre>Seasons in an array: [&quot;SPRING&quot;, &quot;SUMMER&quot;, &quot;FALL&quot;, &quot;WINTER&quot;]</pre><p>The above observations hold for infinite data structures as well. Elements are only calculated on demand, without memorization.</p><h3>Summary</h3><p>Immutable.js is a nice library providing immutable data structures. It corrects the flaws of underscore.js, namely that operations of different data structures were forced on JavaScript arrays and objects, mixing the concept of data types, and losing immutability. Even though lodash.js attempted to correct some of these flaws, the compatibility with underscore.js still results in a counter-intuitive structure. Although lazy.js came with lazy loading, it was especially known for being a lazy version of underscore.</p><p>The name immutable.js very well reflects that we need to deal with immutable data structures as a necessary condition for exercising pure functional programming. The emphasis on using correct data structures results in increased maintainability of your code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b4b0fc30d5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Switching to ES6 Template Literals — The Death of JavaScript Templating Engines]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@Z501t/switching-to-es6-template-literals-the-death-of-javascript-templating-engines-8328bb1edaa6?source=rss-6e7ffb89db6b------2"><img src="https://cdn-images-1.medium.com/max/1280/1*eWOVw5PqUUE6vSiQ8Z0Vsw.jpeg" width="1280"></a></p><p class="medium-feed-snippet">It is time to have a look at string manipulation and template literals.</p><p class="medium-feed-link"><a href="https://medium.com/@Z501t/switching-to-es6-template-literals-the-death-of-javascript-templating-engines-8328bb1edaa6?source=rss-6e7ffb89db6b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@Z501t/switching-to-es6-template-literals-the-death-of-javascript-templating-engines-8328bb1edaa6?source=rss-6e7ffb89db6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8328bb1edaa6</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[template]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[es2015]]></category>
            <dc:creator><![CDATA[Zsolt Nagy]]></dc:creator>
            <pubDate>Wed, 03 Jan 2018 20:13:10 GMT</pubDate>
            <atom:updated>2018-01-03T20:53:20.347Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[ES6 Proxies in Practice]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@Z501t/es6-proxies-in-practice-64c5ba5eb0d7?source=rss-6e7ffb89db6b------2"><img src="https://cdn-images-1.medium.com/max/600/1*OtuuNVuIqbcYEgQIX-ZBNA.jpeg" width="600"></a></p><p class="medium-feed-snippet">This article was originally posted on zsoltnagy.eu along with many other JavaScript topics, exercises, and solutions.</p><p class="medium-feed-link"><a href="https://medium.com/@Z501t/es6-proxies-in-practice-64c5ba5eb0d7?source=rss-6e7ffb89db6b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@Z501t/es6-proxies-in-practice-64c5ba5eb0d7?source=rss-6e7ffb89db6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/64c5ba5eb0d7</guid>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[proxy]]></category>
            <dc:creator><![CDATA[Zsolt Nagy]]></dc:creator>
            <pubDate>Wed, 15 Feb 2017 01:48:54 GMT</pubDate>
            <atom:updated>2018-01-06T17:59:41.230Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Four essential soft skills for Career Advancement]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@Z501t/four-essential-soft-skills-for-career-advancement-98104fd8f3c0?source=rss-6e7ffb89db6b------2"><img src="https://cdn-images-1.medium.com/max/1200/1*6Tad1dnn1UY4-fhUHUIdgg.jpeg" width="1200"></a></p><p class="medium-feed-snippet">In his book, What Got You Here, Won&#x2019;t Get You There, Marshall Goldsmith pointed out that beyond a certain skill level, everyone is good&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@Z501t/four-essential-soft-skills-for-career-advancement-98104fd8f3c0?source=rss-6e7ffb89db6b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@Z501t/four-essential-soft-skills-for-career-advancement-98104fd8f3c0?source=rss-6e7ffb89db6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/98104fd8f3c0</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[job-search]]></category>
            <category><![CDATA[soft-skills]]></category>
            <category><![CDATA[job-hunting]]></category>
            <category><![CDATA[career-advice]]></category>
            <dc:creator><![CDATA[Zsolt Nagy]]></dc:creator>
            <pubDate>Sun, 29 Jan 2017 00:00:37 GMT</pubDate>
            <atom:updated>2017-12-31T13:06:34.715Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Understanding the JavaScript Console API — 7 Tips on Smarter Debugging]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@Z501t/understanding-the-javascript-console-api-7-tips-on-smarter-debugging-3305f8bc24c5?source=rss-6e7ffb89db6b------2"><img src="https://cdn-images-1.medium.com/max/820/1*x9bJmtc704NHSUAzB3h5MA.jpeg" width="820"></a></p><p class="medium-feed-snippet">Many JavaScript developers only use the console.log statement for the purpose of finding out more about how their application works. In&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@Z501t/understanding-the-javascript-console-api-7-tips-on-smarter-debugging-3305f8bc24c5?source=rss-6e7ffb89db6b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@Z501t/understanding-the-javascript-console-api-7-tips-on-smarter-debugging-3305f8bc24c5?source=rss-6e7ffb89db6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3305f8bc24c5</guid>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[browsers]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Zsolt Nagy]]></dc:creator>
            <pubDate>Mon, 23 Jan 2017 21:12:28 GMT</pubDate>
            <atom:updated>2017-12-31T10:20:47.454Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Use ESLint Like a Pro with ES6 and React]]></title>
            <link>https://medium.com/@Z501t/use-eslint-like-a-pro-with-es6-and-react-a5dab3c04e49?source=rss-6e7ffb89db6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5dab3c04e49</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[eslint]]></category>
            <dc:creator><![CDATA[Zsolt Nagy]]></dc:creator>
            <pubDate>Thu, 05 Jan 2017 01:05:09 GMT</pubDate>
            <atom:updated>2018-01-14T19:14:29.338Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8wgzbbihRHKsO-D2Ra8bxQ.jpeg" /></figure><p>In this article, we will extend our <a href="http://www.zsoltnagy.eu/step-by-step-environment-setup-of-the-react-developer-no-legacy-2016-standards/">application setup</a> with linting.</p><p>If you have not read my article on <a href="http://www.zsoltnagy.eu/step-by-step-environment-setup-of-the-react-developer-no-legacy-2016-standards/">setting up a JavaScript application with React</a>, I highly recommend reading it first.</p><h3>Setting Up ESLint</h3><p><a href="http://eslint.org/">ESLint</a> helps us catch mistakes by enforcing consistent standards and best practices. As our code is guarded by linting rules, we are guaranteed to produce consistent code, increasing maintainability.</p><p>As we will write React code, we will set up ESLint together with eslint-plugin-react. This plugin is responsible for linting React code. First, let’s install ESLint via npm:</p><pre>npm install eslint eslint-plugin-react eslint-watch --save-dev</pre><p>On top of the eslint plugin, we installed React support using eslint-plugin-react. We also installed eslint-watch, a tool for live reloading changes after save. We will set up the eslint-watch npm script in the next section of this article.</p><p>The ESLint configuration is in the .eslintrc file of the root folder of your application. The file .eslintrc is a JSON file responsible for configuring your individual linting rules. When it comes to React, the following keys and values are recommended so that ESLint works with React smoothly:</p><pre>{<br>    &quot;plugins&quot;: [<br>        &quot;react&quot;<br>    ],<br>    &quot;parserOptions&quot;: {<br>        &quot;ecmaVersion&quot;: 6,<br>        &quot;sourceType&quot;: &quot;module&quot;,<br>        &quot;ecmaFeatures&quot;: {<br>            &quot;jsx&quot;: true<br>        }<br>    },<br>    &quot;env&quot;: {<br>        &quot;es6&quot;:     true,<br>        &quot;browser&quot;: true,<br>        &quot;node&quot;:    true,<br>        &quot;mocha&quot;:   true<br>    },<br>    &quot;extends&quot;: [<br>        &quot;eslint:recommended&quot;,<br>        &quot;plugin:react/recommended&quot;<br>    ],<br>    &quot;rules&quot;: {<br>    }<br>}</pre><p>The plugins key is responsible for enabling the React plugin.</p><p>In newer versions of ESLint, we have to wrap the ecmaFeatures key in parserOptions. In version 1, ecmaFeatures was a top level key. Regardless of the version, this is the section where you can enable ESLint.</p><p>Talking about parser options, check out the <a href="http://eslint.org/docs/user-guide/configuring#specifying-parser-options">documentation</a> on default settings. It is important to use &quot;sourceType&quot;: &quot;module&quot; in case you are planning to use ES6 modules. Otherwise, each import would result in a linting error.</p><p><em>Recommended</em> settings come with a set of predefined rules. You can include them in the extends field. In this example, I defined eslint:recommended and plugin:react/recommended.</p><p>Whenever a recommended rule appears too strict, or a rule we need is missing, we can override it in the &quot;rules&quot; section of .eslintrc.</p><p>The &quot;env&quot; key is responsible for telling ESLint that it should accept some global variables. For instance, if you disallow using globals in general, you will have to take care of it, xit, expect etc when writing your automated tests.</p><h3>Linting in the console</h3><p>We have already installed the eslint-watch npm module. It’s time to use it.</p><p>Add &quot;lint&quot; and &quot;lint:watch&quot; to your package.json:</p><pre>&quot;scripts&quot;: {<br>    &quot;build&quot;: &quot;webpack -d &amp;&amp; cp src/index.html dist/index.html &amp;&amp; webpack-dev-server --hot --inline --colors --progress --content-base src/&quot;,<br>    &quot;build-prod&quot;: &quot;webpack -p &amp;&amp; cp src/index.html dist/index.html&quot;,<br>    &quot;lint&quot;: &quot;esw webpack.config.* src tools --color&quot;,<br>    &quot;lint:watch&quot;: &quot;npm run lint -- --watch&quot;<br>},</pre><p>You can now run npm run lint:watch in order to watch linting. Once you save a file, the linter displays all the errors and warnings.</p><p>If you want to run the linter once, use npm run lint.</p><h3>Convenient linting in the console</h3><p>You need to run</p><ul><li>npm run build to build your application and launch the development environment,</li><li>npm run lint:watch to run the linter.</li></ul><p>Later, you may run an automated testing tool as well.</p><p>You may want to execute just one npm script in order to launch your application and your linter. We will install the npm-run-all package to handle executing multiple scripts:</p><pre>npm install npm-run-all --save-dev</pre><p>After the installation, define a fifth script in your package.json:</p><pre>&quot;scripts&quot;: {<br>    &quot;build&quot;: &quot;webpack -d &amp;&amp; cp src/index.html dist/index.html &amp;&amp; webpack-dev-server --hot --inline --colors --progress --content-base src/&quot;,<br>    &quot;build-prod&quot;: &quot;webpack -p &amp;&amp; cp src/index.html dist/index.html&quot;,<br>    &quot;lint&quot;: &quot;esw webpack.config.* src tools --color&quot;,<br>    &quot;lint:watch&quot;: &quot;npm run lint -- --watch&quot;,<br>    &quot;start&quot;: &quot;npm-run-all --parallel build lint:watch&quot;<br>},</pre><p>When executing npm start, both scripts are executed in parallel. You will get all the compilation errors and linting errors in one window. Whenever you save a file, all the compilation and linting errors will be printed in the terminal.</p><h3>Linting in Sublime Text 3</h3><p>You can also configure the linter in Sublime Text 3. Open the Package Control, and install the following two packages:</p><ul><li><a href="http://www.sublimelinter.com/">Sublime Linter</a>,</li><li><a href="https://github.com/roadhump/SublimeLinter-eslint">Sublime Linter ESLint</a>.</li></ul><p>Red and yellow dots appear next to the line numbering, indicating warnings and errors respectively. Error messages appear at the bottom of your editor.</p><p>If you are using Atom, VS Code, or WebStorm, configuration is different. Check out the <a href="http://eslint.org/docs/user-guide/integrations">ESLint integrations guide</a> for more information.</p><h3>Sample rule configuration</h3><p>If you prefer configuring your own rules, you have to know what your options are. In this section, we will set up custom linting rules. These rules reflect my own opinion on how coding works the best for me.</p><pre>&quot;rules&quot;: {<br>    // first argument: 0 - silent, 1 - warning, 2 - error<br>    &quot;strict&quot;:             [ 2, &quot;safe&quot; ],<br>    &quot;no-debugger&quot;:        2,<br>    &quot;brace-style&quot;: [<br>        2,<br>        &quot;1tbs&quot;,<br>        { &quot;allowSingleLine&quot;: true }<br>    ],<br>    &quot;no-trailing-spaces&quot;: 2,<br>    &quot;keyword-spacing&quot;:    2,<br>    &quot;space-before-function-paren&quot;: [<br>        2,<br>        &quot;never&quot;<br>    ],<br>    &quot;spaced-comment&quot;:     [2, &quot;always&quot; ],<br>    &quot;vars-on-top&quot;:        2,<br>    &quot;no-undef&quot;:           2,<br>    &quot;no-undefined&quot;:       2,<br>    &quot;comma-dangle&quot;:       [ 2, &quot;never&quot; ],<br>    &quot;quotes&quot;:             [ 2, &quot;single&quot; ],<br>    &quot;semi&quot;:               [ 2, &quot;always&quot; ],<br>    &quot;guard-for-in&quot;:       2,<br>    &quot;no-eval&quot;:            2,<br>    &quot;no-with&quot;:            2,<br>    &quot;valid-typeof&quot;:       2,<br>    &quot;no-unused-vars&quot;:     2,<br>    &quot;no-continue&quot;:        1,<br>    &quot;no-extra-semi&quot;:      1,<br>    &quot;no-unreachable&quot;:     1,<br>    &quot;no-unused-expressions&quot;: 1,<br>    &quot;no-magic-numbers&quot;:   1,<br>    &quot;max-len&quot;:            [1, 80, 4],<br>    &quot;react/prefer-es6-class&quot;: 1,<br>}</pre><p>As you can see from the comment, the first argument of the rule setting describes the enforcement level of the rule:</p><ul><li>0 is silent,</li><li>1 displays a warning,</li><li>2 displays an error.</li></ul><p>You may ask the question why we need a 0. There are two valid reasons:</p><ol><li>You may want to define a rule for future use, but currently, you prefer muting it to focus on other linting errors;</li><li>You may want to override a stronger value from another linting configuration by using the &quot;extends&quot; option, and muting some rules you don’t need.</li></ol><p>Let’s see some clarification why I chose these settings. Warning: you will read my opinion, not the ultimate truth.</p><p>You can look up the documentation of any ESLint rules by pasting the name of the rule in the search bar of <a href="http://eslint.org/">eslint.org</a>.</p><ul><li>&quot;strict&quot; requires the usage of &quot;use strict&quot;; in global scope. Strict mode comes with benefits similarly to linting your code, by forcing you to stick to best practices.</li><li>&quot;no-debugger&quot;: have you ever had nightmares of your teammates committing debugger; statements in your application and giving you a surprise? Have you ever committed a debugger; statement yourself to an open source repo just to enjoy a facepalm moment? If any of these have happened to you, you will likely turn this option on. Regarding debuggers on production, your build process should eliminate all debuggers, so you should not rely on linting for this purpose. Oh, and <a href="http://www.zsoltnagy.eu/principles-of-debugging-web-applications/">never debug on production</a>.</li><li>&quot;brace-style&quot;: I use the <em>one true brace style</em> for personal projects, and &quot;allman&quot; in a corporate project. I don’t believe in brace-style wars, and I am fine with any of these two brace styles. The &quot;allowSingleLine&quot; key allows us to write compact blocks that fit in an 80 character long line.</li><li>&quot;no-trailing-spaces&quot; is for the convenience of developers. Imagine you wanted to reformate the code by pressing delete after your statement. Instead of joining the current line with the following line, you would just delete a trailing space.</li><li>&quot;keyword-spacing&quot; and &quot;space-before-function-paren&quot;: use these two settings to differentiate between statements and functions. Keeping the space in statements and loops like if (...) and for (...), and allowing no spaces between function and (...) makes sense.</li><li>&quot;spaced-comment&quot;: minor detail for the sake of readability of comments. Keep a space between /* or // and the comment text itself.</li><li>&quot;vars-on-top&quot; requires you to define your variables at the very top of your scope. This helps you think about the state space of a problem, helps you organized your thoughts, and penalizes you if you are a fan of creating very long functions.</li><li>&quot;no-undef&quot; and &quot;no-undefined&quot;: this is not a typo. The former disallows the usage of globals unless they are mentioned in the global key of .eslintrc or in a comment containing a global declaration. The key &quot;no-undefined&quot; disallows the usage of undefined. When we assign a variable a value, it’s defined. Once we indicate that the value should not be there anymore, instead of using undefined, I prefer using null. Using null indicates the absence of a value. There are some other inconvenient edge cases which sane developers will never use: it is possible to override undefined as a variable locally.</li></ul><pre>{<br>    let undefined = 2;<br>    console.log( undefined, typeof undefined );<br>}</pre><pre>&gt; 2 &quot;number&quot;</pre><p>This does not work in the global scope, as undefined is a property of the global object, and the value of this property is not changeable.</p><pre>{<br>    var undefined = 2;<br>    console.log( undefined, typeof undefined );<br>}</pre><pre>&gt; undefined &quot;undefined&quot;</pre><ul><li>&quot;comma-dangle&quot; disallows trailing commas in object literals. I don’t believe in this simplification, and I am convinced that most developers handle copy-pasting or extending configuration without trailing commas well enough. If you are interested in the advantages that come with using trailing commas, read <a href="https://pawelgrzybek.com/trailing-comma-in-ecmascript2017-function-parameter-list/">this post</a>.</li><li>&quot;quotes&quot;: yes, I use single quotes. Some people become emotional about favoring one way over the other. Post the question “Single or Double Quotes?” on HackerNews, and watch the incoming messages.</li><li>&quot;semi&quot; enforces semicolons. Highly recommended.</li><li>&quot;guard-for-in&quot;, &quot;no-eval&quot;, and &quot;no-with&quot; are losing relevance, as these are quite old language constructs. Most of the time, we use the for...of loop on iterables anyway. With and eval are in the <a href="http://archive.oreilly.com/pub/a/javascript/excerpts/javascript-good-parts/bad-parts.html">bad parts</a> of JavaScript according to common knowledge.</li><li>&quot;valid-typeof&quot; double checks your typos. When using the typeof operator, you compare its value against a string. If you make a typo in the string value, you get an error that’s hard to detect.</li><li>&quot;no-unused-vars&quot; check if your code contains variables that are never used. This rule detects typos as well as badly written code. Less disciplined developers tend to leave unused code in their code-base. This is a perfect way to send them automatic reminders.</li></ul><p>The following rules are only warnings, as there are cases when it makes sense to violate them:</p><ul><li>&quot;no-continue&quot;: another Crockford-rule. According to my opinion, continue in a loop is sometimes a good idea, but most of the time, it makes your code harder to read.</li><li>&quot;no-extra-semi&quot;: I am not a big fan of characters that don’t serve a semantic purpose</li><li>&quot;no-unreachable&quot;, no-unused-expressions&quot;: an obvious rule. Warn developers if their code is unreachable or their expressions are not used, as this phenomenon is rarely intentional.</li><li>&quot;no-magic-numbers&quot; there is nothing worse than using integers for constant values, and referencing these integers in your code. One change in the constant values results in maintenance hell. You don’t even know how to search for all the code segments that use these constant. Would you search for all occurrences of the value 1? This rule is highly inconvenient, as sometimes, magic numbers are values that are only used in one place, and declaring a constant for these values doesn’t make your code more readable.</li><li>&quot;max-len&quot;: Some people prefer 120 character long lines, as our resolution is large enough to add some horizontal space even if you have a two column layout in your text editor. I will stick to 80 characters, as I am also recording tutorial videos, and very long lines are harder to read in a tutorial video.</li><li>&quot;react/prefer-es6-class&quot; This is one example rule for React. We will use the ES6 syntax.</li></ul><p>For a complete list of React/JSX linting rules, check out <a href="https://www.npmjs.com/package/eslint-plugin-react">the npm documentation</a>.</p><h3>Editor configuration</h3><p>Your editor can also help you get rid of some linting errors. I use the following configuration in Sublime Text:</p><pre>{<br>    &quot;rulers&quot;: [80, 100],<br>    &quot;tab_size&quot;: 4,<br>    &quot;translate_tabs_to_spaces&quot;: true<br>}</pre><p>Access and modify the user settings on your computer in Preferences &gt; Settings. Your configuration is a JSON file. If you like the above keys, add them to your configuration.</p><p>Using the &quot;translate_tabs_to_spaces&quot; key neutralizes the default linting rule &quot;no-mixed-spaces-and-tabs&quot;.</p><h3>Exercise</h3><p>Check out the code of the <a href="http://www.zsoltnagy.eu/building-a-chat-component-in-react-and-es6/">React Chat Example</a> tutorial.</p><p>You can download or fork the correct branch of my GitHub repository <a href="https://github.com/zsolt-nagy/react-boilerplate/tree/react-chat-example">here</a>.</p><p>Set up the linter based on this article, and correct linting errors to get a feel for using ESLint. Try out using ESLint both in the terminal and in your favorite IDE or text editor.</p><p>You can read the other articles belonging to this series in chronological order by clicking <a href="http://www.zsoltnagy.eu/category/react-redux/">here</a>.</p><p>If you would like to get regular updates on my articles, sign up in the above form with your favorite email address.</p><p><em>Originally published at </em><a href="http://www.zsoltnagy.eu/use-eslint-like-a-pro-with-es6-and-react/"><em>www.zsoltnagy.eu</em></a><em> on January 5, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5dab3c04e49" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Secrets of a Successful Tech Interview]]></title>
            <link>https://medium.com/@Z501t/secrets-of-a-successful-tech-interview-9db4a2cf7d52?source=rss-6e7ffb89db6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/9db4a2cf7d52</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[tech-recruiting]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[tech-interview]]></category>
            <dc:creator><![CDATA[Zsolt Nagy]]></dc:creator>
            <pubDate>Sat, 08 Oct 2016 00:00:08 GMT</pubDate>
            <atom:updated>2018-01-14T19:20:56.050Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5iaI4oFA_j6GL0iWUp6DBw.jpeg" /></figure><p>Two candidates, one goal: a software engineer job offer in a tech startup. Both candidates have had an equally successful track record. One of them had no chance of getting the job. The other one got an offer above his market value.</p><p>On the surface, there was not too much difference between the two applicants. They even spent close to equal effort on preparing the application package. Yet, the contrast between them will soon become evident.</p><p>Matt crashed and burned during the interview. He couldn’t believe his bad luck once he was escorted to the exit. He thought, everything went really well until he got a question that seemed so easy at first. On his way home, he probably wondered why he had kept getting questions he had had a hard time answering, and hoped to be lucky one day.</p><p>Dave not only got the job offer with ease. He also got a higher starting salary than the top of the range budgeted for his position, and a career path to become a lead developer. In some sense, Dave was very happy with the offer, as he passed an interview once again. On his way home, however, he wondered which of his three offers is the right one for him.</p><p>Why does Dave keep getting the best possible offers, while Matt gets eliminated all the time?</p><p>Observing the situation from different angles, at the end of this article, you will also conclude that success leaves clues. Sometimes it is brutally evident why one candidate has a hundred times more chance of getting a job than another one, even if the successful candidate asks for a significantly higher salary.</p><h3>The Process</h3><p>For the sake of simplicity, we will focus on the following aspects of the application process:</p><ol><li>Application package</li><li>HR interview</li><li>Homework assignment</li><li>Tech interview</li><li>Negotiation style</li></ol><p>We will analyze each aspect one by one, and compare the performance of the two candidates.</p><p>All companies have different application procedures, and different interviewers look for different mistakes. Please don’t treat this case study as the ultimate truth. I do encourage you though to draw some generic conclusions based on common sense.</p><h3>Application Package</h3><p>Both Matt and Dave did a good enough job to get noticed. They demonstrated relevant experience in their resumes.</p><p>Matt had more experience, but less relevant experience. The only thing worrying me about Matt’s application was his pride in counting the number of <strong>months</strong> of experience in his field of expertise.</p><p>Beyond a certain level of familiarity, years of experience does not correlate with performance. There have been multiple studies about this phenomenon. For instance, in the book Peopleware: Productive Projects and Teams, written by Tom DeMarco and Timothy Lister, Coding War games have been analyzed. People with ten years of experience did not outperform people with two years experience in their field. Correlation between performance and familiarity only started forming below six months of experience.</p><p>In my post <a href="http://devcareermastery.com/design-your-career-become-so-good-they-cant-ignore-you">Design your Career — Become So Good They Can’t Ignore You</a>, I referenced the rule of ten thousand hours of deliberate practice, following the books Outliers (Malcom Gladwell), and So Good They Can’t Ignore You (Cal Newport).</p><p>Years of experience do not show the amount of time spent on deliberate practice, leaving your comfort zone, and deep work. Some enthusiasts practice four hours a day, 300 days a year. In two years, they gain 2400 hours of deliberate practice under their belt. Including four years of intensive studies at a university, the best students may have already collected ten thousand hours of deliberate practice.</p><p>A more relaxed developer may spend a hundred hours of deliberate practice per year in average.</p><p>Therefore, assuming that both Matt and Dave had at least six months of relevant experience in their specialization, I was fine with the result. None of them were junior developers anyway.</p><p>I kept Matt’s month of experience counter in mind though, as it was clearly an out of line metric.</p><p>I recall reading another developer with five years of experience, claiming that he has had an experience of writing more than 100.000 lines of code throughout his career. This statement is equivalent to a body builder saying that he has eaten three million kilocalories of food throughout his career.</p><p>If you mention the number of years of experience in too many places, chances are, people interpret it as <strong>explicit influence</strong>. Can’t you see that I am good? Shall I mention it once more? Write it down please. I am good!</p><p>The resume of Dave was significantly more compact. He wrote everything that seemed relevant to us, and left out the skills that didn’t matter. After all, enumerating Microsoft Excel, a Drivers Licence, knowledge of Haskell, a programming language mainly for universities, did not increase Matt’s chances. The same holds for a detailed description of a project that has little to no relevance to the position. Less is often more.</p><p>The cover letter of Matt was all about bragging. It ended with “Because of my six years of experience, qualifications, and accomplishments, I believe I will be a valuable asset to your company”. This was the one and only place where he mentioned our company in his cover letter.</p><p>Dave was a lot more easy-going, down to earth and friendly. He was also quite informal. He expressed how happy he was when he read our job ad, as he always wanted to work in an environment, where he could utilize his specialization to its limits. The cover letter sounded like a message from someone who genuinely cares about finding out whether we can work together.</p><p>I researched their LinkedIn recommendations and their GitHub profile too. Both of them were cutting edge. Matt seemed to have more dummy projects on GitHub. Dave, however, collected several hundred stars on an open source repository, and it later turned out that a company is using this repository commercially.</p><p>Matt had a blog with five short articles. It is always great to have a blog in general even if it is not cutting edge. I was lacking quality though. It looked as though Matt created a blog just to showcase that he had a blog. I personally still judged his blog as something positive.</p><p>Dave had a portfolio site, showcasing his open source contribution, including some demos. He also wrote about his mission in life. Very interesting read.</p><p>All in all, both Matt and Dave were interesting enough from a technological perspective. Dave clearly took the lead, but none of them have delivered anything so far.</p><h3>HR interview</h3><p>Matt continued applying explicit influence. He was emphasizing his own accomplishments, and his role in the projects. He had little to no questions about the company, or about the products the company is offering.</p><p>The conversation seemed to be a formality. Matt didn’t seem that interested in anything outside work. He also mentioned that his number one interest is to develop his own abilities.</p><p>Near the end of the interview, Matt started asking about overtime policies, the rules of booking leave, and benefits associated with the role. He said this information was important to him, as he was stressed about getting too much work in the past, and he is looking for a balanced life.</p><p>Matt didn’t really bother revealing his personality. He kept his style professional. After all, this interview was more or less a formality for him. He did inquire about the next steps of the application process. At the end, both the HR manager and Matt left the interview room relieved that it’s over.</p><p>At this point, some HR managers already show the door to even the best professionals, justified by lack of interest in the company. Matt did not make a lasting impression on the HR manager. His position was barely strong enough to get away with his attitude.</p><p>Dave came in ten minutes late. He apologized for not being on time, and assured the HR manager that he does not have a tendency of coming late.</p><p>Coming late happens to all of us once or twice in extreme situations. Once I remember I was almost half an hour late from an interview due to a traffic accident. Things like this happen. The worst thing that can happen to you is losing focus. Finding excuses and explaining yourself in detail is quite useless. Apologize, ask your interviewer if it is all right to continue the interview, and do your best afterwards. If an external condition blew your chances, tough luck, you have to take responsibility even for things you cannot directly influence.</p><p>Dave could continue focusing on the interview, and started asking question after question about the company. The HR manager was genuinely surprised by the avalanche of questions, and she felt the interview was turned upside down, and Dave started interviewing her.</p><p>After a while, Dave announced that he believed in balance, so even though he had other questions, it was now the HR manager’s turn to take the lead. Despite giving up the lead, the interview seemed rather a gentle conversation.</p><p>There is a major difference between faking interest and showing genuine interest. Dave was indeed curious about the company, his future position, and his colleagues, including the HR manager he was talking to. Instead of being pushy, and trying to make an impression, Dave was trying his best to gather as much information as possible to decide if the job was the right position for him. In some sense, he was the prize to be won, and companies were the ones bidding on his services.</p><p>After the interview, the company already had a great impression on Dave. Even the tech leaders were rooting for him to pass all the hurdles of the interview.</p><p>When it came to Matt, he did the necessary minimum to pass all tests. His qualifications and experience showed he was the right fit, yet, he clearly did not go the extra mile.</p><h3>Homework assignment</h3><p>Both candidates did an excellent job in developing all the requested features. Matt was very quick, he knew what he was doing. His total time spent on the task was one and a half hours after downloading the assignment. It took Dave three and a half hours to complete the same task.</p><p>Matt understood the specification correctly, and implemented all features adequately. The features were more or less robust, there were just a few small bugs here and there, and one major bug that he overlooked.</p><p>Observing the code, Matt clearly had some difficulties with some of the more complex features. It looked as though he wrote some of his methods based on trial and error instead of having a battle plan in advance. The result was bloated code, and long methods.</p><p>The following quote is from the book <strong>Clean Code: A Handbook of Agile Software Craftsmanship</strong> by Robert Martin.</p><blockquote><em>“The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that. Functions should not be 100 lines long. Functions should hardly ever be 20 lines long.”</em></blockquote><p>The danger comes with high cyclomatic complexity, i.e. a high number of possible execution paths within a method. A lot of branching in fifty lines of code is very hard to understand, even with comments. The only reason why it makes sense to write a long function is if you write a lookup-table, or you define long data structures.</p><p>When it comes to comments, they were rather used as notes for the developer, not notes for others. There was no generic commenting style in the application, and there was a clear absence of comments where they were needed.</p><p>Documentation was also fully missing. Even though it is not a requirement, documentation can sometimes save time. For instance, instead of implementing an obvious chunk of code handling an edge case, it is possible to just document the expected input format, and list the full solution as an improvement suggestion that you are ready to complete upon request. The developer saves time, and the interviewer will know the absence of a feature was not due to negligence or lack of awareness.</p><p>All in all, Matt barely passed another hurdle once again. After all, he completed all features quickly, there was no reason to reject him. However, by now, both soft skill warnings, and warnings on problem solving skills have surfaced. These warnings will be examined during the interview.</p><p>Dave failed to implement the last feature even though he was asked to complete all features. He wrote in the documentation that he omitted it on purpose, but he is willing to implement it in the upcoming version in case the rest of the code was not convincing.</p><p>The documentation of Dave was flawless. Installation instructions, assumptions and software design considerations made it very clear that there was a smooth thought process behind the implementation.</p><p>Dave claimed that he practiced acceptance test driven development during implementation. Indeed, all the tests showed intelligent design. I quickly recalled, Matt did not even write any tests. Both Matt and Dave mentioned test driven development in their skill-set. Yet, Dave made it clear in his mission that he is always targeting 100% test coverage. Once I saw the task, I concluded, these were not empty words. He provided test coverage even when he was not asked to do so.</p><p>All the implemented features were flawless. I spent ten minutes trying to break the solution with irregular inputs. I tend to do this monkey-test as a habit, and this skill has come very handy throughout my career. Astonishingly, I could only detect one small inconsistency. I could not even clearly call it a bug. I noted this inconsistency for future use, before examining the code more deeply.</p><p>The code itself was very well organized and consistently commented. It was obvious for me to understand the code even without comments.</p><blockquote><em>“One difference between a smart programmer and a professional programmer is that the professional understands that clarity is king. Professionals use their powers for good and write code that others can understand.” (Robert C. Martin — Clean Code)</em></blockquote><p>After all the investigation, asking for the missing feature did not make much sense. Dave has demonstrated his approach towards craftsmanship already.</p><h3>Tech interview</h3><p>Things looked very gloomy for Matt at this point. Matt would not have the best chances even if he was the only candidate. In case of Dave, we were not sure if we had the best chances to get him on board.</p><p>The objective of Matt’s interview seemed to be to determine if he is a good enough backup option in case Dave turns us down.</p><p>The objective of Dave’s interview was rather to convince him that his skills would be utilized to their peak, and he can gain more than enough career capital with us, meaning that he can grow faster with us than without us.</p><p>Throughout my career, I have been both in Matt’s shoes and in Dave’s shoes multiple times. Believe me, once you get to cutting edge, interviewing will become a whole new experience for you. If you are not there yet, don’t worry! You are reading the right material, as my mission is to take you there.</p><p>Let’s get back to Matt’s interview. Matt’s impression was clearly that he had nailed all hurdles so far. He seemingly arrived with confidence. Narcissistic confidence to be exact.</p><p>I asked Matt if he had any questions. He had a few about or technological stack, then he asked about our development methodology. So far so good. Then he asked a question about overtime, followed by a question on performance review periods. His last question was about perks such as getting budget for a conference.</p><p>These questions revealed his selfish nature. First, he was looking for comfort, then he was looking for rewards. Don’t get me wrong, being selfish is absolutely all right, as long as you can offer enough career capital in return. Some degree of selfishness is inevitable, both for your private life, and for your professional life. Just recall your flight attendant before taking off: “Once the oxygen masks fall, help yourself before helping others”.</p><p>Does Matt have enough career capital to offer? Let’s find it out! The first question was on one of the smaller bugs he had in his homework. Instead of focusing on the solution, Matt focused on apologizing. He expressed how much he dislikes these bugs, and that he tends to catch such errors normally. I told him it was all right, as all of us make mistakes, and asked him to correct it in the code.</p><p>I showed him another small bug, then the most significant bug in his code. Apologies became more and more uncomfortable. Matt quickly realized that his chances were getting worse. As I was aware of how Matt was narrating these events to himself, I told him not to disappoint himself, he was still in the game for the position. Sometimes, even candidates require some coaching on the spot.</p><p>Unfortunately for Matt, the major bug was a hard nut, and it took him twenty minutes to fix it. It was very alarming to me that he did not log information that helped him, he rather treated a thirty line long method as a black box. He tested multiple modifications at once. He was in fact very lucky to have fixed the mistake without introducing two other bugs as a side-effect. Having observed his thought process, I gave him one last chance to prove himself.</p><p>This chance is a very interesting interview question, requiring nothing else, but problem solving skills. If you are interested in this task, I am conducting <a href="http://devcareermastery.com/free-interview/">free simulated interviews</a>, where I give you feedback on your thought process and level of maturity on the spot. This opportunity alone will significantly increase your chances on understanding how to apply deliberate practice in your profession, and how to get to cutting edge.</p><p>Getting back to Matt, even though he had all resources available to him, he could have googled anything he wanted, and he could have asked me questions, his problem solving skills were simply not there. His started overcomplicating his solution, and he fell into his own trap. He did not have enough career capital to offer in exchange for the position.</p><p>Matt received feedback on the spot. He would not have gotten the position even if Dave had not been hired. From the perspective of Matt, it may be hard to understand this decision. However, from the outside, it was fully obvious.</p><p>The question was now if Dave will end up taking the position. We spent the first half an hour on introducing each other, and then Dave took control of the interview by kicking off a conversation about leadership style in the company, used technologies and methodologies, and he even showed interest in the history of the team.</p><p>After half an hour of chatting, I was convinced his lexical knowledge was amazing, as it was developed out of interest.</p><p>We then moved on to talk about the homework assignment. I presented the one bug to Dave. He said, “nice catch”, smiling. He jumped into his test suite, wrote a failing test, and corrected the code within a minute. Once his test passed, he showed the application in action. This process assured me that not only the bug was fixed, but no other tests signaled any other failures after the change.</p><p>The problem solving task was similarly easy for him. Dave explained his approach, and translated his thought process into working code within five minutes.</p><p>The rest of the interview was a formality. We solved some problems together that I had encountered during work. Dave only got stuck in one problem, but even then, he demonstrated a brilliant thought process, and contributed to the solution. Matt did not even reach this phase of the interview.</p><h3>Negotiation style</h3><p>Matt did not have a chance to negotiate an offer. The only thing we know is that he was fishing for perks during the interview, and he was trying his best to limit his own risks such as overtime. He often demonstrated his worth based on explicit influence, expressing what he thinks about his own experience and knowledge. However, when it came to implicit influence, when it was time to shine, career capital was missing.</p><p>Dave was an assertive negotiator. He did not use techniques such as not revealing his salary until we expose our range. Instead, he exactly knew his value, and had a very good idea about our ranges too. He would have even been ready to name all the sources of his research in case his numbers hadn’t matched ours.</p><p>All Dave said was “I am aware I am targeting a high salary, and it might be slightly outside your range. With my position and experience in this area, 20% of all developers get this salary or higher. If you choose to hire me, I will make sure I will do my best to justify the slightly higher costs.”</p><p>As an added benefit, we talked about his ambitions during the interview. Dave expressed his interest in leading a small team. Although he did not get a guaranteed role, he got two promises: a performance evaluation within a year, and a project he can take charge of. He also got full access to our leadership training.</p><p>Dave got the offer. While you are wondering if he took it or not, I would like to reframe your thought process to think about your own situation. Would you like to be like Matt or Dave? Think about one thing that you can do right now to improve your chances. I encourage you to start developing momentum today.</p><p><em>Originally published at </em><a href="http://devcareermastery.com/secrets-of-a-successful-tech-interview/"><em>devcareermastery.com</em></a><em> on October 8, 2016.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9db4a2cf7d52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Debugging Tips and Tricks]]></title>
            <link>https://medium.com/@Z501t/javascript-debugging-tips-and-tricks-f7eaba481473?source=rss-6e7ffb89db6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7eaba481473</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Zsolt Nagy]]></dc:creator>
            <pubDate>Sun, 09 Aug 2015 16:48:24 GMT</pubDate>
            <atom:updated>2018-01-11T19:53:20.311Z</atom:updated>
            <content:encoded><![CDATA[<p>Following my post about <a href="http://www.zsoltnagy.eu/principles-of-debugging-web-applications/">principles of debugging web applications</a>, it is time to explore JavaScript debugging in practice.</p><h3>Browser Developer Tools</h3><p>My personal favorite is the Chrome Developer Tools. Safari and Firefox don’t match the high standards set by Chrome, but they are getting better. Firefox has a combination of Firebug and the improved Firefox Developer Tools. If the Firefox team continues doing an excellent job at improving their built-in Developer Tools, Firebug may become obsolete one day.</p><p>Regardless of your personal preference, you should be able to test and debug any code in any browser that you target. This may or may not include the famous Internet Explorer 8.</p><p>Familiarize yourself with the developer tools of your choice. You may get additional debugging support from your IDE (Integrated Development Environment), or third party software.</p><p>Knowledge of debugging fundamentals is transferable from one tool to another. In fact, I learned the basics of debugging in the 90s using Borland’s C developer environment. Breakpoints, conditional breakpoints and watches were exactly the same as in your latest Chrome Developer Tools. I caught my first exception in Java near the year 2000. The concept of stack traces still apply, and even though JavaScript terminology calls these objects Errors, checking the stack trace is similarly useful as before.</p><p>Some knowledge is specific to front-end development. Examples:</p><ul><li>DOM inspection,</li><li>DOM breakpoints,</li><li>debugging events,</li><li>profiling memory leaks.</li></ul><h3>Breakpoints</h3><p>It is possible to add a breakpoint in the source code using the debugger statement. Once a debugger statement is reached, execution stops. The context of the current scope is exposed in the console, together with all local and global variables. Values of variables can be inspected by moving the mouse cursor over them.</p><p>Conditional breakpoints can also be created in the code:</p><pre>if ( condition ) { <br>    debugger; <br>}</pre><p>Breakpoints and conditional breakpoints can also be inserted in the Developer Tools of your choice. In the Chrome Dev Tools, clicking on a line number in the Sources view adds a breakpoint. If you right click on a breakpoint and select “Edit Breakpoint”, you can also add a condition.</p><h3>Break on node change</h3><p>In case your task is to debug junk code, you may end up asking why a DOM node was modified during execution. The Chrome Developer Tools gives you a handy breakpoint to detect node changes in the element tree.</p><p>In the Elements view, right click on an element and select the “Break on…” item from the context menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/0*9QlVvCPCkxXWywAr." /></figure><p>Break on Node Change</p><p>Possible types of DOM breakpoints:</p><ul><li>Nodes change in the sub-tree of the selected node,</li><li>Attributes of the selected node are modified,</li><li>The node is removed.</li></ul><h3>Avoid logging reference types</h3><p>When logging an object or an array, the values of primitive types inside the logged reference may change. When viewing a reference type, bear in mind that code executed between the time of logging and observation may influence the observed values.</p><p>For instance, execute the following code in your Chrome Developer Tools.</p><pre>var wallets = [{ amount: 0 }];</pre><pre>setInterval( function() {<br>    console.log( wallets, wallets[0], wallets[0].amount );<br>    wallets[0].amount += 100;<br>}, 1000 );</pre><p>While the second and the third logged attribute reflect the correct values, the Object refrence in the first attribute shows unreliable values. The value of the amount field is assigned at the time of revealing the attribute in the Developer Tools. This value stays the same regardless of how many times you close and reopen the same reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/0*Dnh6tuxnrkWs-srE." /></figure><p>Always know what you are logging. Either log primitive types, use watch expressions with breakpoints. In case of asynchronous code, avoid logging reference types.</p><h3>Tabular logs</h3><p>In some developer tools, you can use console.table for logging arrays of objects on the console.</p><p>Try executing the following row in your Chrome Developer Tools:</p><pre>console.table(<br>    [<br>        {<br>            id: 1,<br>            name: &#39;John&#39;,<br>            address: &#39;Bay street 1&#39;<br>        },<br>        {<br>            id: 2,<br>            name: &#39;Jack&#39;,<br>            address: &#39;Valley road 2.&#39;<br>        },<br>        {<br>            id: 3,<br>            name: &#39;Jim&#39;,<br>            address: &#39;Hill street 3.&#39;<br>        }<br>    ] );</pre><p>The result is a nice looking table. All primitive types are displayed right away. Their values reflect the state at the time of logging. Complex types are logged displaying their types. Their contents is not possible to browse. Therefore, console.table should only display two dimensional data structures of form arrays of objects having primitive values.</p><h3>XHR Breakpoints</h3><p>Sometimes you may encounter an erroneous AJAX request. If you are not able to identify the code submitting the request right away, XHR breakpoints save you time. XHR breakpoints stop execution of the code when a special type of AJAX request is submitted and direct the user to the code segment submitting the request.</p><p>In the Sources tab of the Chrome Developer Tools, one of the defined breakpoint types is XHR Breakpoints. When clicking on the + icon, you can enter URL fragments. The JavaScript code breaks whenever such a URL fragment appears in the URL of an AJAX request.</p><h3>Event Listener Breakpoints</h3><p>All types of events may be caught by the Chrome Developer Tools, making it possible to debug what happens if the user presses a key, clicks a mouse button etc.</p><h3>Pause on Exceptions</h3><p>The Chrome Developer Tools allows you to pause execution of your JavaScript code upon throwing an exception. This makes it possible for you to observe the state of your application at the time when the Error object was created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/0*-QD_dd9ulEDXROkU." /></figure><p>Pause on Exceptions</p><h3>Snippets</h3><p>The left panel of the Sources Tab has a Snippets sub-tab for the purpose of storing code snippets that help you debug your code.</p><p>If you keep on using the console for debugging and you write the same code over and over again, it is high time abstracting your code into a debugger snippet. This way, you can even transfer your debugging magic to your peers.</p><p>Paul Irish published some basic <a href="https://github.com/paulirish/devtools-addons/wiki/Snippets">debugging snippets</a> such as inserting a breakpoint before the execution of a function. It is worth examining these snippets and searching for others on the web.</p><h3>Inserting a breakpoint before a function</h3><p>If you have access to the reference of a function, you can also insert a breakpoint that stops execution just before the function is called. If f is the function you would like to debug, the debug( f ) statement adds this breakpoint.</p><h3>Unminify minified code</h3><p>Use source maps whenever possible. In some cases, source maps don’t make it to production, however, you should <a href="http://www.zsoltnagy.eu/principles-of-debugging-web-applications/">not debug on production anyway</a>.</p><p>In case source maps are not available, your last resort is the Pretty Print button in the Sources tab of your Chrome Developer Tools. The {} Pretty Print button is below the textarea displaying the source code. Pretty Print beautifies the source code and changes the line numbers for easier debugging and more useful stack traces.</p><p>Pretty Print should still be used as a last resort. Uglified code is still ugly in a sense that the names are still not semantic.</p><h3>Console bookmarks for DOM elements</h3><p>Both Chrome Developer Tools and Firebug gives you bookmarks for the DOM elements you last clicked on in the Elements (Chrome) or HTML (Firebug) tab. If you selected elements A, B and C in this order,</p><ul><li>$0 gives you C,</li><li>$1 gives you B,</li><li>$2 gives you A.</li></ul><p>If you select another element D, then $0, $1, $2 and $3 will hold the DOM elements D, C, B and A respectively.</p><h3>Accessing the call stack</h3><p>The command console.trace logs a stack trace including line numbers.</p><pre>var f = function() { g(); }<br>var g = function() { h(); }<br>var h = function() { console.trace(&#39;trace in h&#39;); }</pre><pre>f();</pre><p>The Sources tab in Chrome Dev Tools also displays the Call Stack just below the Watch expressions.</p><h3>Audits</h3><p>Performance audit tools often come handy. These tools act as a generalized leak buster. They detect where your website may be optimized. As these tools don’t have any understanding of your product, some of the advice may be ignored. More often than not, the audit tool points out valid areas in which your website can be optimized significantly.</p><p>Example audit tools:</p><ul><li>Audit tab of the Chrome Developer Tools</li><li><a href="http://yslow.org/">YSlow</a></li></ul><h3>Practice makes perfect</h3><p>While some debugging techniques may be familiar to you, others may save you some time. If you start applying some of these techniques in practice, I suggest re-reading this article in a couple of weeks. You will be surprised how much your focus may change in a matter of weeks.</p><p><em>Originally published at </em><a href="http://www.zsoltnagy.eu/javascript-debugging-tips-and-tricks/"><em>www.zsoltnagy.eu</em></a><em> on August 9, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7eaba481473" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloning Objects in JavaScript]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@Z501t/cloning-objects-in-javascript-822727a339c1?source=rss-6e7ffb89db6b------2"><img src="https://cdn-images-1.medium.com/max/820/1*2kZl4_9f5QDgOjSIxvEXTg.jpeg" width="820"></a></p><p class="medium-feed-snippet">This article was originally posted on zsoltnagy.eu.</p><p class="medium-feed-link"><a href="https://medium.com/@Z501t/cloning-objects-in-javascript-822727a339c1?source=rss-6e7ffb89db6b------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@Z501t/cloning-objects-in-javascript-822727a339c1?source=rss-6e7ffb89db6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/822727a339c1</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Zsolt Nagy]]></dc:creator>
            <pubDate>Sat, 25 Jul 2015 20:00:33 GMT</pubDate>
            <atom:updated>2017-12-30T12:19:44.773Z</atom:updated>
        </item>
    </channel>
</rss>