<?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 Nick Lee on Medium]]></title>
        <description><![CDATA[Stories by Nick Lee on Medium]]></description>
        <link>https://medium.com/@nicklee1?source=rss-32fb6fce5f0e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Rm3iox6YHWDHiu0s22qH_Q.jpeg</url>
            <title>Stories by Nick Lee on Medium</title>
            <link>https://medium.com/@nicklee1?source=rss-32fb6fce5f0e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 15:22:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nicklee1/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[Protecting Your JS Web Apps with an App Gateway]]></title>
            <link>https://medium.com/@nicklee1/protecting-your-js-web-apps-with-an-app-gateway-8826e19cbaf0?source=rss-32fb6fce5f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8826e19cbaf0</guid>
            <category><![CDATA[web-apps]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Nick Lee]]></dc:creator>
            <pubDate>Thu, 23 Nov 2017 10:55:49 GMT</pubDate>
            <atom:updated>2017-11-23T10:59:21.632Z</atom:updated>
            <content:encoded><![CDATA[<p>A couple of weeks ago I started building a PoC for a cloud based load testing service. The overall architecture was a fairly standard setup:</p><ul><li>Simple “marketing” site i.e. just simple template driven content</li><li>An Express based API which exposed some protected endpoints that allows users to configure and start tests, as well as obtain information about in progress and past tests.</li><li>A React based web app which requires authentication to view, that essentially acts as “pretty” user interface for the API</li></ul><p>Typically a user will find out about the product on the www.myservice.com site, then the main application that provides the service in question is hosted on a subdomain such as app.myservice.com, whilst the API is accessed at api.myservice.com. Of course it’s not essential to use subdomains, but it just makes things a little bit clearer when it comes to deployment.</p><h4>The Authentication Challenge</h4><p>When I start developing apps, authentication is usually one of the first challenges as I tackle as it is a fundamental part of many applications, and getting your users, roles and permissions right early on is crucial. I really like the idea of create-react-app, and the fact that the upgrade path is extremely easy so long as you don’t <em>eject</em>. The problem is, however, that you cannot access the Express server that sits behind your create-react-app, and therefore you have to rely on client side code to handle authentication which for me is a bit of a no-no so I set about finding an alternative answer.</p><h4>The App Gateway is Born</h4><p>After giving it some thought, I decided I needed a gateway server which could take care of authentication for me, and only allow access to the Web App if a user was authenticated. If a user is unauthenticated, it should present the user with a login screen to allow them to login and obtain an access token <strong>which can be used by the Web App to make calls to a backend API</strong> on the users behalf. For authenticated users, the gateway should just proxy all requests on to the upstream server that renders the Web App. When a user logs in, they’ll be given an access token (stored in their browser) required by the gateway authenticated on subsequent requests.</p><p><em>Note: It is essential that the </em>access<em> tokens issued by the gateway are understood by your API. For example, you could use shared secrets between the gateway and the API, or if you’re using an API Gateway like AWS API Gateway to manage API access, you could write a custom Authoriser which can make requests to the gateway to validate the token.</em></p><p>I liked this concept and quickly created a prototype gateway which I’ll follow describe in a follow up article. However, this got me thinking about other ways in which the gateway server could add further value and, given it’s Black Friday week when I’m writing this, the first thing that came to mind is rate limiting access to the application. During peak traffic periods, many large scale sites (such as retailers and ticket sales websites) will throttle the number of visitors allowed on the site at any one time, and effectively operate a queue. In fact, this functionality is so common on high traffic sites, that it is out of the box functionality provided by Akamai. Unfortunately, Akamai’s services are a pretty expensive luxury that not every business can afford!</p><p>Similarly, you could also add in some application monitoring and alerting into the Gateway and trigger alerts if the backend Web App is beginning to slowdown or becoming unresponsive. Think of the gateway as a bouncer for your Web App — if there’s too many people in there, or you don’t have ID, you’re not getting in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*BS0kl8NMoB_1hHgW9oPKOA.gif" /></figure><p>Architecturally speaking, this gateway is a similar pattern to an API Gateway except that it is for UI Applications, so I decided to call it (wait for it…) an <strong>App Gateway</strong>. It’s sole job is to act as a barrier to the accessing an application whilst providing commonly required functionality such as only ensuring only authorised users can access app, or queuing users during peak periods where app is overloaded. When building client side applications with frameworks like React, this pattern is real timesaver as you can now assume all users are authenticated, rather than trying to determine the auth status from session data stored in local storage, manage API expiry tokens, and so on. All you need to do is get the token which was set in the user’s browser by the App Gateway, and send a request to your backend API to obtain the user information.</p><h4>Deployment Considerations</h4><p>The App Gateway is the entry-point for your Web app and as such it needs to be public facing. You should of course ensure that the upstream server, for example the server which your create-react-app is deployed on, is not publicly accessible. Additionally, the Gateway should be scaled appropriately, and may need to proxy additional protocols such as WebSockets.</p><h4>Closing Thoughts</h4><p>I’ll be following this post up with an example NodeJS implementation of an App Gateway, but if you simply can’t wait, here’s the code: <a href="https://github.com/nicklee1990/auth-gateway-example">https://github.com/nicklee1990/auth-gateway-example</a></p><p>The App Gateway is essentially a sister concept to the API Gateway i.e. a barrier which provides typical functions before entering an application such as authentication. We are now in a world where client-side applications are everywhere, cloud based infrastructure is so cheap and the performance overhead of 1 extra HTTP hop is so insignificant (if things are deployed correctly), that isolated deployable units like an App Gateway which abstract common, and often complicated concerns such as Authentication make much more sense than they did previously in the world of monolithic applications. And also I really didn’t want to eject from my create-react-app :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8826e19cbaf0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agile Qualifications: Don’t Bother]]></title>
            <link>https://medium.com/@nicklee1/agile-qualifications-dont-bother-7e41d2d6f2e4?source=rss-32fb6fce5f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e41d2d6f2e4</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[agile-development]]></category>
            <dc:creator><![CDATA[Nick Lee]]></dc:creator>
            <pubDate>Wed, 09 Aug 2017 06:45:02 GMT</pubDate>
            <atom:updated>2017-08-09T06:45:02.790Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*NXSIbzLCAroj07nOnQOTtw@2x.png" /></figure><p>One thing that particularly disappoints me on a number of job specs that come my way is when I see them express a strong preference for candidates who are qualified scrum masters. It’s worrying that our industry values superficial qualifications over substance as I feel there could be a lot of great candidates slipping through the recruitment nets.</p><h4>One Size Fits One</h4><p>Anyone who has worked in agile environments at a number of different organisations can attest to one thing: no two organisations have the same interpretation of agile. Whether it’s the way they approach big chunks of work, or even just their sprint naming conventions, every team is unique.</p><p>When you think about it, this should be an obvious conclusion to draw. Every organisation will have a different culture, different budget, and team members from different backgrounds and with different skill sets. Even the tooling available and appetite for risk, which is often defined by their industry and the nature of their product/service, help shape what the processes employed by a team look like. Imagine where a team simply doesn’t have budget to hire a product owner or a scrum master, so the lead developer performs those tasks, grooming the backlog etc. This team can still adopt agile behaviours and work in an iterative manner even if it goes against the traditional image of a scrum team, but I know of agile preachers who would say that this team isn’t working in an “<em>agile” </em>way. Remember, agile is about behaviours, not hard and fast rules that must be adhered to.</p><h4>So are qualifications a complete waste?</h4><p>Not necessarily. The better courses might teach you some new concepts or processes that you can test out and adapt to your own specific situation. You always have to be open to learning new approaches and the instructors (usually) will be experienced practitioners who can provide plenty of anecdotal lessons.</p><p>Additionally, if I’m being pragmatic and looking at things from the individual’s perspective, then the answer becomes a definite no. We have to always consider the current context in which we work, and unfortunately being a qualified scrum master, for example, will look good on your CV and help you get past the initial stages of some job applications.</p><p>However, I strongly feel that when it comes to finding what works and what doesn’t in a given environment, experience is of much greater value compared to a qualification.</p><p>When it comes to looking at the quality of the courses and what you get out of them, I’ll be blunt: the courses are usually 3–5 days, fairly boring, classroom based and involve a brief test at the end of the course. You’re not going to suddenly become a top agile practitioner after a bit of revision and scoring 70% on a pretty noddy test.</p><p>From a recruitment point of view, I wouldn’t consider agile qualifications particularly valuable at all. Lets say I’m a newly qualified scrum master, and I’ve worked on a project that decided to “go agile” 1 month ago, hence the qualification. Will I realistically be more knowledgeable about agile and ultimately work better in agile teams than someone who has spent 2 years working across 4 different agile projects? It’s a fact of life that CVs often get scan read in the first instance. If you’re skipping straight to the Qualifications section and hoping to see “Qualified Agile &lt;insert role&gt;”, you’re doing it wrong. You’ll be planting the idea in your mind that if it’s not there something is missing from the CV and potentially discard a candidate for the wrong reasons.</p><p>The ability and willingness for someone to adapt to a different way of doing things in a new team is a much greater indicator of whether they suit working in an agile environment than any qualification. I know plenty of people who work in “agile” teams, and subconsciously resist agile ways of working. You can only work out whether someone really “gets it” from a discussion with them.</p><h4>Closing Thoughts</h4><p>Don’t get me wrong, certain IT qualifications do have value, particularly those around security. However, being a qualified scrum master or a qualified enterprise and solution architect doesn’t make me <strong><em>significantly</em></strong> better at my job, it just means I sat on a course for 5 days and passed a trivial exam at the end of it.</p><p><strong><em>NB</em></strong><em>: If anyone reading has their framed scrum master certification sitting on their mantle piece at home and is feeling a bit offended by this article, spark a discussion in the comments!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e41d2d6f2e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A BDD Style Regression Test Automation Approach Does Not Make Sense]]></title>
            <link>https://medium.com/@nicklee1/a-bdd-style-regression-test-automation-approach-does-not-make-sense-5bc1a682a440?source=rss-32fb6fce5f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bc1a682a440</guid>
            <category><![CDATA[bdd]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[tdd]]></category>
            <dc:creator><![CDATA[Nick Lee]]></dc:creator>
            <pubDate>Thu, 06 Jul 2017 10:58:55 GMT</pubDate>
            <atom:updated>2017-07-06T12:20:18.810Z</atom:updated>
            <content:encoded><![CDATA[<h4>Trying to retrospectively create a BDD style automation framework to automate regression tests adds nothing but complexity.</h4><p>Behaviour Driven Development (BDD), I fear, has become one of those terms which has lost all meaning, like “cloud” or “PCI”. The acronym ‘BDD’ is banded around the test world in sentences which make absolutely no sense if you substitute the acronym for the words which it represents.</p><p>I frequently read articles in the QA/testing realm discussing the merits of writing your Selenium based tests by creating a “BDD test automation framework” and it worries me that there is such widespread misunderstanding of the concept. The most common structure of an article on the subject usually involves demonstrating using a Cucumber implementation library to parse spec/feature files written using Gherkin syntax, and then implementing the corresponding ‘Steps’, probably using Selenium Webdriver for the Given/When feature actions with an assertion library for the Then section.</p><p>So what’s wrong? The problem is that these “BDD style” tests achieve minor readability gains at the expense of adding a layer of complexity to your framework. You’re not doing BDD by writing a bunch of tests in feature files in Gherkin syntax; you’re just borrowing and (pointlessly) repurposing a central feature of the BDD process. BAs can write Given/When/Then style regression specs if they so desire, but you don’t need to actually parse them as input to your framework.</p><h4>What is BDD?</h4><p>First off, lets take a step back and understand what BDD is. BDD was originally introduced as a solution to the age old problem in software development of communication breakdown between technical and non-technical resources. <strong>It is a software development process that results in well tested code, not an approach to testing.</strong> The clue is in the name: Business Driven Development. BDD’s primary aim isn’t to generate tests, it’s a way of clearly communicating specs to technical team members to minimize disparities between the vision and implementation of features.</p><h4>But how should I write my automated tests?</h4><p>Automated tests are often a handy by-product of using a BDD approach to software development. By undergoing the process of defining your features in feature files for developers to implement and using a Cucumber implementation, you can end up with a suite of automated tests. However, automated tests are not the focus here, the focus should be on the feature itself. Therefore if you have an existing product and you want to automate a large pack of regression tests, (re)writing these as feature files using Gherkin syntax and parsing them in your framework doesn’t add much value because the feature is already built – the communication and build is done!</p><p>Some may argue that using a BDD style test automation framework gives you the benefit of allowing non-technical team members to write tests, but that simply isn’t true because a technical team member/automation engineer still has to implement what each given/when/then clause is doing. This capability can just as easily be achieved by creating a well thought out set of Page Objects and Modules in your test automation framework which allow testers with a very limited understanding of code and a decent IDE to chain together a few methods and write some assertions. Even if you’re BAs insist on only defining the tests and not implementing them, and they <strong>must </strong>use Gherkin syntax to do so, just write tests based on these feature files, you don’t really need to parse them. If you go down the route of parsing these files and parameterising the statements, as your test suite grows you’ll inevitably end up with duplicate step definitions, usually because someone writes a differently worded but functionally equivalent step in their feature files. Trust me, this <strong>will </strong>happen when you start reaching a suite with dozens of tests. This duplication of tests steps is a killer for so-called BDD Style Automation frameworks and will lead to a bloated, confusing framework.</p><p>The additional layer of complexity is best demonstrated through an example.</p><p>Let’s say we have a simple eCommerce site and we create a basic automation framework with some Page Objects. We decide we want to run some end to end tests to verify the stock check functionality on the project page which has proven to be a little flakey at times. We’ll ignore the implementation of the Page Objects, but assume that their methods return instances of the resulting page. Our test might look something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bac4d8bd74eead94234f7e509303b4d1/href">https://medium.com/media/bac4d8bd74eead94234f7e509303b4d1/href</a></iframe><p>Now let’s rewrite the same case using a BDD style feature file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc1a8177b257acf81d7335eb1aff3420/href">https://medium.com/media/cc1a8177b257acf81d7335eb1aff3420/href</a></iframe><p>Of course at this point if we run our test suite with a Cucumber plugin, our tests will fail and offer to create some Steps for us. Once implemented, these might look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b35de9d3c049d83b7c5cc22e5bab8df/href">https://medium.com/media/5b35de9d3c049d83b7c5cc22e5bab8df/href</a></iframe><p>Hopefully it’s immediately obvious that all adding BDD style feature file layer has accomplished is making things very slightly more legible in the feature file. However, if you have any familiarity with Javascript, the code is less readable in my opinion, and it’s added another set of dependencies (in this case the Cucumber JS library and Cucumber Protractor binding library) and an additional layer of indirection. One might argue that you don’t need to use a Page Object model in the BDD style framework, but over time you’ll discover you need a way to abstract parameterised actions that are carried out in multiple test steps. Also, looking at the original test code, it’s pretty hard to argue that it isn’t legible or understandable to someone with almost no technical knowledge.</p><p>A more efficient use of resources would be to simply make a small investment in a good IDE and in the training of team members who don’t currently have basic understanding of the language being used in the tests.</p><h4>Closing thoughts</h4><p>End to end testing should always be a part of the delivery pipeline for any serious software product and there are many benefits derived from creating a test automation framework , such as making your testing more extensive and robust, allowing multiple browser testing with a few lines of config, and reducing the scope for human error. However, trying to write your tests retrospectively using BDD feature files, in my view, is a waste of time. You would be better off simply using a well designed, data driven Page Object model based framework. BDD can provide great benefits and some development teams have seen its implementation lead to positive results, but always remember that it’s intended to be an approach to your entire development process, not just a bolt-on to your testing practices.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bc1a682a440" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring Sublime Text 3 for Modern ES6 JS Projects]]></title>
            <link>https://medium.com/@nicklee1/configuring-sublime-text-3-for-modern-es6-js-projects-6f3fd69e95de?source=rss-32fb6fce5f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f3fd69e95de</guid>
            <category><![CDATA[sublimetext]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Nick Lee]]></dc:creator>
            <pubDate>Thu, 05 Jan 2017 14:58:14 GMT</pubDate>
            <atom:updated>2017-01-05T14:58:14.316Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to configure Sublime Text 3 to have <strong>IntelliSense, </strong>Eclipse/JetBrains style keybindings and ES6 Syntax highlighting</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*P-AK4Z4JMCQhUD21rBCufQ.png" /></figure><p>Whilst working on a Node project at a recent client, their development team was using Sublime Text 3 as their IDE of choice and that they wanted the whole team to be working on a very similar stack. I just don’t buy it when a developer says they <strong>need </strong>a certain IDE to do their job so there was no complaints from me. Powerful and complex IDEs can be a great time saver and everybody has their favourites, but needing a specific IDE is a warning sign that the user is over-dependent on it and is perhaps missing some core skills and knowledge, particularly relating to modern build tools or application compilation.</p><p>My main gripes with Sublime when I got started were that the vanilla installation is missing some time saving features which I feel are essential in modern IDEs for JS development:</p><ul><li>Autocomplete was pretty naive, and didn’t support CommonJS or ES6 modules. The autocomplete basically just analyses the current file and even then it provides quite limited analysis</li><li>Even when there was autocomplete available, the function completion and information features were weak</li><li>No support out of the box for ES6 syntax</li><li>The key bindings felt a bit laborious</li></ul><p>Not being happy putting up with these issues, I set about resolving them.</p><p><em>Admittedly the key bindings gripe is purely personal preference, but if you’re coming from an Eclipse based IDE, not having “.” trigger the autocomplete suggestion box is enough to slowly drive you insane.</em></p><h4>Getting Started</h4><p>First of all you need to install the <a href="https://packagecontrol.io/">Package Control</a> to make the rest of this tutorial a breeze.</p><ol><li>Open the Command Palette using ctrl + shift + p</li><li>Type <em>Package Control</em> and hit Enter on the option to install package control</li></ol><p>From now on, to <strong>bring up the package installer</strong>, simply open the Command Palette with ctrl + shift + p, and type “install package” and hit enter on the <em>Package Control: Install Package </em>option. This will bring up a search box you can use to find packages.</p><h4>Improved IntelliSense</h4><p>IntelliSense covers general autocomplete and inline function information such as function metadata, parameter information and return values. Luckily the <a href="https://github.com/ternjs/tern_for_sublime/issues">tern_for_sublime</a> package does a great job of utilizing <a href="https://ternjs.net/">TernJS</a> to provide excellent autocomplete features.</p><ol><li>Bring up the package installer</li><li>Type <em>Tern</em> and Hit Enter on the <em>Install Package: tern_for_sublime</em> option</li><li>Select <em>Yes, Allow </em>when prompted for whether tern_for_sublime should install Tern</li></ol><p>4. Add a file to the project root called .tern-project and make sure it looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/943144c2668c2904c21e78d5196ca03d/href">https://medium.com/media/943144c2668c2904c21e78d5196ca03d/href</a></iframe><p><em>Consult the </em><a href="http://ternjs.net/doc/manual.html"><em>TernJS Manual</em></a><em> for other available libraries, learning about loading certain files by default using </em>loadEagerly<em> and configuring plugins. If you have a lot of NPM dependencies, you may encounter Sublime performance issues. To rectify this, in your config file you may need to exclude the node_modules directory and explicitly include certain subdirectories within it.</em></p><p>Now when you use ES6 imports or require a module in Node, Sublime should be able to provide auto-completion for that module. Furthermore, you should get some handy auto-completion for any libraries you included in the libs array —to test this try getting suggestions for document</p><h4>Improved Function Completion and JSDoc support</h4><p>Once you have tern_for_sublime working correctly, setting up the tooltip display is simple. Just go to Preferences &gt; Package Settings &gt; Tern &gt; Settings (User) and paste the following in this file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/423106b6ebf9512a9b6151642c682971/href">https://medium.com/media/423106b6ebf9512a9b6151642c682971/href</a></iframe><p>After saving the file, when you click on a function or request suggestions, you’ll get a fancy looking tooltip that can read your JSDocs!</p><p><em>Note: I strongly recommend installing </em><a href="https://github.com/spadgos/sublime-jsdocs"><em>DocBlockr</em></a><em> via Package Control for generating Doc Blocks as it’s a huge time saver.</em></p><h4>ES6 Syntax Highlighting</h4><p>Sublime doesn’t have Syntax highlighting for ES6 JS by default. Install the <a href="https://github.com/babel/babel-sublime">babel-sublime</a> package</p><ol><li>Bring up the package installer</li><li>In the search box type <em>Babel</em> and Hit Enter on the Babel package</li><li>Enable the Babel Syntax for Javascript by opening a JS file (or JSX if required) and in the Sublime Menu go to View &gt; Syntax &gt; Open all with current extension as… &gt; Babel &gt; JavaScript (Babel)</li></ol><p>That’s it! Sublime will now understand and provide syntax highlighting for ES6 Javascript</p><h4><strong>Testing it out</strong></h4><p>All that’s left is prove our changes work. In your Sublime project, create 3 files:</p><ul><li>index.js</li><li>Calculator.js</li><li>Logger.js</li></ul><p>and make sure they look like these:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0104638b5310710ee394321ec44e86f/href">https://medium.com/media/e0104638b5310710ee394321ec44e86f/href</a></iframe><p>If everything has worked, when you request suggestions for an imported module, you should get something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*VGTRruHHwmRG2b-jYSrgdg.png" /><figcaption>Behold auto-complete in all it’s glory!</figcaption></figure><p>Even better, when you click on the parameters inside the add or logMessage calls in index.js, you should get something which looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oe8ZUeWme6en5uxkWwjHfg.png" /><figcaption>Who needs WebStorm??</figcaption></figure><h4>Eclipse/JetBrains Style Key Bindings (dot auto-complete)</h4><p>The default auto complete trigger in Sublime is ctrl + space. Coming from an Eclipse based IDE background, this felt unnatural to me and I was craving ‘dot’ autocomplete trigger. Luckily in Sublime this is very simple to set up:</p><ol><li>Open Preferences &gt; Settings</li><li>In the new Window that opens, in the right hand pane Preferences.sublime.settings – User add the auto_complete_triggers as shown below (you can just leave any other settings as they are)</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f3b230f29df1d204a320de1a3374c62/href">https://medium.com/media/4f3b230f29df1d204a320de1a3374c62/href</a></iframe><p>Now when you hit “.” you should see autocomplete suggestions.</p><h4>Eclipse/JetBrains Style Key Bindings (ctrl + click jump to definition)</h4><p>The default go to definition shortcut in Sublime is F12. To change this to ctrl + left mouse click you need to add a new <em>mousemap </em>file to your Sublime installation. Luckily doing this is very simple.</p><ol><li>On your file system, navigate to wherever the mousemaps are kept on your OS*</li><li>Create a file named Default (Windows).sublime-mousemap (replace Windows with OSX or Linux depending on your OS)</li><li>Set the contents of that file to the following:</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11b965453bf290080b00a7769dc5820f/href">https://medium.com/media/11b965453bf290080b00a7769dc5820f/href</a></iframe><p><em>*The location of where your mousemap files should be kept varies based on your OS. At the time of writing, these are:</em></p><ul><li>Windows:C:\Users\YOUR_USER\AppData\Roaming\Sublime Text 3\Packages\User</li><li>OSX/Linux:~/.config/sublime-text-3/Packages/User</li></ul><h4>Suggestions</h4><p>If you have any suggestions or nice tips for using Sublime or must have plugins when developing JS based applications, let me know in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f3fd69e95de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Your Protractor Tests Data Driven]]></title>
            <link>https://medium.com/@nicklee1/making-your-protractor-tests-data-driven-e3c9e2a5e4e7?source=rss-32fb6fce5f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3c9e2a5e4e7</guid>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[protractor]]></category>
            <dc:creator><![CDATA[Nick Lee]]></dc:creator>
            <pubDate>Sun, 18 Dec 2016 12:17:39 GMT</pubDate>
            <atom:updated>2016-12-18T20:00:30.163Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to use an external data source in your Protractor tests to improve the reusability of your end to end tests</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*CRnQo_L3-oeVPatajLLo6Q.png" /><figcaption>Image Source: <a href="http://codecept.io/angular/">http://codecept.io/angular/</a></figcaption></figure><p>Often when creating end to end tests using Protractor, you’ll end up writing several tests which execute the same steps over and over again, and only differ in terms of the values you’re inputting or performing assertions on. Verifying form validation is working is a classic example of this. A password field could have multiple validation rules and error messages, however the test steps to trigger those rules will be identical except for the value entered in the text field. When confronted with any scenario of this nature, it makes sense to try and reuse your code and make it a little more DRY. Abstracting your test data from your test automation framework is always a good idea, but it also provides an excellent way of achieving this reusability when testing very similar scenarios.</p><h4>How it’s done</h4><p>Let’s take a look at a really simple test and how we can improve it.</p><p><em>Note: I’m using ES6 syntax in this tutorial however the code provided could easily be replicated using ES5</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09f0619f1d6c090ea6c85dbd38567362/href">https://medium.com/media/09f0619f1d6c090ea6c85dbd38567362/href</a></iframe><p>This is a basic test for the AngularJS homepage to ensure that the example app correctly displays the text entered in the name field in the greeting message.</p><p>Looking at this code, we can immediately see we’ve got input and expected values hardcoded into our tests which a isn’t best practice from a test automation perspective. But leaving that aside, what if we wanted to verify that it also accepts and displays special characters, multiple words, and trims leading spaces (and dozens more scenarios)? We could write individual tests for each of these cases, but it’s going to get very repetitive and boring, pretty fast. Instead, we can create a helper function which will execute our test for every scenario whilst making the relevant data available to our test code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b466cb00abc078bbdd229d52e7e8309/href">https://medium.com/media/5b466cb00abc078bbdd229d52e7e8309/href</a></iframe><p>Now when we wrap our tests in this helper, our test will be passed the data for the current scenario, as well as the current iteration number for us to use in our test description. To save ourselves some time, we will make our helper globally (via the global object) which can done in the onPrepare method of our Protractor config file:</p><pre>// conf.js<br>// ...other config<br>onPrepare: () =&gt; {<br>  global.all = require(&#39;./all&#39;)<br>}</pre><p>That’s it! All that’s left is to whip up some data and wrap our test in our new helper function. So let’s take the following data:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c03de2019d5354844b3ebfbc8e698e6/href">https://medium.com/media/8c03de2019d5354844b3ebfbc8e698e6/href</a></iframe><p>And pass it in to our new helper in our test spec :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97dcc0840e2ce1cb3e8996929ecf1492/href">https://medium.com/media/97dcc0840e2ce1cb3e8996929ecf1492/href</a></iframe><p>Now when we run our tests, it will run 3 tests instead of 1, and our reporters will receive a test description which includes details about the current iteration, which will help when debugging any failed tests. Though this is quite a straightforward use case, in more complicated scenarios such as testing form validators where each field can have multiple validation rules and error messages (potentially in different languages), it can become a very powerful, time-saving technique.</p><h4>Closing thoughts</h4><p>When it comes to test automation, where possible you should always try and abstract your data from your test automation framework to make your tests more flexible and reusable. We’ve managed to achieve this data abstraction and test reusability in just a few lines of code, without sacrificing the readability of our test. In this example, we’re just supplying our helper with data from a JSON file, but you could very easily retrieve this data from any other source such as a database or CSV file, which would be extremely useful when testing internationalised sites and working together with non-technical team members.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3c9e2a5e4e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Site Search: A Sign of Bad Information Architecture]]></title>
            <link>https://medium.com/@nicklee1/site-search-a-sign-of-bad-information-architecture-e2bc002e01a1?source=rss-32fb6fce5f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2bc002e01a1</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[user-experience]]></category>
            <category><![CDATA[ux]]></category>
            <dc:creator><![CDATA[Nick Lee]]></dc:creator>
            <pubDate>Sun, 04 Dec 2016 09:59:37 GMT</pubDate>
            <atom:updated>2016-12-04T10:17:29.717Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jiFa2NZR3FzUBAYJIvoF0g.png" /></figure><p>Very recently a client asked me to add Google site search to their website, and my immediate reaction was “why?”</p><p>The answer I received, which indeed is what a site search feature is supposed to do, was that they want to provide an easier way for users to navigate and find content on their site, <strong>quickly</strong>. It may sound like a reasonable goal from a business perspective, but alarm bells immediately began to ring for me at this point.</p><h4>What’s the problem with a site search?</h4><p>To begin understanding the problem with site search features, we need to understand what information architecture is.</p><blockquote>Information architecture is about helping people understand their surroundings and find what they’re looking for, in the real world as well as online – The Information Architecture Institute</blockquote><p>Whenever I’m designing a site, I always consider things from my users perspective and in order to keep that focus, I always keep one, key information architecture question in the back of my mind:</p><blockquote>Does the structure and feature set of this site ultimately allow me to <strong>quickly</strong> achieve my goal(s)?</blockquote><p>Adding a site search feature to a site is analogous to saying “Can’t find what you’re looking for? No problem, search for it”. That sounds like a sensible feature, and indeed seems to contribute to the ability to answer yes to the question I pose above. However, I read that statement, and I don’t think “Problem solved”, I instead think “<strong>Why</strong> can’t the user find what they’re looking for without a search bar?” Is it the nature of the data that the site provides, or is it how that data is managed and surfaced? Answering that question will tell you if you really do need a site search, or if the structure of your site is lacking in some way.</p><p>If, for example, on the corporate site for your business which contains a relatively small amount of information (About Us, Services, etc.), you discover that users are struggling to find content they want on your site, it’s probably a big red warning sign that the information architecture of your site needs improving and you should investigate alternative ways to surface the data you’re trying to present, which in this case your company details and its offering. The site probably doesn’t have that much content on there, so if I can’t organically find my way to the content I want, it’s obviously not being surfaced correctly.</p><h4>When are site searches not just good, but essential?</h4><p>There can be many scenarios where the nature of a site and its data means that without a search bar, in 99% of cases the site just wouldn’t work, e.g. an eCommerce platform or a news site. If the core functionality of your site is based around <strong>large volumes of homogenously structured data (e.g. Tweets, news articles, products), </strong>then a site search makes perfect sense. It’s of course unrealistic, for example, to expect users to trawl through your archives of stories looking for the article they’re interested in if they have no idea about the details of the metadata which governs the location of that data in the wider dataset.</p><p>However, it is crucial to observe that in these scenarios, the nature of the content drives the need for a search bar. Users have a specific interest in mind, and they are looking to find a subset, which could be one or many items, of the much larger dataset.</p><h4>Closing thoughts</h4><p>If you’re site isn’t centred around presenting medium to large amounts of homogeneously structured data, then it’s likely that your site, if it were designed correctly, should allow your users to quickly achieve their goals without the presence of a search bar. By all means use a site search feature as a <em>temporary</em> fix to your information architecture issues, but don’t treat it as a silver bullet. Instead think of it as a duct tape solution, which eventually needs to be replaced by something more robust – a better design.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2bc002e01a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why the Repository Pattern is Often Misunderstood in the Laravel Community]]></title>
            <link>https://medium.com/@nicklee1/why-the-repository-pattern-is-often-misunderstood-in-the-laravel-community-e840780499f2?source=rss-32fb6fce5f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e840780499f2</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Nick Lee]]></dc:creator>
            <pubDate>Mon, 10 Oct 2016 21:50:05 GMT</pubDate>
            <atom:updated>2017-07-24T13:56:30.533Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jFUgnkLTahkaBWSN8SLavg.png" /></figure><p>There are countless tutorials available online explaining how to apply the Repository Pattern in your Laravel application, and you may, unfortunately, even see the pattern referenced as a ‘Laravel best practice’. The vast majority of these articles cite the benefits as being along the lines of:</p><blockquote><em>…using repositories will make our controllers a bit less verbose, more loosely coupled, and easier to read</em> —<a href="http://vegibit.com/laravel-repository-pattern/">Vegibit</a></blockquote><p>or</p><blockquote><em>…[repositories provide] flexibility when changing ORM</em> — <a href="https://mguimaraes.co/repository-pattern-on-laravel-part-2/">Mateus Guimarães</a></blockquote><p>These sound like admirable goals, but are sadly left unachieved by the tutorials which exist on the first page of a Google search on this topic. Let’s look at why this is the case and how we can fix it.</p><h4>What is the repository pattern and when should you use it?</h4><p>The Repository Pattern is key pattern in Domain Driven Design (DDD), but it can of course be applied if you’re not strictly following DDD.<strong> It is not a Laravel specific pattern. </strong>In Martin Fowler’s Patterns of Enterprise Application Architecture, the following definition of a repository is given:</p><blockquote><em>[A Repository] mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects — </em>Patterns of Enterprise Application Architecture by Martin Fowler</blockquote><p>A repository is just an intermediary that abstracts away the domain object persistence details and complexities from the other parts of your application.</p><p><em>Note: There exists several Stack Overflow questions along the lines of ORM vs Repositories. Do not confuse the concept of an ORM with a repository! They are not the same thing.</em></p><p>So now we understand what the pattern is about, we should address when to use it. Fortunately, <a href="https://msdn.microsoft.com/en-us/library/ff649690.aspx">this article by MSDN</a> gives us a list of use cases for the Repository Pattern! One of the most important of these cases, particularly in the context of the aforementioned Laravel tutorials, is when you want to centralise and encapsulate reusable data access queries which will improve the maintainability and readability of your code. When you look at common implementations of this pattern, you’ll see that many repositories end up as encapsulations of ORM query builder usage. This is where many Laravel based tutorials misunderstand the repository pattern and return the result of Eloquent queries, making their repository untrue to the definition we gave earlier.</p><h4>If my repository encapsulates and ‘hides’ my Eloquent queries from the rest of my application, surely I’ve decoupled my code from Eloquent?</h4><p>Unfortunately this supposition is invalid, and the problem probably lies in your interface definition. To illustrate this, let’s first look at the classic Blog example. You’ll often see the following repository in one form or another:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec516c7eb33e2474d02445ed554c923d/href">https://medium.com/media/ec516c7eb33e2474d02445ed554c923d/href</a></iframe><p>So whenever we want to retrieve the active posts for displaying on our web frontend, or for sending out weekly blog digests for example, we have a nice clean query that encapsulates our query logic. But if we assume this implementation satisfies the PostRepositoryInterface, any calling code that uses the NaiveEloquentPostRepository will be coupled to Eloquent, even if it type hints the PostRepositoryInterface and let’s the container resolve the specific implementation.</p><p>As proof, consider the scenario where tomorrow you decide to remove Eloquent in favour of some other ORM. What happens next? Well first you’d probably write a new repository that implements the PostRepositoryInterface, and you’d assume the rest of your application will continue to function if you’ve decoupled yourself successfully. But it won’t because your application is expecting Eloquent models rather than domain specific objects. This will most likely be demonstrated by the repository calling code accessing properties on the Eloquent objects as if they were public properties, as is the Eloquent way, rather than using getter and setter methods.</p><h4>So how do I decouple myself from Eloquent?</h4><p>If you dig around Laravel forums enough, you’ll probably see someone asking this very question and the most common answer given is</p><blockquote>Well if you want full decoupling from Eloquent, then you should probably use the toArray() method on the Eloquent collection when returning the result of your query</blockquote><p>Oh dear. The solution is definitely not to just dump the collection or model to an array. That’s just madness! Let’s not abandon Object Oriented Programming altogether every time we’re confronted with an issue otherwise things could get messy, really fast.</p><p>The solution is easy and is in fact implied in the definition of a Repository referenced earlier in this article. A repository is supposed to provide a collection-like interface for access to <strong>domain objects</strong>, therefore your interface methods should declare that they will return domain objects. Looking back at our NaiveEloquentPostRepository implementation, we would then need to map the Eloquent model(s) to domain objects using, for example, some sort of mapper class and then return these objects from the repository. That way, if you decide you want to rip out Eloquent, the rest of your application will be none the wiser since they only care about the domain objects and never see or use Eloquent models.</p><h4>Closing thoughts</h4><p>If you are returning Eloquent objects from your repositories, your application is theoretically coupled to Eloquent. But before you start thinking about creating separate domain objects and mapping between them and Eloquent models, ask yourself is it worth it? Are you really going to move away from Eloquent? I’ve only ever changed ORM once or twice and that was during very early prototyping when I felt like playing around with different technologies.</p><p>If you’re writing a tutorial, you need be clear with readers what they will get out of it. If the goal is to demonstrate how the repository pattern can provide ORM decoupling, then you need to implement it correctly. Implementing what is effectively an <strong>Eloquent Query Abstraction Layer</strong> as I like to call it, is useful but will not achieve this goal. For me, an <strong>Eloquent Query Abstraction Layer</strong> is a way of encapsulating query logic for reuse whilst retaining all the good stuff that you can do with Eloquent models (which is a lot!). It’s always important when using design patterns to understand when to use them and how they apply to the problem you’re facing. Make design patterns work for you, but understand the background of the pattern and the problem it’s trying to solve.</p><p>In my opinion, Laravel works so well out of the box with Eloquent that if you do decide you’ve fallen out of love with Eloquent at some point in the future, you’ll probably find you’ve fallen out of love with Laravel as well. Because of the way Laravel and an Active Record system like Eloquent work together, I believe the repository pattern <strong>in it’s true sense</strong> isn’t worth the effort in most Laravel applications. However, there is value in using an Eloquent Query Abstraction Layer that is described in the tutorials mentioned in the introduction of this article. It is important to remember that as a community, we need to be wary of misusing fundamental terminology and concepts as it will leave many newcomers to the Laravel world confused or frustrated.</p><p><em>On a side note, I would be interested to hear in the comments about scenarios where people have found themselves needing to switch out an ORM for an existing application!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e840780499f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Test Code Coverage Targets are a Bad Idea]]></title>
            <link>https://medium.com/@nicklee1/why-test-code-coverage-targets-are-a-bad-idea-1b9b8ef711ef?source=rss-32fb6fce5f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b9b8ef711ef</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-testing]]></category>
            <dc:creator><![CDATA[Nick Lee]]></dc:creator>
            <pubDate>Tue, 04 Oct 2016 15:01:42 GMT</pubDate>
            <atom:updated>2016-12-18T20:04:39.376Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*rlDopqay27L6NvZw0i9r1A.png" /><figcaption>Image Source: <a href="http://www.jpl.nasa.gov/blog/2013/2/ask-the-expert-is-it-too-late-to-reduce-climate-change">NASA JPL</a></figcaption></figure><p>Code coverage reports are an excellent tool available in most testing frameworks, and provide useful and actionable insights into your code. Over recent years, the emphasis on writing maintainable, well-tested code has spread far and wide, and automated testing has attained the recognition it deserves. Given the importance of testing, it is not unimaginable to find yourself in a scenario where your company superiors have decided that, in order to ensure the maintainability of the codebase for the future, any new code must have a near perfect test coverage level of 95% <em>(a level which I’ve previously had the displeasure of being forced to meet).</em> At first glance, you might think that if you have 95% coverage, you can be confident that your application is well tested…right? Wrong. <strong>Coverage does not equal quality</strong>.</p><h4>The Benefits of Code Coverage Reports</h4><p>Let’s imagine you’ve just installed a coverage plugin for your testing framework. After you run your test suite, your colourful new coverage report informs you that a particular feature has a test coverage of about 35%. Upon seeing this low percentage, you correctly assume that something is up and examine the code in question, only to find a rather dusty looking tests folder. You vaguely recall being under so much pressure to meet deadlines that you never got round to writing the tests, and in a moment of madness you proclaimed to the rest of the office, “To hell with TDD, BDD, ATDD and testing altogether, I’ll just get it done and write the rest of the tests later. As long as the build doesn’t fail it’s all good”. But as sprints passed you by, new stories arose and priorities shifted, some tests that should not have been forgotten were lost. Tests became history. History became legend. Legend became myth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*iPiXwAd-pF9KTHdfiOl3Ig.jpeg" /></figure><p>Luckily, the test coverage reports you just generated have come to the rescue and given you a nice little prompt to go back and sort out that test-anaemic code. It turns out there was a bug lurking in there, but fortunately it hadn’t been encountered by your users. You fix the bug, add the required tests and upon rerunning your test suite, you see the coverage for this functionality has jumped up to 88%. Balance is once again restored to Middle Earth.</p><p>Through this example we can see the way in which test coverage reports can be useful. By drawing attention to areas of code which <strong>may</strong> not be fully tested, test coverage reports highlight areas of your application which could be at risk of containing unforeseen bugs and/or are in a poorly maintained state. Furthermore, when running end-to-end tests, some test coverage reports can give less experienced team members insights into the execution path for a particular scenario which they are not familiar with. This can be helpful if the feature is complicated and the code has a large number of possible execution paths, (though in reality you’d hope they just go and setup debugging in their IDE properly). <em>On a related note, I like to view tests as an excellent source of documentation, accurately describing what can and can’t be done in your application, and how it should respond in a range of business scenarios. Examining the execution path when a test is ran can be really helpful when getting to grips with new code.</em></p><h4>So what’s the problem with test coverage targets?</h4><p>The goal of test coverage targets is a noble one. By striving to ensure that every line of code is tested, you theoretically reduce the likelihood of a defect going into production unnoticed until an unfortunate customer stumbles across it. However, in reality you run the risk of becoming a slave to this number and writing a whole host of pointless tests that exist for the sole purpose of meeting the minimum coverage requirement. At this point, take a step back and think about why we even write tests.</p><blockquote>Software testing is a set of processes aimed at investigating, evaluating and ascertaining the completeness and quality of computer software. Software testing ensures the compliance of a software product in relation with regulatory, business, technical, functional and user requirements — <a href="https://www.techopedia.com/definition/17681/software-testing">Techopedia</a></blockquote><p>Tests make sure our application does what it’s supposed to do, in the way it’s meant to. They help us maintain our code in the long run as we add new features, and help others understand how the application functions. By writing tests in order to meet a test coverage percentage, you shift the focus of your tests away from their true purpose.</p><p>Test coverage results should be used for indicative purposes only, highlighting issues rather than dictating what tests to write. Bad test coverage is usually a symptom of badly tested code, but good test coverage certainly does not guarantee good code.</p><p>Let’s imagine another example. Say you are aiming for 90% unit test coverage, and you’re sat on 87%. So far you haven’t been unit testing your getters and setters, and by doing so you’ll be able to reach 90%. Is it worth it? People may share different opinions on this topic, but in my view, the answer is no. Look at the following 2 methods as an example:</p><pre>public String getName()<br>{<br>    return this.name;<br>}</pre><pre>public void setName(String value)<br>{<br>     this.name = value;<br>}</pre><p>Do you really need to unit test these two methods? The likelihood is your end to end tests will hit this functionality anyways, and the functionality is so basic, and so simple, that a unit test is pointless. Sure my unit test coverage might suffer, but I won’t be losing any sleep over it. If your getters/setters are doing some crazy logic, then go ahead and unit test them, but be clear on why you’re doing it <em>(hint: it shouldn’t be for test coverage reasons)</em>. Even if you believe getters and setters should always be unit tested, the <strong>reason</strong> for holding this belief should not be based upon increasing your test coverage.</p><p>Ultimately, if someone is giving you firm test coverage targets to hit, they’ve misunderstood what software testing is about. The following quote from Martin Fowler succinctly summarises the true purpose of test coverage:</p><blockquote>Test coverage is a useful tool for finding untested parts of a codebase. Test coverage is of little use as a numeric statement of how good your tests are. — <a href="http://martinfowler.com/bliki/TestCoverage.html">Martin Fowler on Test Coverage</a></blockquote><p>Use test coverage to identify areas which you’ve missed when writing tests, but use your judgement, skills and knowledge to ensure that you’re testing the right things in the right way.</p><h4>Closing Thoughts</h4><p>Test coverage is a valuable metric if used correctly. It can offer some pretty good indications of areas of code which are lacking tests and as a result are more fragile and less maintainable. However, setting strict rules around test coverage targets, especially exceptionally high targets such as 95%, will most likely lead to a bloated test suite that doesn’t fulfil it’s purpose.</p><p><strong>Remember: A well tested codebase will have a high test coverage, but a codebase with a high test coverage isn’t always well tested.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b9b8ef711ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving the Problem of How Many Story Points to Commit to in your First Sprint]]></title>
            <link>https://medium.com/@nicklee1/solving-the-problem-of-how-many-story-points-to-commit-to-in-your-first-sprint-c255dfb93d9f?source=rss-32fb6fce5f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c255dfb93d9f</guid>
            <category><![CDATA[scrum]]></category>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Nick Lee]]></dc:creator>
            <pubDate>Fri, 30 Sep 2016 15:56:02 GMT</pubDate>
            <atom:updated>2016-10-02T12:58:53.526Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mg_DImrosWmRYYI02QBJbQ.jpeg" /><figcaption>Image Source: Anadolu Agency via Getty Images</figcaption></figure><p>A question which inevitably arises when kicking off a new agile Scrum project is “How many stories or story points should we commit to in our first sprint?” It’s all well and good relying on your team’s track record once you’ve achieved a predictable enough velocity after a number of sprints, however at the start of a Scrum project, the problem of sprint capacity planning becomes a little more tricky since you lack sufficient data to make an informed decision.</p><h4>A Few Incorrect Solutions to this Problem</h4><p>I’ve seen many misguided efforts to solve the problem of early sprint capacity planning, such as</p><blockquote>“Well a good benchmark is 50 points per person per sprint”</blockquote><blockquote>“Let’s workout roughly how many hours a point is worth, and how many hours we have as a team, then go from there”</blockquote><blockquote>“Let’s just pick anything for this initial sprint, it doesn’t matter as the first few sprints will always be way off”</blockquote><p>Let’s go through these misguided efforts one by one and understand why they’re sub-optimal solutions. The first idea of using 50 points is bordering on madness. A story point has no meaning outside of a given team. Story points are estimates of the<strong> effort required to complete a given story in the context of a particular team</strong>, often based on an initial reference story which is assigned a sensible arbitrary point value. Therefore, 50 points to Team A means absolutely nothing to Team B, and thus picking a value out of thin air simply makes no sense.</p><p>The second attempt, though not nonsensical like the first, is also inadvisable and threatens the integrity of future estimations. By allowing your team to picture a mapping between points and hours, you are setting a dangerous precedent for subsequent estimation sessions where people may continue to adopt this mindset, particularly if your team is new to agile and coming from a waterfall background. There’s nothing wrong with using time based estimates on Scrum projects, but if you say you’re going to use story points then don’t just use time estimates masquerading as points. Again, keep in mind that story points are a measure of <strong>effort, </strong>not a measure of the length time a task will take to complete. Even if you promise yourselves “we’ll just do it this once”, it’s a slippy slope to go down and sounds an awful lot like “I’ll just have one more slice of cake, and then I’ll stop”, which I can confirm from my vast experience on the subject simply doesn’t work.</p><p>The third attempt is just accepting defeat without even trying. The frequency with which I hear teams laugh heartily at the chaos when recalling the early days of their project often confuses me. I don’t believe there is anything preventing a good team from getting it right from the start. Agile places an emphasis on trust and the knowledge of team members, so try to draw on the experience of your team and trust their ability to be successful from the word go!</p><h4>The Correct Solution to the Problem</h4><p>In my experience, the most successful solution is actually one of the simplest. To arrive at a reasonable amount of points to take into your first sprint, all you have to do is start running through the stories in the backlog in descending order and ask the following question to your team</p><blockquote>“Are we confident we’ll be able complete this story as well?”</blockquote><p>Controversial though it may seem, I actually advocate forgetting the story points altogether at this point (cue cries of Heathen! and Blasphemy against the Manifesto!). Instead, just use a bit of common sense and honesty. Look at what you’ve accepted so far and ask yourselves whether you can honestly say, with a reasonable degree of confidence, that after X weeks - where X is your chosen sprint length - your team will have been able to complete the already accepted stories plus this additional story which is currently under consideration. <em>Note the use of the word confident! Don’t set yourselves up for a fall by being overzealous.</em> Once someone answers “No” with an acceptable justification, stop there and you’re done. It’s important to recognise that for this method to work, all your team members, including those who are more junior, need to feel able to exercise their freedom of speech if they have any doubts whatsoever. Also, in your first sprint planning session you should have at least completed the following pre-requisites for using this strategy:</p><ul><li>Discussed, explored and further prioritised the backlog</li><li>Chosen a ‘reference story’ and assigned it a story point value to use as a baseline for estimating other stories</li><li>Used ‘planning poker’ to estimate the effort required in terms of points for a reasonable number of stories towards the top of the backlog</li></ul><p>I really can’t stress enough the importance of putting faith in your team members and drawing on their expertise and knowledge to drive the decision making within your team.</p><h4>Closing thoughts</h4><p>I like to keep in mind a few key points at all times when my team is trying to decide what we’ll commit to early on in the project:</p><ul><li>Don’t become a slave to story points. Successful agile teams rely on the quality of their team members, especially those who can draw on their past experience to inform their future decisions.</li><li>Be conservative at first. Inevitably at the start of a project there are going to be unforeseen issues that need ironing out. Your code reviews will take longer, you’ll have to write more scaffolding and boilerplate code, your CI tooling might fall over etc. All these issues will most likely eat up more effort from your senior team members and reduce your effective capacity</li><li>Do not forget the human aspect of software engineering teams. Don’t set unachievable goals that will damage team morale — there’s no better feeling than finishing a sprint and knowing that you nailed it as a team. Getting off to a good start will set the tone for future sprints</li></ul><p>Once you’ve completed your first sprint, you’ll be on your way to understanding what your team is capable of accepting into a sprint. Even once you have an idea of your average velocity and can start basing sprint capacity on previous sprint data, it’s always valuable to take a step back and a realistic look at what you’ve committed to and consider whether it’s achievable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c255dfb93d9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prepending Your Git Commit Messages with User Story IDs]]></title>
            <link>https://medium.com/@nicklee1/prepending-your-git-commit-messages-with-user-story-ids-3bfea00eab5a?source=rss-32fb6fce5f0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bfea00eab5a</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[agile-development]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Nick Lee]]></dc:creator>
            <pubDate>Fri, 30 Sep 2016 12:01:02 GMT</pubDate>
            <atom:updated>2016-10-11T07:34:20.221Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*twY8AG0n19tk-iDURGOtyA.png" /><figcaption>Image Courtesy of git-scm.com</figcaption></figure><p>It’s always a good practice to prepend your commit messages with something meaningful. For example, it is often common when working with project management tools, such as <a href="http://t.umblr.com/redirect?z=https%3A%2F%2Fwww.atlassian.com%2Fsoftware%2Fjira&amp;t=NGVkNGRlNjU0ZWZjYmE2OTE3Yjc4ODNiZmIzNGNlNDI3YTZiN2FlNixXNHhVdW0xRw%3D%3D&amp;m=1&amp;b=t%3AGZgQ6WcHPzXT-MKNskrsRg">Jira</a>, to prepend your commits with the User Story ID that you’re are working on. It’s also pretty standard, especially if using tools like <a href="https://bitbucket.org/">BitBucket</a> and creating branches from Jira, for your feature branch name to be the User Story ID plus title of the task/story. Wouldn’t it be great if you could append the ID from Jira to your BitBucket commits (<a href="https://confluence.atlassian.com/bitbucket/processing-jira-software-issues-with-smart-commit-messages-298979931.html#ProcessingJIRASoftwareissueswithSmartCommitmessages-SmartCommitcommands">and get the benefits of Smart Commits</a>) without having to constantly memorise ticket numbers, or repeatedly run git branch to check the ticket number and branch name? Fear not, Git Hooks to the rescue.</p><p><em>Note: All teams have different standards and practices (or at least should have!) for writing commit messages so achieving a one size fits all commit message formatter is difficult, but the code in this tutorial can be very easily adapted to match your own style.</em></p><p>Let’s start off by looking at a basic commit message. A fairly common style is along the lines of</p><blockquote><strong>ABC-123 — a succinct description of work completed</strong></blockquote><p>where <strong>ABC-123</strong> is the ticket/story ID in your project management platform (e.g. Jira). This is a simple format and has the added bonus of enabling linking commits in BitBucket with stories in Jira via Smart Commits. Our goal in this tutorial is to prepend commits with this ticket number automatically.</p><p>A good practice when working with agile and feature branches is to include the ticket number in the feature branch name as it’s good for traceability. If you’re using Jira to create your feature branches, you can create branches from the UI of the ticket and it will automatically have the ticket number prepended to the branch name. For this tutorial, we’ll assume this best practice is being followed. Therefore, if our branch was named <strong>“ABC-123-some-nice-feature”</strong>, we want to extract the <strong>ABC-123</strong> segment and either prepend or append it to our commit message. This is where Git Hooks come in. Git Hooks are simply a way to trigger custom scripts when certain Version Control System (VCS) events occur and they can be found in the .git/hooks directory of your git based project.</p><h4><strong>Step 1: Create the hook file</strong></h4><p>Open up the .git/hooks directory of your project and you’ll see a handful of sample hook files for various VCS events. For our goal, we want to change the prepare-commit-msg.sample script which as the name suggests, is triggered when you make a git commit and prepare the commit message. Open this file with your favourite command-line text editor and delete all the commented out boilerplate code in there.</p><h4>Step 2: Add the code to be triggered on commit</h4><p>Copy and paste the following script in it’s place and then rename the file to prepare-commit-msg (i.e. remove the .sample).</p><pre>#!/bin/bash<br># Include any branches for which you wish to disable this script<br>if [ -z &quot;$BRANCHES_TO_SKIP&quot; ]; then<br>  BRANCHES_TO_SKIP=(master develop staging test)<br>fi</pre><pre># Get the current branch name and check if it is excluded<br>BRANCH_NAME=$(git symbolic-ref --short HEAD)<br>BRANCH_EXCLUDED=$(printf &quot;%s\n&quot; &quot;${BRANCHES_TO_SKIP[@]}&quot; | grep -c &quot;^$BRANCH_NAME$&quot;)</pre><pre># Trim it down to get the parts we&#39;re interested in<br>TRIMMED=$(echo $BRANCH_NAME | sed -e &#39;s:^\([^-]*-[^-]*\)-.*:\1:&#39; -e \<br>    &#39;y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/&#39;)</pre><pre># If it isn&#39;t excluded, preprend the trimmed branch identifier to the given message<br>if [ -n &quot;$BRANCH_NAME&quot; ] &amp;&amp;  ! [[ $BRANCH_EXCLUDED -eq 1 ]]; then<br>  sed -i.bak -e &quot;1s/^/$TRIMMED /&quot; $1<br>fi</pre><p>Now simply run git init to pick up the changes and try making a commit! You should see the ticket ID from your branch automatically prepended to your commit message.</p><h4>Going Global</h4><p>Manually adding this hook to all your projects is boring and not very DRY. Luckily, applying this globally is easily done by modifying your global git configuration to use a <a href="https://git-scm.com/docs/git-init">template</a>:</p><p>Firstly, set up a git template directory using the git config command. In this example we’re using the .git-templates folder we’ve created in our home directory:</p><pre>git config --global init.templatedir &#39;~/.git-templates&#39;</pre><p>Then create the hooks directory for global hooks in your template folder:</p><pre>mkdir -p ~/.git-templates/hooks</pre><p>Afterwards, copy your hooks into this newly created directory and ensure permissions are correctly set on the file</p><pre>chmod a+x ~/.git-templates/hooks/prepare-commit-msg</pre><p>Done! Now whenever you run git commit, it will prepend the first segments of the branch to the commit message! For existing projects, you just need to reinit the git directory (don’t worry, it won’t break anything!) by running the following in the project root directory:</p><pre>git init</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bfea00eab5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>