tag:blogger.com,1999:blog-92203892700628278182024-03-18T09:17:26.152+00:00Design, Code, ReleaseIf it was only that easyNathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.comBlogger146125tag:blogger.com,1999:blog-9220389270062827818.post-67644438230025064322018-03-15T07:00:00.000+00:002018-03-15T07:00:28.940+00:00Azure Functions: Exception while executing function...connection string is missing or emptyI've recently started to play with Azure Functions trying them in Visual Studio with C# and in Visual Studio Code with JavaScript.<br />
<br />
I've focused on the Http triggers specifically basic CRUD interactions with Azure Table storage which will become a future series of blog posts.<br />
<br />
My first attempt in C# went fairly smoothly, created a function then hit run and have Visual Studio handle starting the functions runtime which I then executed via Postman and it returned me data read from my local Azure Storage Emulator.<br />
<br />
I then tried to recreate what I'd just done using JavaScript using the V1 functions creating the function via the azure-cli template with a minor alteration to read from my existing table.<br />
<br />
<h3>
The Problem </h3>
I started the function using <span style="background-attachment: scroll; background-color: #eeeeee; background-image: none; background-position: 0% 0%; background-repeat: repeat; background-size: auto auto; border-radius: 3px; border: 1px solid rgb(234 , 236 , 239); font-size: 14px; padding: 2px 5px 3px;">func run TestGet</span> and then tried to hit it using postman only to get an error:<br />
<br />
<div style="background-attachment: scroll; background-color: #eeeeee; background-image: none; background-position: 0% 0%; background-repeat: repeat; background-size: auto auto; border-radius: 3px; border: 1px solid rgb(234 , 236 , 239); font-size: 14px; padding: 2px 5px 3px;">
Exception while executing function: Functions.TestGet -> Microsoft Azure WebJobs SDK 'MyStorageConnectionAppSetting' connection string is missing or empty.
The Microsoft Azure Storage account connection string can be set in the following ways:<br />
1. Set the connection string named 'AzureWebJobsMyStorageConnectionAppSetting' in the connectionStrings section of the .config file in the following format <add azurewebjobsmystorageconnectionappsetting="" connectionstring="\" defaultendpointsprotocol="http|https;AccountName=NAME;AccountKey=KEY\" name="\">, or </add><br />
2. Set the environment variable named 'AzureWebJobsMyStorageConnectionAppSetting', or<br />
3. Set corresponding property of JobHostConfiguration.</div>
<br />
This confused me greatly as I had used the default AzureWebJobsStorage setting exactly as I had with the C# version which had worked.<br />
<br />
Trying to Google the error message turned up next to no results and the majority of those didn't actually have any relevant infromation but <a href="https://github.com/Azure/azure-functions-core-tools/issues/89" target="_blank">this</a> GitHub issue provided the clue to the answer specifically <a href="https://github.com/Azure/azure-functions-core-tools/issues/89#issuecomment-300545542" target="_blank">this</a> comment which mention the IsEncrypted setting.<br />
<br />
What I had noticed is that when the functions runtime started up the first line in the command window was <span style="background-attachment: scroll; background-color: #eeeeee; background-image: none; background-position: 0% 0%; background-repeat: repeat; background-size: auto auto; border-radius: 3px; border: 1px solid rgb(234 , 236 , 239); font-size: 14px; padding: 2px 5px 3px;">The input is not a valid Base-64 string as it contains a non-base 64 character</span> and so I checked my IsEncrypted setting<br />
<br />
<pre style="background: #1e1e1e; color: gainsboro; font-family: "consolas"; font-size: 13;"><span style="color: #b4b4b4;">{</span>
<span style="color: #d7ba7d;">"IsEncrypted"</span><span style="color: #b4b4b4;">:</span> <span style="color: #569cd6;">true</span><span style="color: #b4b4b4;">,</span>
<span style="color: #d7ba7d;">"Values"</span><span style="color: #b4b4b4;">:</span> <span style="color: #b4b4b4;">{</span>
<span style="color: #d7ba7d;">"AzureWebJobsStorage"</span><span style="color: #b4b4b4;">:</span> <span style="color: #d69d85;">"UseDevelopmentStorage=true;"</span>
<span style="color: #b4b4b4;">}</span>
<span style="color: #b4b4b4;">}</span></pre>
<br />
and found that it was set to true and due to that when the functions runtime ran up it wouldn't use the appsettings.json/local.settings.json as it expected them to be encrypted and since it wasn't it seems it wouldn't read the settings that were there, so setting it to false allowed the runtime to read the setting<br />
<br />
<h3>
The cause</h3>
A comment on the Github issue suggested that the IsEncrypted setting should be false so to check if I had caused the issue or it had been the azure-cli I created a new folder and ran the command<br />
<span style="background-attachment: scroll; background-color: #eeeeee; background-image: none; background-position: 0% 0%; background-repeat: repeat; background-size: auto auto; border-radius: 3px; border: 1px solid rgb(234 , 236 , 239); font-size: 14px; padding: 2px 5px 3px;">func init</span> which creates the basic files needed for functions including the appsettings.json which looks like this:<br />
<br />
<pre style="background: #1e1e1e; color: gainsboro; font-family: "consolas"; font-size: 13;"><span style="color: #b4b4b4;">{</span>
<span style="color: #d7ba7d;">"IsEncrypted"</span><span style="color: #b4b4b4;">:</span> <span style="color: #569cd6;">true</span><span style="color: #b4b4b4;">,</span>
<span style="color: #d7ba7d;">"Values"</span><span style="color: #b4b4b4;">:</span> <span style="color: #b4b4b4;">{</span>
<span style="color: #d7ba7d;">"AzureWebJobsStorage"</span><span style="color: #b4b4b4;">:</span> <span style="color: #d69d85;">"UseDevelopmentStorage=true;"</span>
<span style="color: #b4b4b4;">}</span>
<span style="color: #b4b4b4;">}</span></pre>
<br />
So it would seem the azure-cli is the cause of this issue and whilst you need to ensure the values should be encrypted when deployed to production/live when working locally you need them unencrypted to be able to work.<br />
<br />
<h3>
Why didn't it happen in Visual Studio?</h3>
I wanted to know why I hadn't run into this when I was creating functions in Visual Studio so went back into VS and created a new functions project and checked what had been created in the local.settings.json:<br />
<br />
<pre style="background: #1e1e1e; color: gainsboro; font-family: "consolas"; font-size: 13;"><span style="color: #b4b4b4;">{</span>
<span style="color: #d7ba7d;">"IsEncrypted"</span><span style="color: #b4b4b4;">:</span> <span style="color: #569cd6;">false</span><span style="color: #b4b4b4;">,</span>
<span style="color: #d7ba7d;">"Values"</span><span style="color: #b4b4b4;">:</span> <span style="color: #b4b4b4;">{</span>
<span style="color: #d7ba7d;">"AzureWebJobsStorage"</span><span style="color: #b4b4b4;">:</span> <span style="color: #d69d85;">"UseDevelopmentStorage=true"</span><span style="color: #b4b4b4;">,</span>
<span style="color: #d7ba7d;">"AzureWebJobsDashboard"</span><span style="color: #b4b4b4;">:</span> <span style="color: #d69d85;">"UseDevelopmentStorage=true"</span>
<span style="color: #b4b4b4;">}</span>
<span style="color: #b4b4b4;">}</span></pre>
<br />
As you can see it sets the IsEncrypted to false which is why I never had the problem with the C# functions. As an experiment I set IsEncrypted to true and tried to run the functions and interestingly the functions runtime reported an error <span style="background-attachment: scroll; background-color: #eeeeee; background-image: none; background-position: 0% 0%; background-repeat: repeat; background-size: auto auto; border-radius: 3px; border: 1px solid rgb(234 , 236 , 239); font-size: 14px; padding: 2px 5px 3px;">Failed to decrypt settings. Encrypted settings only be edited through 'func settings add'.</span> which whilst not exactly clear does give a better phrase to search for.<br />
<br />
Hopefully if anybody else runs into this problem they'll find it easier to resolve than I did. Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-54697158949645706642018-02-12T07:00:00.000+00:002018-02-12T08:11:01.749+00:00WebApi controller - using anonymous types as return valuesOn a couple of projects I’ve worked on recently both have used anonymous objects to return data to a SPA UI as Json from WebApi controllers.<br />
<br />
Microsofts recommended return type for WebApi controller methods is <span style="font-family: "courier new" , "courier" , monospace;">IHttpActionResult</span> and they provide a variety of the helper methods to make the creation of the response easy e.g. <span style="font-family: "courier new" , "courier" , monospace;">Ok()</span>, <span style="font-family: "courier new" , "courier" , monospace;">BadRequst()</span>, etc<br />
<br />
To return an anonymous object as Json is as easy as using the <span style="font-family: "courier new" , "courier" , monospace;">Json</span> method and create the anonymous object as the parameter to the method:<br />
<br />
<pre style="background: #1e1e1e; color: gainsboro; font-family: "consolas"; font-size: 13;"><span style="color: #569cd6;">public</span> <span style="color: #b8d7a3;">IHttpActionResult</span> Get()
{
<span style="color: #569cd6;">return</span> Json(<span style="color: #569cd6;">new</span> { id <span style="color: #b4b4b4;">=</span> <span style="color: #b5cea8;">1</span> });
}</pre>
<br />
<h4>
Why do this? </h4>
There is a real advantage in using this technique as it gives you a lot of flexibility in what you return, there is no need to define different view model classes for each "shape" of data you need so it cuts down on the amount of boiler plate code needed.<br />
<br />
<h3>
Unit Testing</h3>
Not everybody writes unit tests for controller methods which return data but if you do the use of <span style="font-family: "courier new" , "courier" , monospace;">IHttpActionResult</span> as a return type makes it a little trickier than you would anticipate to be able to look at the Json returned.<br />
<br />
If you try to use the strongly typed classes (<span style="font-family: "courier new" , "courier" , monospace;">IHttpActionResult</span>, <span style="font-family: "courier new" , "courier" , monospace;">HttpContent</span>, etc) you'll most likely find yourself going down a rabbit hole trying to get to the content of the response which eventually either leads to having to use reflection to get the data or using dynamic.<br />
<br />
However, if we take a short cut and make use of dynamic straight away we can vastly simplify the code which gives us a test that looks like this:<br />
<br />
<pre style="background: #1e1e1e; color: gainsboro; font-family: "consolas"; font-size: 13;">[<span style="color: #4ec9b0;">Test</span>]
<span style="color: #569cd6;">public</span> <span style="color: #569cd6;">void</span> Should_return_id_in_reponse()
{
<span style="color: #569cd6;">var</span> target <span style="color: #b4b4b4;">=</span> <span style="color: #569cd6;">new</span> <span style="color: #4ec9b0;">DataController</span>();
<span style="color: #569cd6;">dynamic</span> response <span style="color: #b4b4b4;">=</span> target<span style="color: #b4b4b4;">.</span>Get();
<span style="color: #569cd6;">dynamic</span> content <span style="color: #b4b4b4;">=</span> response<span style="color: #b4b4b4;">.</span>Content;
<span style="color: #4ec9b0;">Assert</span><span style="color: #b4b4b4;">.</span>That(content<span style="color: #b4b4b4;">.</span>id, <span style="color: #4ec9b0;">Is</span><span style="color: #b4b4b4;">.</span>EqualTo(<span style="color: #b5cea8;">1</span>));
}</pre>
<br />
By setting the return from the controller method to dynamic we avoid the need to explicitly call ExecuteAsync and using dynamic to access the content makes it easier for us to get hold of the content without the need for any Json wrangling.<br />
<br />
At this point if you've created the test in the same assembly as the controller it will pass - success!<br />
<br />
But, if you've created your test in a separate project when you run the test you'll get an error thrown when trying to check the id in the assert:<br />
<br />
<pre style="background: #1e1e1e; color: gainsboro; font-family: Consolas; font-size: 13;">'object' does not contain a definition for 'Content'
</pre>
<br />
If you've used dynamic before chances are you'll have seen this error previously as it occurs anytime you try to access a property that it isn't able to find or access on the type that has been returned.<br />
<br />
At this point you might be scratching your head wondering why since you're able to access the content and you know exactly what should be in it, especially if you debug the test as you'll see the anonymous object created correctly.<br />
<br />
As it turns out the reason you get this error is that when c# constructs an anonymous object at runtime it creates it as an internal class and becauses its internal the project holding the tests will not be allowed to access its properties.<br />
<br />
To remedy this all you need to do is to go into the WebApi project and add an attribute to its AssemblyInfo.cs:<br />
<br />
<pre style="background: #1e1e1e; color: gainsboro; font-family: "consolas"; font-size: 13;">[<span style="color: #569cd6;">assembly</span>: <span style="color: #4ec9b0;">InternalsVisibleTo</span>(<span style="color: #d69d85;">"insert the name of your test assembly here"</span>)]
</pre>
<br />
doing this now allows your test project to see internal classes in your WebApi project, if you run the test again it will pass.<br />
<br />
<h3>
Code</h3>
A repo with code for this can be found <a href="https://github.com/NathanGloyn/Anonymous_Response" target="_blank">here</a> if you want to see it in action <br />
<br />Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-83812244863983422182016-09-12T07:00:00.000+01:002016-09-12T07:00:17.929+01:00Your agile isn’t my agile old man<p>Seems everybody and their dog are “doing agile” and they all seem to be complaining about how agile isn’t helping them, in fact for a lot of them it seems to be hindering them.</p> <p>I’ve wondered about this for a while and it wasn’t until reading Dan North’s recent post “<a href="https://dannorth.net/2016/07/04/how-to-train-your-agile/">How to train your agile</a>” that it struck me.</p> <p>I’ve been writing software for just under 20 years and when I started the way projects were managed were completely different from how a lot of people manage them now…</p> <h2>When I was young it was all fields around here</h2> <p>At the end of the 90’s delivery of software was frequently measured in years, projects often cancelled before completion and of those projects that were delivered they frequently had <em>stability</em> issues requiring lots of rework.</p> <p>This way of working was fundamentally broken and so people set out to find a better way to work.</p> <p>When they started using agile, delivering in months not years and focusing on ensuring the software worked you can see how radical the change was and this lead to a real change in how software was delivered, it gave businesses:</p> <ul> <li>Faster development <li>Better quality software <li>Working software delivered to production</li></ul> <p>All the things you still hear today associated with agile, what organisation wouldn’t want all of those things compared to what they had?</p> <h2>Whatever grandpa, that’s not how we do it nowadays</h2> <p>The expectation today is working software delivered in weeks not months or years, an “agile” process isn’t really adding anything here, it’s the norm, it certainly isn’t going to make it any faster, even though people might keep saying it will. </p> <p>Unfortunately not all environments are the same and in some “agile” is a dirty word synonymous with pointless meetings and having to work in a hamster wheel of sprints which never deliver what they were supposed to, where each sprint can become a <br>mini-death march.</p> <p>Where people are working in this way they don’t see any benefits, all they see is a broken process that they’re forced to follow because the management believe it will mean faster development, better quality, etc. If all you’ve known is this type of environment then you would most likely think agile <a href="http://gilesbowkett.blogspot.co.uk/2014/09/why-scrum-should-basically-just-die-in.html">should die in a fire</a> and for a lot of devs that have joined our community in the last 6-8 years this is their only experience of agile.</p> <p>At the other end of the scale there are people working in an environment that makes original agile look antiquated, continuous deployment multiple times a day, focused on adding value for the business, trunk based development with feature toggling, etc. These types of environment frequently, but not always, have a DevOps culture looking beyond development to see how the organisation as a whole effects what they do, and the organisation looks for ways to improve, systems thinking.</p> <h2>Where does this leave us?</h2> <p>When you take a look back at the environment that spawned agile its easy to see where the claims around faster, better quality, etc came from, at the time it was a completely different way to work. To be fair if you are still delivering multi-month/year projects using waterfall then those original claims are still likely to be true today.</p> <p>For anybody in environments that look <em>backwards</em> to most agile practices – well done! keep up the good work! Only thing I will say is stay vigilant as it can be all too easy to slip back into bad practices. </p> <p>If you are working in an “agile” environment, that is anything but agile, you may be able to change what you are doing by using the retrospectives to start conversations around the areas you believe aren’t helping and look at what you can do to change the situation, focusing on the principles rather than the practices (outcome not output, working software, etc) to attempt to improve your situation.</p> <p>There is almost always ways to improve how you are working and that should be baked into any process you follow, what is frequently missing is the will to change or even try to change.</p> <p>I firmly believe agile can help you but it does require you to participate so make sure you join in and look for ways to improve how you work, regardless of its “agile” or not.</p>Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com1tag:blogger.com,1999:blog-9220389270062827818.post-89569161169322308232016-03-30T08:00:00.000+01:002016-03-30T08:00:14.483+01:00Location of VM when using VMWare & Docker on windows<p>In my previous <a href="http://designcoderelease.blogspot.com/2016/03/docker-using-vmware-workstation-on.html">post</a> I covered how to get Docker working on windows using VMWare workstation rather than VirtualBox.</p> <p>One problem I ran into is that by default Docker will create the VM for the host OS in the users directory which usually resides on the C drive.</p> <p>I try not to have my VM’s on C as I tend to keep that for my main OS and so I wanted to find a way to move where the VM was created.</p> <p>First method I found for doing this involved me manually moving the vmdk by opening the VM in workstation after it was running, stopping Docker, moving the vmdk and editing the VM details in workstation to set it to the new location. Whilst this worked it is a complete pain and so I dropped that approach and looked for alternatives.</p> <p>I then found the <font face="Consolas">create</font> option--<font face="Consolas">storage-path</font> which allows you to specify where the VM should be created, this worked but again I didn’t want to have to specify the location every time, good for flexibility but if I forgot to use it then the VM would end up being created on the C drive.</p> <p>Then I found there is an environment variable that Docker looks for named <font face="Consolas">MACHINE_STORAGE_PATH</font> which will be used as the root folder when Docker creates the VM it will use as the Host OS.</p> <p>So on my machine I set it to F:\Docker and then Docker created all the necessary folders (cache, certs, machines) under this folder and the individual VM’s are created in machines folder.</p> <p>Remember you will need to restart your command/console window once you set the environment variable or it won’t take affect.</p>Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-59580009321487587542016-03-29T08:00:00.000+01:002016-03-29T08:00:43.265+01:00Docker using VMWare workstation on windows<p>I’ve wanted to explore Docker for a while now being on windows meant I’d need to use VirtualBox which I didn’t want to do since I already have VMWare Workstation installed.</p> <p>After a bit of a google I found that there was a driver to use VMWare with docker but no posts describing how to use it. With a bit of trial and error I got it working and thought I’d share how to do it here.</p> <h2>How to..</h2> <p>Before you start you need to be on Windows 7 or above and have VMWare workstation already installed.</p> <p>First install Docker machine for windows (you can get it from <a href="https://docs.docker.com/engine/installation/windows/">here</a>), this will install all the normal programs needed to run docker.</p> <p>Next you want to get the VMWare workstation driver from <a href="https://github.com/pecigonzalo/docker-machine-vmwareworkstation/releases">here</a>, its an exe but you don’t run it you just need to copy the driver into the folder where you installed Docker Machine (usually C:\Program Files\Docker Toolbox).</p> <p>At this point you’ll be able to run a create command which will build a Docker instance but you won’t be able to talk to the container. The reason for this is the network adapters that VirtualBox installs will stop Docker talking to the VMWare virtual machine.</p> <p>To be happy that its all working you can simply disable the network adapters and then any container you create should work. At this point you can either leave as is or uninstall VirtualBox.</p> <p>One side effect of this is that you won’t be able to use Kitematic since it only works with VirtualBox on windows.</p> <h2>Is this useful?</h2> <p>Even as I write this post I know that the <a href="https://blog.docker.com/2016/03/docker-for-mac-windows-beta/">Docker for Windows beta</a> is coming out but that only uses Hyper-V at the moment. Docker have said that you’ll still be able to use Docker Machine after Docker for Windows arrives and if you want to use VMWare that this may still be the best option for you.</p> <p><br><a style="display: none" href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=719235" rel="tag">CodeProject</a></p>Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-89523932821230202592015-08-27T07:30:00.000+01:002015-08-27T07:30:00.166+01:00NDepend V6<p>As anybody reading my blog for a while can tell you I like <a href="http://www.ndepend.com/">NDepend</a> and a new version was recently released.</p> <p><i>Disclaimer: I do <b>not </b>work for NDepend but I was lucky enough to be provided a license to use the software, my opinion in this post is my opinion and nobody else’s.</i></p> <p>My first impression of the new version is that there aren’t a huge number of new features in this release rather there has been a number of incremental changes & improvements to various parts of it.</p> <h4>What’s new and changed?</h4> <p>V6 brings with it integration for VS2015 (which V5 didn’t have) and there have been several enhancements around making the experience of using NDepend smoother – better VS integration, VS theming, high DPI support, able to work with portable class libraries etc.</p> <p>For a long time integrating NDepend into a build process on a CI server needed you to perform additional work to get it hooked up but in V6 its been made easier and there is closer integration with a few CI server technologies, TeamCity being the one I’m most interested in, where NDepend now makes it easy to integrate into the build process.</p> <p>One area NDepend has suffered with is compiler generated code, such as anonymous types, lambdas, async/await, etc. This has been tackled in V6 so instead of being told <code><>f__AnonymousType0<int,string> <font face="Arial">breaks a rule it now tries to determine if the rule is really broken or if its only due to generated code which will hopefully reduce the number of false positive rule violations.</font></code></p> <p><code><font face="Arial">Additional support has been added around tests so that NDepend can now tell you percentage of code covered by tests and the treemap has had additional colouring added to enable you visualize the code coverage over the assemblies analysed.</font></code></p> <p><strong><font size="3">My thoughts on V6</font></strong></p> <p>As I mentioned before this release feels more of an incremental change rather than a big functional change but that is to be expected with a mature product such as NDepend.</p> <p>The enhancements around VS integration, VS theming etc are something that the product needed simply to stay where it was i.e. its not a selling point per say rather what people just expect a modern application to support.</p> <p>Although the test coverage additions seem useful, in practice I find myself using the existing tools I already have to work with this so I’m not sure I’m going to use these new features all that much.</p> <p>My favourite new feature in V6 is the ability to attach NDepend to a solution using the solution user options (.suo) file rather than the solution (.sln) file. The benefit of this is that because .suo files are not normally stored in version control it means that I can use NDepend on a solution where others in my team don’t have NDepend and it doesn’t cause anybody any issues when loading the solution.</p> <h4>Should you upgrade?</h4> <p>If you’re already using NDepend V5 with VS2013, unlikely upgrade and not impacted by most of the enhancements or only use NDepend from the command line then upgrading <em>may</em> not provide much value.</p> <p>However, if you are going to be upgrading to VS 2015 and use NDepend inside of VS or in your build progress then I think you’ll want to upgrade to get the latest enhancements.</p> Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-36746392957514271062015-07-29T07:30:00.000+01:002015-07-29T07:30:03.079+01:00A day of intensive TDD training<p>Last Saturday (25/7/2015) found me in South Wimbledon attending a 1 day intensive TDD training course being run by <a href="https://twitter.com/jasongorman">Jason Gorman</a> from <a href="http://www.codemanship.co.uk/">codemanship</a>. </p> <p>Although this course is usually run over 2 days codemanship occasionally run the course as a reduced price 1 day intensive format.</p> <p>I had decided to attend because although I have been trying to do TDD for the past few years I have never had any formal training so wanted to check what I was doing was correct and see what else I could learn about TDD.</p> <h3></h3> <h4>Introduction</h4> <p>Once everybody was set up Jason told us what we could expect from the day starting from the most basic TDD techniques progressing through you use TDD to drive the design to using mocks/stubs and finally applying techniques to work out behaviour required from user stories.</p> <p>Jason pointed out that when you first start doing TDD you need to be mindful of what you are doing to ensure you are following the practices we would be doing that day as it was easy to slip into bad habits, this will mean you will be slower until you become comfortable with the various practices but you would become faster the more you did them. </p> <h4>TDD Back to the beginning</h4> <p>After the introduction Jason took us right back to basics explaining the red-green-refactor cycle and stressing that the refactor part is just as important as the test to ensure you end up with good code.</p> <p>Jason then had us pair up to write tests/code around transferring money between two bank accounts, in fact all activities during the day were done as a pair which was great as I also got to practice pairing with different people. </p> <p>Jason didn’t give us any specific guidance about how we should do this, other than write a failing test, make it pass, refactor – not forgetting to refactor tests as well.</p> <p>After you had created an object oriented way to handle the transfer Jason got us to go back to just doing it with variables and then refactor that to find and eliminate the duplication, teasing out methods where necessary and giving you insight into </p> <h5>More TDD Basics</h5> <p>After the first exercise Jason talked to us some more about the techniques you use in TDD to help drive the design of the code such as tests only having one reason to fail, always write the assertion first, triangulation, etc.</p> <p>One thing he stressed was that the idea isn’t to do no design before you code but only do enough design to inform where you start your tests (something we came back to later).</p> <p>Triangulation was something that really helps with this as Jason explained you want to be driving from a specific solution towards a more general solution, writing meaningful tests which are self explanatory using data that helps tells a story e.g. boundary values.</p> <p>Another thing that was highlighted out was writing the assertion before you write the code isn’t just to ensure you have a failing test but to make you think about what it is the code needs to do to satisfy that assertion, and the assertion should be related to helping satisfy the requirement(s).</p> <p>Armed with this new knowledge we tackled our second example of creating a Fibonacci generator.</p> <h5>Yet more TDD Basics</h5> <p>After the second exercise Jason talked to us about refining what we were doing, isolating tests, never refactor with a red test, test organisation, etc.</p> <p>Another key point here was to pay attention to the requirements so that you didn’t needlessly create tests that you had to throw away later, this tied back to writing the assertion first to make sure you are writing a test that helps satisfy the requirements.</p> <p>Jason stressed again the need to importance of maintaining the tests, this means refactoring the tests where necessary to try to ensure they are clear, easy to understand and testing what is necessary (circling round to not writing needless tests)</p> <p>We then tackled are 3rd and final exercise of the morning having to create a FizzBuzz program with with some additional requirements. If we completed the initial work Jason challenged us to rewrite the generator so that it didn’t use any conditional statements when generating the sequence i.e. if, switch or tertiary operations.</p> <h4>Test Doubles </h4> <p>The afternoon started with Jason touching on the London & Chicago schools of TDD and how the London school favoured the use of the various types of test doubles to allow testing of interaction between classes.</p> <p>After discussing the various types of double we jumped into our first example of the afternoon creating a system (in the loosest terms possible) that could tell you if you were able to book a holiday for a specific week of a specific year.</p> <h4>Pulling it together</h4> <p>When we stopped the 4th exercise Jason started talking to us about how we pull all of this together to help design a system.</p> <h5>Users & goals</h5> <p>He talked about determining requirements and how a common way to capture this information was via user stories. What was stressed though is the user story should be seen only as the starting point for a discussion, hopefully with the user, to get more details around/about the functionality needed.</p> <p>We utilized the Given…When…Then format to get this additional information with each of the then clauses becoming the requirements to be satisfied. Although this helped us gain further understanding about what was required Jason pointed out that they weren’t executable specifications, to understand specifics we needed concrete examples for each then to allow us to create tests that can satisfy them.</p> <h5>Class Responsibility Collaboration Cards</h5> <p>With this additional info could examine the stories to determine the roles, responsibilities & collaborations that we believe we need and to help us visualize the objects we used Class-Responsibility-Collaboration (CRC) cards where we have 1 card per role (object) listing its responsibilities (methods) and other objects it communicates with (collaborations).</p> <p>This helps to enable a “tell don’t ask” design where you communicate by message passing which also identifies boundaries where you can mock the interactions when you come to writing the tests.</p> <h5>Testing the design</h5> <p>We then did an exercise where in a pair we took a user story, created expanded details and added specifics then Jason took our finished work and handed it to another pair to create the CRC’s for it.</p> <p>Once everybody had completed the CRC’s Jason took one or two and showed us how we could test the design by running through the Given...when…then and seeing if the objects and interactions would successfully satisfy the criteria. </p> <h4>Finishing up</h4> <p>Jason re-iterated what he had said at the beginning that we needed to ensure we practiced the techniques we had learnt today as if we didn’t practice it was easy to slip into bad habits and asked us all to think about what we could do to practice.</p> <p>We all then went to the pub to have a drink and discuss the day a bit further.</p> <h4>My thoughts on the day</h4> <p>Firstly I can see why this is billed as an intensive course, we really didn’t stop during the day. Ideally I would have liked a little extra time doing the exercises but in general I liked the pace, it kept you focused on what you needed to do without overloading you.</p> <p>I really enjoyed the course, it reinforced my existing knowledge, highlighted areas where I have picked up bad habits and I came away having learnt more around triangulation and using CRC cards to test specifications.</p> <p>Whether you are a complete beginner or have been doing TDD for a while I’d recommend this course, I’m sure you would get a lot out of it.</p> Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com2tag:blogger.com,1999:blog-9220389270062827818.post-25942304529439367892015-07-27T07:30:00.000+01:002015-07-27T07:30:02.778+01:00Agile…..its all about the code<p>Over the last few posts I’ve talked about <a href="http://designcoderelease.blogspot.com/2015/06/agile-is.html">principles</a>, I’ve talked about <a href="http://designcoderelease.blogspot.com/2015/07/agile-culture-is-it-thing-is-it.html">culture</a> and mentioned <a href="http://designcoderelease.blogspot.com/2015/06/agile-methodologies-are-just-tools.html">methodologies</a>.</p> <p>Although I’ve touched upon development/engineering practices in most of these posts you could be forgiven in thinking that these practices are unimportant or <em>just</em> another thing you should do.</p> <p>This couldn’t be further from the truth.</p> <p>The key to achieving success with agile in software development is by implementing the various development/engineering practices. </p> <p>Without these practices “agile” just becomes a different way to organise the work, it doesn’t improve the quality of the code and it doesn’t speed up development. </p> <p>On the flip side just adopting the development/engineering practices won’t help protect the team from being bombarded with requests for work, having to chop and change between projects or working on “the wrong thing”, the other agile practices exist specifically to help the team with this allowing them to focus on getting software into the hands of the users/customers, which after all is the ultimate goal.</p> Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-1836362048629869592015-07-01T08:10:00.000+01:002015-07-01T08:10:42.324+01:00Agile Culture - is it a thing? is it important?In the last few posts I've covered a variety of aspects of agile, how the artifacts and practices associated with agile <a href="http://designcoderelease.blogspot.com/2015/06/agile-isnt.html">don't make you agile</a>, the <a href="http://designcoderelease.blogspot.com/2015/06/agile-is.html">underlying concepts</a> in a good agile team, how agile methodologies are just <a href="http://designcoderelease.blogspot.com/2015/06/agile-methodologies-are-just-tools.html">tools</a> and the <a href="http://designcoderelease.blogspot.com/2015/06/what-does-good-agile-environment-give.html">benefits</a> that you will hopefully see with a fully agile team/business.
<p>A couple of times I've mentioned agile culture but not tried to actually define it in any meaningful way or described what it is and why it is important, so this post I'm tackling just that.</p>
<h3>What is an organisations culture?</h3>
Before trying to define what an agile culture is its worthwhile defining what culture means in this context.
<br />
<p>I looked around the internet and found a few different definitions about what culture is (such as <a href="http://www.entrepreneur.com/encyclopedia/corporate-culture">here</a> and <a href="http://businessculture.org/business-culture/">here</a>) and I believe you can generalise the various definitions and say that:
<blockquote><p>Culture is the combination of the values, beliefs, practices, etc that people in a company adhere to.</p>
<p>Some of these may be explicit e.g. a mission statement and others may be implied e.g. social norms in the company.</p></blockquote>
<p>Whilst a company may have the same values and beliefs as another company, the implementation of those values, beliefs & social norms may well differ resulting in a different culture even though at their core they are based on the same things.</p>
<h3>Agile Culture</h3>
Having defined what a culture is, and understanding that every companies culture is going to be different, what values, beliefs & practices could we reasonably expect to see within an agile culture?
<br/>
<br/>
<h4>Embracing agile principles and practices</h4>
Unsurprisingly an agile culture is one that embraces agile principles but not just within development teams but throughout all aspects of the business that are involved with project/products.
<br />
<p>Not all agile practices are appropriate for people outside of the development team e.g. TDD, but practices such as <a href="http://www.extremeprogramming.org/rules/overtime.html">sustainable pace</a>, <a href="https://en.wikipedia.org/wiki/Value_stream_mapping">value stream mapping</a>, limited work in progress, transparency, etc are suitable across the business so everybody can benefit from using them.</p>
<h4>Focus on delivery</h4>
One of the tenets of agile is "stop starting and start finishing" it is about delivering and people in an agile culture do just that across the business in relation to whatever work they perform.
<br />
<br />
<h4>Value of a piece of work is understood</h4>
Agile talks a lot about value (I wrote a <a href="http://designcoderelease.blogspot.com/2014/01/value.html">post</a> about this a while back) and wanting to focus on delivering value for the business. In an agile culture this idea is understood across the organization which can make decisions about prioritisation and delivery easier since when people have to make a decision they do so with the common understanding of the value that they believe a piece of work will provide for the business.
<br />
<br />
<h4>Actively seeks feedback</h4>
How do people know if what they are delivering is the right thing? they seek feedback.
<p>When it comes to feedback a development team is spoilt by all the different forms of feedback they have available to them - unit tests, continuous integration, product owner/champion, users, etc. For other parts of the business the form and type of feedback will depend on what is being delivered, and who it is delivered to, but that doesn't stop them seeking feedback be it from a person, team, department or company.</p>
<h4>Learning</h4>
Many organisations want to promote a <a href="https://en.wikipedia.org/wiki/Learning_organization">culture of learning</a> due to the benefits that it brings, an agile culture has an advantage with the feedback mechanisms providing information about what is delivered and what may need improving.
<p>The other advantage is that agile methodologies have built in practices such as "Inspect & Adapt" from Scrum or "Continuous Improvement" in Kanban which actively encourage teams to look at what they are doing to enable them to improve how they work.</p>
<p>Good companies don't just stop at looking to improve processes but also encourage individuals to learn, understanding that if people learn they bring that knowledge into the organization and the business ultimately benefits from that.</p>
<h3>Do companies with an agile culture actually exist?</h3>
So is this an actual thing? When people hear this description they frequently comment that this "sounds great in theory, doesn't work in practice" or they say it seems like an agile nirvana or fantasy, and I understand that for a lot of people it seems that this way of working is a million miles away from how their own businesses work day-to-day.
<p>Probably the most well known company that you could point to as appearing to works this way is Spotify (checkout these blog posts for more detail <a href="https://labs.spotify.com/2014/03/27/spotify-engineering-culture-part-1/">Part 1</a> and <a href="https://labs.spotify.com/2014/09/20/spotify-engineering-culture-part-2/">Part 2</a>).</p>
<p>I have myself worked for companies that came very close to what I have described, they may not have implemented everything I've outlined but they focused on ensuring the team could build & deliver the software without putting any unnecessary roadblocks in the way.</p>
<h3>Is this important?</h3>
I believe that working this way is very important, it helps companies understand that although the development team are the people producing the software they are only one part of a larger process which involves everybody upstream & downstream of the developers; companies need to understand that this larger process is what generates the companies income and the true cost of any project/product is related to everybody involved in the process, rather than just one part of it.
<p>More explicit knowledge of how the various parts of an organisation interact helps to identify where any bottle necks exist slowing the delivery down, allowing a company to focus on the problem area rather than just presuming they know which part is causing the problem, often incorrectly.</p>
<p>Possibly the biggest advantage is having people in an organisation understand the larger process, it may not change the work that they do day-to-day but it can mean they understand their impact on other peoples work in the company, plus they are able to weigh decisions they need to make based on feedback received, perceived value and what needs to be delivered, rather than simply "doing what they are told to do" people hopefully become engaged, active participants rather than <a href="https://en.wikipedia.org/wiki/Sheeple">sheeple</a>.
Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-2149712754451516992015-06-25T08:52:00.001+01:002015-06-25T08:52:23.114+01:00Agile methodologies are just tools<p>Agile methodologies (XP, Scrum, Kanban, DSDM, Crystal, etc) are for the most part made of really simple tools, so simple in fact that anybody could be told about them and start using them almost immediately</p>
<p>However, in my post <a href="http://designcoderelease.blogspot.com/2015/06/agile-isnt.html">agile isn't</a> I said
<blockquote><i>even if you are doing everything a methodology says you should do doesn't necessarily make you agile. </i></blockquote>
<p>I said this because the various methodologies are really just a bunch of tools designed to help you with your work, but tools alone won't make you agile.</p>
<h2>A comparision</h2>
<p>I have a friend who is a master carpenter, his toolbox contains many of the tools I have in my garage, and whilst I can use my tools my results are never as good as his. The reason for this is he has years of experience and a passion for working with wood, not only can he pick the best tool for the task at hand but understands how best to use that tool to get the result he wants. Combine this with his knowledge of wood, techniques for working with wood (joints, cuts, etc) and he will always be better at working with wood than I am.</p>
<p>I could practice with my tools and gain insight into how best to use them and which one to chose but it wouldn't make me a master carpenter, for that I also need the other knowledge my friend has about wood and techniques for working with wood.</p>
<p>Could I learn this? of course but from seeing my friend work and talking to him I can see its not something you learn out of a book, you do it by practice and feedback from more experienced people.</p>
<h2>How's this relate to agile then?</h2>
<p>As I mentioned before agile methodologies are made up of what are really simple practices and people read books, blogs or attend a 2 day course and belive that they understand how to use these practices.</p>
<p>However, this is no different to me having a bunch of tools in my garage, I know what they are and I have a basic idea of how to use them but I'm not going to get the best results.</p>
<p>This brings me back to my quote from my earlier post, unfortunately a lot of <i>agile implementations</i> out there are done by people who only have the tools they have no passion for it and haven't tried to learn more about not only the practices they follow but agile itself, leading to some of the nightmares you hear about agile in the work place.</p>
<p>It takes time, experience and practice to take these simple tools and understand how best to use them to get the most out of them, you need to spend time listening to other experienced practioners, talking to them, asking questions, etc.</p>
<p>Although my post <a href="http://designcoderelease.blogspot.co.uk/2015/06/agile-is.html">Agile is...</a> outlines some of the concepts underlying agile, at its heart its about people and tools will only help they won't do the work for you.</p>Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-31875789616820578322015-06-05T09:10:00.000+01:002015-06-05T09:10:36.674+01:00What does a good agile environment give you?In my last <a href="http://designcoderelease.blogspot.co.uk/2015/06/agile-is.html">post</a> I talked about what made a good agile environment and the <a href="http://designcoderelease.blogspot.com/2015/06/agile-isnt.html">post</a> before that I mentioned practices that people often mistake for being agile.
<p>When you put the concepts and practices together the result should be an agile environment with everybody aligned towards the same goal</p>
<br />
<h2>Trust</h2>
One of the biggest gains that you get in a good agile implementation is the increase in trust between the organisation and the team.
<p>Historically projects have failed and organisations have lost trust in teams to deliver so they then started implementing tighter project management in an attempt to ensure projects succeed, which frequently leads to more project failures.</p>
<p>The trust can be restored with the team increasing communication with the rest of the organisation by being transparent with the work (tracking work on a card board, charts showing progress, meetings, etc) and through collaborating with the rest of the organisation about work being done and the work to be done.</p>
<p>If the team is trusted to deliver the focus moves from when something will be completed to <b>what</b> is to be completed and how soon it is needed.</p>
<br />
<h2>Value</h2>
Frequently work is prioritized based on a vague idea of what the business thinks is best for the product but often without any context of how simple or complicated a feature will be, collaborating with the team can feed in to discussions around the cost of developing that feature versus the benefit the business anticipates it will get from it.
<p>Value itself is a tricky thing to pin down: is it about money, cost, user experience? Recently there have been some posts (notiable <a href="https://www.linkedin.com/pulse/agile-value-delivery-beyond-numbers-larry-cooper">this</a> post and <a href="http://www.blueprintsys.com/delivering-business-value-with-your-it-project-how-to-define-value/">this</a> post) discussing value and showing that it is a very nuanced area.</p>
<p>The good thing about this is value will need to be considered and discussed amongst everybody involved across the business so that everybody understands value around the work being done it can help them with making decisions themselves as to priority of the work.</p>
<br />
<h2>Speed</h2>
One reason that organisations want to adopt agile is because they are under the impression that it will speed up development, they are then disappointed when following a methodology the work isn’t being done any faster.
<p>The potential increase in speed, and it is only potential, comes about mainly because with better engineering practices, building the features that are of most value and focusing on creating working software the business ends up being able to use/sell the software in days/weeks rather than months/years.</p>
<p>The people aren't actually creating the work any faster than they were before it is just that they are having to do less rework which means the software is available to the end users sooner, and there should be less defects meaning less time needing to be spent on support all of which combines to allow more time to be spent developing the product in the first place.</p>
<br />
<h2>Flow</h2>
Good agile implementations don't restrict themselves to looking at the team creating the work, they look at the organisation as a whole and work out everything that is involved in creating a product, how the work flows through the business.
<p>Once you start seeing the team as only part of the overall flow it may become apparent that there are both upstream and downstream activies which are causing problems for the organisation and it is these areas that need to be tackled to improve rather than just focusing on the team.</p>
<p>A side effect of this can be to question the need for estimates, if you have a team that is reliably deliverying work and is only 1 part of a bigger process what value does the business get from estimates from the team? This isn't to say the business isn't going to want estimates but it is understanding the value of that estimate in context to the larger organisation versus the value from the thing they want to create.</p>
<br />
<h2>Summary</h2>
Creating an agile environment is hard, you can take a team and implement an agile methodology but that is only a small part of the story. Done right agile will involve a lot of the organisation (if not all of it), it changes the way people in the business look at the work and focuses them on what is being produced and the part everyone has to play in getting that work done.
<p>More than that though it can prompt people to look more deeply into various aspects of running the team/organisation such as value, reward, motivation and learning to name a few.</p>
<p>Hopefully these posts have given you an idea of what agile actually looks like rather than the perception that it is a methodology or just a few meetings, charts and user stories.</p>
<br />
Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com6tag:blogger.com,1999:blog-9220389270062827818.post-14960620600461342272015-06-03T08:56:00.000+01:002015-06-03T08:56:48.345+01:00Agile is...My last <a href="http://designcoderelease.blogspot.com/2015/06/agile-isnt.html">post</a> covered a lot of things that people associate with agile and how just doing those things don't make you agile, this time I'm going to cover things that good agile implementations tend to display.
<br />
<br />
<h2>Communication</h2>
The keystone of all good agile implementations is good communication.
<p>The last post listed meetings & visual work tracking which are are all ways to communicate but what is key is that an agile team doesn't restrict themselves to just these methods, they will communicate whenever they need and not restrict themselves to "set" meetings.</p>
<p>For me agile revolves around communication - communication between members of the team, the team and the larger business, the business and the customer, etc. From communicatin we get </p>
<br />
<h2>Collaboration</h2>
Another key part of a good agile implementation is collaboration, it forms the basis for working in the team and for the team working with the customer/business.
<p>I mentioned capturing user stories as requirements in the last post, these should involve collaboration between the customer/product owner/product champion and the team. The team shouldn't be separate from these discussions it should be a part of them able to provide not only technical insight but frequently a different view on the product as the team has unique domain knowledge from working on the "product".</p>
<p>If there is no collaboration then people tend to fall into silo's & lose the view of the whole product as well as fostering the mindset "it's not my area/problem/issue/job".</p>
<br />
<h2>Cooperation</h2>
Whilst collaboration is about working with other people toward a single goal,cooperation is about working with others towards your own goals. Think about this. In a team everybody is doing their own work to pursue the larger goal that the team is working towards, but an agile team co-operate understanding that everybody needs to complete their work for the team as a whole to succeed.
<p>What does this mean in practice? An example isif one team member finishes their work and can see other people still working on theirs they offer to help them complete existing work before starting anything new.</p>
<br />
<h2>Control</h2>
For a long time developers were told what they had to work on, when they should work on it and often how long it should take them to complete it, they had no influence over what they did or when.
<p>Agile turns this on its head, collaborating with the business the team should be involved in all aspects of the work from generating user stories, prioritising the work, developing, testing, etc.</p>
<p>This apparent reversal of traditional control is done to allow the team to be able to make decisions quickly, rearrange the work based on changing circumstances/priorities to enable them to deliver the work.</p>
<br />
<h2>Commitment</h2>
Work needs to be completed & users using it for it to be of any value to the business, people working in an agile environment understand this.
<p>Don't confuse this with the team committing to complete work in a sprint from the older Scrum guides, this is the business being able to <i>trust</i> the team to complete the work, this doesn't mean working ridiculous hours to finish by the end of an iteration(although the team may decide to do that), it is knowing that when a piece of work is started (barring any changes in priority or direction) the work will be completed and delivered.</p>
<br />
<h2>Adaption</h2>
Agile isn't static, when you first start you may have a framework that you work within but as a team becomes more experienced they use techniques like retrospectives to determine how they can improve what they are doing.
<p>Should you wait till a retrospective to make a change? No. Just like you shouldn't wait until a meeting to talk to other people there is no reason why you can't make changes to the process outside the retrospective.</p>
<br />
<h2>Summary</h2>
People will often point to the <a href="http://www.agilemanifesto.org/">agile manifesto</a> and say "that's agile" but it doesn't tell the whole story, other people will point to the <a href="http://www.agilemanifesto.org/principles.html">agile principles</a> which provide more examples of how an agile team should work but still can't convery the subtleties of working in an agile environment.
<p>Underlying both the manifesto and the principles are the concepts I've outlined above, regardless of if you are practicing an agile methodology or not, you can tell if a team/organisation is agile by observing them and seeing if their culture embodies the concepts listed here.</p>
<p>In my next post I'm going to go into how some of the benefits of being agile, often listed as reasons to go agile, are in fact side-effects of having the right culture and mindset based on these concepts combined with the practices from my last post</p>
Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com4tag:blogger.com,1999:blog-9220389270062827818.post-3627467690970635822015-06-01T08:59:00.000+01:002015-06-01T10:06:04.102+01:00Agile isn't...<h2>
Meetings</h2>
Various agile methodologies outline specific meetings but holding these meetings doesn't make you agile
<br />
<br />
<h2>
Capturing requirements as user stories</h2>
You aren't writing large requirements documents, you're capturing the details using a form of "As a <user> I want/need <functionality> so that <desired result>
This is a good way to focus on functionality that you need for the system (it does have its pitfalls and nuances) but doesn't make you agile
<br />
<br />
<h2>
Visually tracking work</h2>
Having a board that shows progress of work is really good to help people understand what the team is currently doing and what they've done, similarly charts summarising progress can help people understand trends but doing this doesn't make you agile.
<br />
<br />
<h2>
Engineering practice's</h2>
Your team practice TDD, pair programming, continuous integration/delivery/deployment, that's awesome and will help you a lot in your day to day work. These practices aren't restricted to agile working so this doesn't make you agile either.
<br />
<br />
<h2>Following an agile methodology</h2>
I can hear people say "we do all that, and we have people dedicated to ensuring we follow the process etc" and I would not doubt you but from experience I can still say that even if you are doing everything a methodology says you should do doesn't necessarily make you agile.
<br />
<br />
<h2>So what <i><b>is</b></i> agile?</h2>
The items listed above all have value in them and I wouldn't suggest you stop if you're doing them already. Just don't think that by doing those you are <i>agile</i>.
<p>In my next post I'll detail what things are common to successful agile implementations that I have seen.</p>
Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com1tag:blogger.com,1999:blog-9220389270062827818.post-43440949601712554242015-03-30T08:17:00.000+01:002015-03-30T08:17:16.067+01:00Emailing support<p>A while back I was working with a colleague and we ran into an issue that required us to email a company for support.</p> <p>My colleague expressed an interest in how I went about structuring the email and asked if I could write up my process for them, hence this blog post.</p> <h3>Structure</h3> <p>The way I structure any of my mails, to support or otherwise, is along the lines of:</p> <ul> <li>Explaining reason for the email</li> <li>Provide any information I may have on subject</li> <li>If asking for something clearly state what I need/would like</li></ul> <p>In addition if I am able to provide anything to help, such as test project with failing tests, they should be attached or easily accessed.</p> <p>One of the additional things that I take into account when writing an email for support is thinking “what would I need to help</p> <h4>Example</h4> <p>Below is an example email written about a problem with a fictitious component aBxZ:</p> <p>Hi Support,</p> <p>Here at MadeUpCompany.com we are using your aBxZ component and are concerned about the number of duplicate calls it is making to the 123.com api and can see no way to stop this.</p> <p>We have been using Fiddler to profile aBxZ’s behaviour on our QA environment whilst testing with a similar load to our production environment and have attached the data we captured.</p> <p>If you look at the captured sessions you’ll see that aBxZ makes a call to 123.com for every request, this is happening even when we don’t call aBxZ explicitly.</p> <p>We read the documentation and ensured that we have followed the instructions and guidance on how to use aBxZ and we posted on StackOverflow about it but nobody was able to provide a solution.</p> <p>We managed to replicate the behaviour in a test project, which is attached, and it appears to be happening when aBxZ is instantiated.</p> <p>Please can you let us know:</p> <ol> <li>Are we using the component correctly?</li> <li>If using it correctly is there anything we can do to stop this?</li> <li>If it is a bug with aBxZ when you think you might have a patch/fix</li></ol> <p>If we should be doing something different to what we do currently please could you alter the attached test project and send it back to us.</p> <p>Looking forward to your reply</p> <h3>Analysis of the email</h3> <p>Looking at the mail it follows my structure and breaks down like this:</p> <ul> <li>Paragraph 1, say who we are and what the problem is</li> <li>Paragraphs 2 – 5 provide details about what has been tried and provide to them additional information in form of captured fiddler sessions and a test project</li> <li>Paragraphs 6 & 7 ask, hopefully as clearly as possible, for help to resolve the issue.</li></ul> <h3>Summary</h3> <p>Hopefully this is of use to you, for me it seems to be very clear but I’d be interested to hear from other people how they structure their emails and if you think I’m missed something out.</p> Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-45148755846713556492015-03-26T08:14:00.000+00:002015-03-26T08:14:22.672+00:00Simple.Data Asp.Net Identity Provider<p><a href="http://www.asp.net/identity" target="_blank">ASP.Net Identity</a> is Microsoft's latest implementation of a membership and identity service which will replace ASP.Net Membership, SimpleMembership and Universal Membership.</p> <p>The out of the box implementation of <a href="http://www.asp.net/identity" target="_blank">ASP.Net Identity</a> is, unsurprisingly, coupled to <a href="http://www.asp.net/entity-framework" target="_blank">Entity Framework (EF)</a> which means if you do want to use the new identity functionality but your app doesn’t use EF for data access you either end up having to include it in your project anyway or not use Identity.</p> <h3>Simple.Data</h3> <p>On a project I was part of towards the end of last year we ran into this exact problem, we were using <a href="https://github.com/markrendle/Simple.Data" target="_blank">Simple.Data</a> for data access but wanted to use the new features of Identity.</p> <p>One of the advantages of identity over previous membership implementations is that it is possible to provide a different data access layer allowing you to use the database you want but keep the rest of the functionality provided by identity e.g. password encryption, OAuth, etc</p> <p>The advantage of using Simple.Data is that you aren’t limited to connecting to any one database as you simply include the relevant provider for the database you want to use (if it is supported).</p> <h3>The Provider</h3> <p>The result is a Simple.Data provider for ASP.Net Identity which should be able to dropped into an existing application using EF with little to no change.</p> <p>You can install it from Nuget using the package manager console with the following command:</p> <p><font style="background-color: #000000" color="#ffffff">PM> Install-Package Simple.Data.AspNet.Identity </font></p> <p>If you prefer to use the “Manage Nuget Packages” GUI it is easiest to search for Simple.Data:</p> <p><a href="http://lh5.ggpht.com/-p2zRWAJv7iI/VRO_UUqAscI/AAAAAAAAAXM/N9ziY6Z7dBg/s1600-h/image7.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4z96kKH-kWw2c-FwODw3nc9_91oT9mVPj8kgLFgmcrcspGuvCiRAYO-tPHP4BRDi9gtQFqAkwQrQc1N5UJ_Ym4HGZWiVB84sroODMOV-69D4umKL3zhTWmJm8OQO1Us2gYI3eacGsJT0/?imgmax=800" width="465" height="296"></a></p> <p>If you want to just look at the code or feel like building it from code yourself the repo on GitHub can be found <a href="https://github.com/NathanGloyn/Simple.Data.AspNet.Identity" target="_blank">here</a>.</p> <h3>Limitations</h3> <p>There are a few limitations with this implementation that its worth knowing about:</p> <ul> <li>Due to ASP.Net Identity being designed around generics you must use concrete classes with it, you cannot use dynamic. To help the provider comes with 2 classes IdentityUser and IdentityRole classes for you to use. <li>Database tables – currently you need to use database tables that match the IdentityUser and IdentityRole classes although they don’t have to be named the same. The Nuget package includes a script for Sql Server to create these tables. <li>Relies on referential integrity – when deleting data ASP.Net Provider does delete any data that may be effected, instead it relies on db referential integrity to clean up linked records. <li>Ids stored as strings – although ids for users, roles, etc are generated as Guids they are stored as strings, this mimics the standard EF model. <li>No IQueryable support – Simple.Data doesn’t support IQueryable this means that the Users property on UserStore and Roles property on RoleStore will throw not implemented exceptions. If you need to query Users and Roles you need to do that yourself <li>Only works with Simple.Data v1 – a version is coming for Simple.Data v2 (which supports async await) but this is still a work in progress. <li>Db Connection – the provider supports using Simple.Data default connection or a named connection, it currently doesn’t support taking a connection string directly.</li></ul> <p>Although you need to use the identity classes in the provider you can inherit from them just like the EF code.</p> <h3>Samples</h3> <p>To try and make it as easy as possible to get started with this provider I have built 2 sample applications based off of the normal MVC project template:</p> <ol> <li>MVC 5 Standard Sample – this is the standard MVC project template the only change is that it uses Simple.Data for data access.<br> <li>MVC 5 Sample – this sample is an extension of the standard sample as it includes using roles with identity to be able to control access to pages of your web application</li></ol> <p>The easiest way to work with these samples is:</p> <ol> <li>Create new ASP.Net Web application <li>Select the Empty project template <li>Once the project has been created add the appropriate Nuget package</li></ol> <p>If you want the standard sample then at the package manager console type:<br><br><font style="background-color: #000000" color="#ffffff">PM > Install-Package Simple.Data.AspNet.Identity.MVC5.Standard.Sample </font></p> <p>Or if you want the sample that includes roles:</p> <p><font style="background-color: #000000" color="#ffffff">PM> Install-Package Simple.Data.AspNet.Identity.MVC5.Sample </font></p> <p>When you install these packages you will have all the necessary classes and references added to your project <strong>and</strong> it will create a database in localDb so you should be able to build and run the code to start working with it immediately.</p> <p>Both sample projects are in one repo which you can find <a href="https://github.com/NathanGloyn/Simple.Data.AspNet.Identity.Sample" target="_blank">here</a> if you wish to play with the code that creates the samples although installing the Nuget package is by far the easiest way to get working with the code.</p> <h3>The future</h3> <p>This version is 1.0.0, it is stable and should work without problems (taking limitations mentioned into account).</p> <p>Going forward there are several improvements that I intend to make:</p> <ul> <li>Simple.Data v2 – complete work on this implementation <li>Support connection strings – to match normal Simple.Data connection options add the ability to be passed a connection string. <li>Support different id variable types – normal ASP.Net Identity allows for different variable types for ids via more generics, I’m looking to add this in. <li>Automated builds – looking to use AppVeyor to build and test the code <li>Automate Nuget publishing – once AppVeyor is building the code look to automate generation and publishing of the Nuget packages <li>More samples – add samples showing use of the provider in different ways e.g. not tied to Owin context</li></ul> <h3>Summary</h3> <p>This provider should make it easy for people that wish to use ASP.Net Identity with Simple.Data right now.</p> <p>With the planned future improvements the additional functionality will bring it up to parity with the full EF model.</p> <p><br><a style="display: none" href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=719235" rel="tag">CodeProject</a></p> Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-25635957611800403142015-02-24T08:28:00.001+00:002015-02-24T08:28:29.375+00:00Node School–Bristol<p>Last Saturday I got to attend the first <a href="http://nodeschool.io/">NodeSchool</a> to be held in Bristol.</p> <p>The event was held at the <a href="http://www.mixrad.io/gb/en/welcome/">MixRadio</a> offices in the heart of Bristol who were sponsoring the day by hosting the event, the room was at the top of their building looking out over Bristol which was brilliant.</p> <h4>The Day</h4> <p>I, like most attendees, started arriving about 9:15 finding somewhere to sit and getting their laptop ready.</p> <p>Just after 10 the event began with an introduction telling us all about the day, what we could expect, how to get help and thanks to the sponsors that had made the day possible.</p> <p>The format for the day was to follow the tutorials in the learnyounode workshop from NodeSchool (which you can install using npm install –g learnyounode) the difference being that instead of having to do it on your own, and try and complete the exercises simply by Googling for solutions, there were “mentors” on hand to help if you got stuck. The mentors were volunteers who had experience with node and could help solve the exercises in the workshop.</p> <p>The original timetable for the day had attendees having a break at 11 but most people were heads down working on the exercises with mentors helping out as required.</p> <p>Lunch was supplied by JustEat, who were also sponsoring the event, who provided some awesome pizza for everyone to eat.</p> <p>After lunch there was a short update on what the plan was for the afternoon and other tutorials that you could look at before we carried on with the exercises.</p> <p>At 4:30 we stopped for a talk from Adam Butler on “<a href="http://slides.com/adambutler/5-th#/">5 Things to build with NodeJS</a>” the highlight of which was Adam flying a couple of different drones using node.</p> <p>After the event there people went for drinks at Big Chill which unfortunately I wasn’t able to attend.</p> <h4>The workshop/exercises</h4> <p>The learnyounode workshop code is structured into a series of exercises that take you from “Hello World!” through multiple async http calls to creating your own http server.</p> <p>Everything is done at the command line with learnyounode providing a list of all the exercises and marking each as completed when you successfully complete an exercise. </p> <p>When you start an exercise you get told what it is you need to do and then get a “Hint” giving you more information about how to accomplish what it is you need to do, once you’ve written your solution you verify its correct using the learnyounode inbuilt test harness. </p> <p>If your code doesn’t pass the test you get test failure output showing what was expected and if you pass you get shown the “official” solution to the problem.</p> <h4>My Day</h4> <p>During the day I managed to complete the entire workshop, which was the intention for everybody.</p> <p>I also managed to complete the Express workshop, ExpressWorks, and what was interesting (to me at least) was how noticeably easier it was to use node with a framework like express after having had to code at the lower level for most of the day. </p> <h4>Summary</h4> <p>It was a really good day in a fantastic venue, we were fed watered and looked after really well throughout the day, I must give a big thanks to <a href="https://twitter.com/kdurrani" target="_blank">Katja</a> ,<a href="http://www.meetup.com/NodeSchool-Bristol/members/135699832/" target="_blank">Tristan</a>, <a href="http://www.meetup.com/NodeSchool-Bristol/members/15871821/" target="_blank">Tom</a> & <a href="http://www.meetup.com/NodeSchool-Bristol/members/34698762/" target="_blank">Adam</a> for organising the day.</p> <p>Although I wouldn’t say I’m now a proficient node developer I feel I have a much better idea of how node works and also through doing the Express workshop can see how easy it would be to put together an application on node.</p> <p>I know that they are planning future events and I would recommend attending one if you want to explore the world of node but were unsure where to start.</p> Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-32427311688188517302015-01-09T09:00:00.000+00:002015-01-09T09:00:01.264+00:002014 in review<p>Just like previous years I’m blogging a little review/retrospective on what I got up to last year, what goals (if any) I managed to achieve and what plans I have for the year ahead.</p> <h3>2014 Goals</h3> <p>As I did so badly in 2013 with my goals I changed tack for 2014 with only 3 main goals:</p> <ul> <li>JavaScript/SPA</li> <li>Code</li> <li>Blog</li></ul> <a name='more'></a> <h4>How did I do?</h4> <p><u>JavaScript/SPA</u></p> <p>I did more JavaScript than SPA work last year I just didn’t blog much about it.</p> <p>I spent a fair amount of time at the beginning of the year looking at UI testing with JS & Node and started writing my own Node “server” mid way through the year.</p> <p>I have also started creating a talk on noBackend with JS which I hope to be able to give later this year.</p> <p><u>Code</u></p> <p>Although I wrote some code I didn’t blog about it or push anything new to GitHub, I feel like I didn’t achieve as much as I wanted. </p> <p><u>Blog</u></p> <p>My goal was to blog 1 article a month which I didn’t manage, I wrote 11 articles which was a big improvement on the previous year where I only managed 4.</p> <h4>What else did I do?</h4> <h4> </h4> <h4>Job </h4> <p>2014 was busy again with work I have almost entirely worked on server side C# with almost zero HTML/CSS/JS. </p> <h4>Conferences</h4> <p>I attended the <a href="http://socratesuk.org/">Socrates UK</a> conference, overall I enjoyed it but I came away from it with mixed feelings about the value I had gained from attending. </p> <p>I did manage to attend DDD SW, DDD EA & DDD North which was great and as always very enjoyable and I came away from all 3 having learning something new and catch up with people.or</p> <h4>Community</h4> <p>Outside of attending the DDD conferences I have attended my local .Net user groups. </p> <p>One sad event this year was that .Net Developers Network closed down after running for 7 years, many thanks are due to Guy Smith-Ferrier, Chris MyHill & Andrew Edwards for organising the meetings it for all these years.</p> <p>Shortly afterwards Bristol DevNet started and has done a good job in carrying on where .Net Dev Net left off and I’ve attended every meeting so far.</p> <h4>Other things</h4> <p>As I indicated in last years post I did stop blogging on Tumblr, instead just posting to this blog.</p> <h3>Coming up in 2015</h3> <p>Thinking about the last couple of years the reason I haven’t managed to achieve everything I wanted to do is simply because I’m spending more time with my family. This isn’t a bad thing but acknowledging it and the restrictions it places on my available time to code, blog, etc is going to influence the goals that I pick.</p> <p>A while back I read a <a href="http://ejohn.org/blog/write-code-every-day/" target="_blank">post</a> from John Resig about writing code everyday even if its only 30 mins. I’m going to take this idea but whilst I’d like to manage everyday I’m not sure in reality I’d make it so instead I’m going to look to do minimum of 30 mins at least 3 days a week towards a goal.</p> <p>One other thing I noticed was I lost site of my goals during the year so I’m planning on doing my own quarterly review of how I’m doing and if necessary to change goals if I’ve found that circumstances have changed.</p> <h3>Goals</h3> <p><u>Blog</u></p> <p>I’m keeping this as a goal for this year and again looking to try and do a post a month.</p> <p><u>Code</u></p> <p>Again keeping this goal as I want to try and focus on writing code outside of work.</p> <p>I have a few ideas floating around about things to do and am currently in the middle of something specific (blog post about it hopefully before end of the month).</p> <p><u>Reading</u></p> <p>I used to use my train commute to read technical books but working from home I now don’t have the commute and have fallen out of the habit of reading technical books at home.</p> <p>I have a virtual pile of books I’ve brought over the last couple of years so I’ve plenty of material to read. I’m only going to aim at one per quarter and see if I can actually do better than that.</p> <p><u>Conferences</u></p> <p>This year I am aiming to go to NDC in Oslo, it may have to be with me as crew but I want to go to this conference as year on year I see all the fantastic content and although I’d love to give a talk at the moment I’m unsure what I could talk about.</p> <p>Having enjoyed last years conference I’m going to go to back to London JS Conf this year.</p> <p>I’m hoping there will be some DDD conferences this year, especially as it is 10 years since the first one so would be nice to see an anniversary DDD.</p> <h3>Summary</h3> <p>I did better at achieving my goals in 2014 than in 2013 but still not managed to do everything I wanted.</p> <p>I’m hoping that with my plans around time to spend on my goals I’ll manage to achieve them all this year.</p> Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-46437723940723107372014-10-31T08:00:00.001+00:002014-10-31T16:59:12.651+00:00Log Parser Lizard creating custom regex format<p>I first heard about <a href="http://www.lizard-labs.com/log_parser_lizard.aspx" target="_blank">Log Parser Lizard</a> (LPL) when Scot Hanselman <a href="http://www.hanselman.com/blog/AnalyzeYourWebServerDataAndBeEmpoweredWithLogParserAndLogParserLizardGUI.aspx">blogged</a> about it back in 2011 and since then its been part of my tool belt.</p> <p>LPL makes analysing logs easy enabling you to point it at single log file, or even a directory of files, it will parse them and then allow you to query the data using SQL syntax.</p> <p>LPL comes with a lot of predefined searches from Active Directory, IIS, event logs, etc and has the ability to allow you to define your own custom RegEx format for parsing text files.</p> <p>Recently I needed to use the custom RegEx format, its not the easiest thing to do and as I couldn’t find any examples I thought I’d write up what I did to help me, and possibly anybody else that needs to do it, in the future.</p> <a name='more'></a> <h3>Format</h3> <p>The custom format is stored in an xml file and consists of:</p> <ul> <li>Regular Expression <li>Fields for LPL to use</li></ul> <h5>Fields</h5> <p>I’m covering fields first as they’re the easy part to understand, each field is a xml element with name and data type <field name="Priority" type="Integer"/>. </p> <p>LPL will only give you columns based on the fields that you define and as I understand it the types are standard .Net types.</p> <h5>Regular Expression</h5> <p>First you need to create a RegEx that will correctly parse the line, so if a line in your text file contains a number, date and text such as:</p> <blockquote> <p><font face="Consolas">1 2014-10-31 Message text</font></p></blockquote> <p>This RegEx will parse that line:</p> <blockquote> <p><font face="Consolas">^(\d)\s(\d{4}-\d{2}-\d{2})\s(.*)$</font></p></blockquote> <p>And will give you 3 capture groups:</p> <ol> <li>The numnber: 1 <li>The date: 2014-10-31 <li>The text: Message text</li></ol> <p>In LPL is you create a RegEx Import Format query and configure it to use this RegEx it will successfully execute the query but you’ll get no results in the grid. </p> <p>The thing that I was missing and couldn’t find info on is that you have to add additional capture groups to the RegEx, wrapping the existing capture groups, to allow LPL to understand which capture group belongs to which field.</p> <p>The format for the LPL capture group is (?&lt;’Field Name’&gt;(\d)) where ‘Field Name’ is the name of the field that you want to store the value in. So our previous RegEx would be need to be altered to:</p> <blockquote> <p><font face="Consolas">^(?&lt;Number&gt;(\d))\s(?&lt;Date&gt;(\d{4}-\d{2}-\d{2}))\s(?&lt;Text&gt;(.*))$</font></p></blockquote> <h4>Sample Files</h4> <p>I’ve created a sample config and corresponding log file for the regex above which you can find <a href="https://www.dropbox.com/sh/w44s5vwcp5ataxm/AABjt44KnT23l5oZgPHmwI8Fa?dl=0">here</a> to allow you to try this out and see it working.</p> Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-39209626219222247192014-10-31T08:00:00.000+00:002014-10-31T17:00:19.468+00:00Log Parser Lizard creating custom regex format<p>I first heard about <a href="http://www.lizard-labs.com/log_parser_lizard.aspx">Log Parser Lizard</a> (LPL) when Scot Hanselman <a href="http://www.hanselman.com/blog/AnalyzeYourWebServerDataAndBeEmpoweredWithLogParserAndLogParserLizardGUI.aspx">blogged</a> about it back in 2011 and since then its been part of my tool belt.</p> <p>LPL makes analysing logs easy enabling you to point it at single log file, or even a directory of files, it will parse them and then allow you to query the data using SQL syntax.</p> <p>LPL comes with a lot of predefined searches from Active Directory, IIS, event logs, etc and has the ability to allow you to define your own custom RegEx format for parsing text files.</p> <p>Recently I needed to use the custom RegEx format, its not the easiest thing to do and as I couldn’t find any examples I thought I’d write up what I did to help me, and possibly anybody else that needs to do it, in the future.</p> <a name='more'></a> <h3>Format</h3> <p>The custom format is stored in an xml file and consists of:</p> <ul> <li>Regular Expression <li>Fields for LPL to use</li></ul> <h5>Fields</h5> <p>I’m covering fields first as they’re the easy part to understand, each field is a xml element with name and data type <field name="Priority" type="Integer"/>. </p> <p>LPL will only give you columns based on the fields that you define and as I understand it the types are standard .Net types.</p> <h5>Regular Expression</h5> <p>First you need to create a RegEx that will correctly parse the line, so if a line in your text file contains a number, date and text such as:</p> <blockquote> <p><font face="Consolas">1 2014-10-31 Message text</font></p></blockquote> <p>This RegEx will parse that line:</p> <blockquote> <p><font face="Consolas">^(\d)\s(\d{4}-\d{2}-\d{2})\s(.*)$</font></p></blockquote> <p>And will give you 3 capture groups:</p> <ol> <li>The numnber: 1</li> <li>The date: 2014-10-31</li> <li>The text: Message text</li></ol> <p>In LPL is you create a RegEx Import Format query and configure it to use this RegEx it will successfully execute the query but you’ll get no results in the grid. </p> <p>The thing that I was missing and couldn’t find info on is that you have to add additional capture groups to the RegEx, wrapping the existing capture groups, to allow LPL to understand which capture group belongs to which field.</p> <p>The format for the LPL capture group is (?&lt;’Field Name’&gt;(\d)) where ‘Field Name’ is the name of the field that you want to store the value in. So our previous RegEx would be need to be altered to:</p> <blockquote> <p><font face="Consolas">^(?&lt;Number&gt;(\d))\s(?&lt;Date&gt;(\d{4}-\d{2}-\d{2}))\s(?&lt;Text&gt;(.*))$</font></p></blockquote> <h4>Sample Files</h4> <p>I’ve created a sample config and corresponding log file for the regex above which you can find <a href="https://www.dropbox.com/sh/w44s5vwcp5ataxm/AABjt44KnT23l5oZgPHmwI8Fa?dl=0">here</a> to allow you to try this out and see it working.</p> Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com1tag:blogger.com,1999:blog-9220389270062827818.post-42995359263892412652014-07-23T08:30:00.000+01:002014-07-24T08:39:29.814+01:00The Full Stack Developer<p>Back in 2010 Carlos Bueno wrote a blog post on <a href="https://www.facebook.com/note.php?note_id=461505383919">The Full Stack Developer</a> and since then there have been various posts that comment on it such as this <a href="http://radar.oreilly.com/2014/04/full-stack-developers.html" target="_blank">post</a> and this <a href="http://www.laurencegellert.com/2012/08/what-is-a-full-stack-developer/" target="_blank">post</a> which made the full stack developer seem an impossibility.</p> <p>I’m not sure I buy into this idea of a Full Stack Developer as somebody who can for example throw together a web site using the latest framework/library, work at the TCP protocol level and understand i/o bottlenecks in a database system with <em>any degree of mastery</em>. </p> <p>Whilst there are some extraordinary individuals out there that can manage this I doubt the majority of developers today can do so.</p> <p>We as developers have, out of necessity, become specialists in specific areas of computing.</p> <p>The rate of change, number of languages/tools/frameworks/libraries and depth of understanding required means that in general people simply don’t have the time to be able to keep up with all the changes to all the various areas of computing. </p> <a name='more'></a> <p>For me a full stack developer is most likely somebody who is able to <em>work with</em> the stack that makes up an application, so in the Microsoft world for a web application that may be angular SPA coupled with Asp.Net <whatever> and Sql Server (not just through EF).</p> <p>A developer that has a good understanding of the stack they are working with means that they can understand trade offs that may be being made in the different areas of the stack, or if you need to tune for performance where they can actually make the most difference.</p> <p>So back to the original posts I mentioned, is the “Full Stack Developer” they describe better than other developers? Most people seem to think the answer is an unequivocal yes, I on the other hand am not so sure. </p> <p>As I mentioned before the rate of change in our industry is so high that, as pointed out in <a href="http://www.nczonline.net/blog/2014/07/15/generalists-and-specialists-thoughts-on-hiring/" target="_blank">this post</a> I recently read, as the lifecycle of the app/product/service moves on you need specialists whose knowledge is specific to a single area.</p> <p>In general I sincerely believe that as a developer you should take the time to learn the stack that you work with but for the majority of developers understanding, for example, the difference between main memory i/o and disk based i/o won’t help them in day to day work. If you find that you do need that information the internet has all the resources you need to learn about it at the time you actually need it.</p> <p>I humbly suggest that if in your day to day work you are worried about relative i/o speeds between cache and main memory or if request rate and size are also a consideration you might just be working in a specialised area at which point are you still a “Full Stack Developer” or are you now a specialist?</p> Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-49142789562949969642014-07-21T08:25:00.000+01:002014-07-21T09:10:25.145+01:00Grunt & Gulp – an overview<p>Furthering my journey into JavaScript up to now I have not had much interaction with JS task/build systems so to remedy that I recently attended a <a href="http://do-less.co.uk/" target="_blank">DoLess</a> workshop on Grunt & Gulp to discover what they were all about.</p>
<p>Most often people associate both Grunt & Gulp with building systems but they are not restrict to that and both can form part of the of a front end dev’s day to day development process being able to run tests & reload html when altered, etc</p>
<a name='more'></a>
<style type="text/css">.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{ background-color: #f4f4f4; width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }
</style>
<h3>Similarities</h3>
<p>Grunt & Gulp are actually very similar:</p>
<ul>
<li>Both use Node.js to provide their functionality
<li>Installed via NPM & need both a global and project specific install
<li>Have a plugin eco-system
<li>Their configuration files are valid JavaScript
<li>Configuration consists of “Tasks”</li></ul>
<p>One other gotcha that I ran into with both Grunt & Gulp is that for them to work with a project you <strong><em>must</em></strong> have a package.json file, if you don’t have that file then when you install plugins (via NPM) even though the plugin is on disk and included in your config neither system will actually use it as it won’t be listed in the package.json.</p>
<h4>Tasks</h4>
<p>Both systems revolve around tasks, they are the building blocks used to allow you to create complex transformations by combining the simple tasks and chaining the results together.</p>
<p>Most tasks will use a plugin and the plugin eco-systems for both systems are growing all the time, providing functionality for you out of the box like minification, linting, testng, etc and if there isn’t a plugin for what you need you are able to create your own custom tasks by writing JavaScript to do whatever you need.</p>
<h4>As part of development flow</h4>
<p>Both systems are not restricted to simply being used for building they can be used as part of the development work flow.</p>
<p>One of the simplest “flows” is using a task to host the “site”, such as <a href="https://github.com/gruntjs/grunt-contrib-connect" target="_blank">connect</a>, and a <a href="https://github.com/gruntjs/grunt-contrib-watch" target="_blank">watch</a> task to look for changes which uses <a href="http://livereload.com/" target="_blank">livereload</a> to refresh the browser so you can see your changes as you make them.</p>
<h3>Differences</h3>
<h4> </h4>
<h4>Grunt</h4>
<p>Grunt stores its instructions in a GruntFile.js and although it is a valid JavaScript file for the most part it reads more like configuration rather than code:</p>
<div class="csharpcode"><pre class="alt"><span class="lnum"> 1: </span>module.exports = <span class="kwrd">function</span>(grunt) {</pre><pre><span class="lnum"> 2: </span> </pre><pre class="alt"><span class="lnum"> 3: </span> grunt.initConfig({</pre><pre><span class="lnum"> 4: </span> uglify: {</pre><pre class="alt"><span class="lnum"> 5: </span> build: {</pre><pre><span class="lnum"> 6: </span> files: {</pre><pre class="alt"><span class="lnum"> 7: </span> <span class="str">'js/app.js'</span>: [<span class="str">'js/lib/jquery.min.js'</span>, <span class="str">'js/accordion.js'</span>]</pre><pre><span class="lnum"> 8: </span> }</pre><pre class="alt"><span class="lnum"> 9: </span> }</pre><pre><span class="lnum"> 10: </span> }</pre><pre class="alt"><span class="lnum"> 11: </span> });</pre><pre><span class="lnum"> 12: </span> </pre><pre class="alt"><span class="lnum"> 13: </span> grunt.loadNpmTasks(<span class="str">'grunt-contrib-uglify'</span>);</pre><pre><span class="lnum"> 14: </span> </pre><pre class="alt"><span class="lnum"> 15: </span> grunt.registerTask(<span class="str">'default'</span>, [<span class="str">'uglify'</span>]);</pre><pre><span class="lnum"> 16: </span> </pre><pre class="alt"><span class="lnum"> 17: </span>};</pre></div>
<p>Grunt processes its tasks in a sequential manner and executes them in the order that you have specified. In the sample above the there is only one task, uglify, but you’ll notice a default task is defined this is used when you execute grunt without specifying a task.</p>
<p>You may want to run multiple tasks and can do this easily by registering a task which then executes multiple other tasks by passing a string array of task names as the second parameter to the registerTask function e.g.</p><pre class="csharpcode">grunt.registerTask(‘<span class="str">default</span>’,[‘qunit’,‘sass’,‘uglify’]); </pre>
<p>Grunt works with files which can cause a bottleneck since if a task transforms a file e.g. uglify, then the next task will not start until the resulting file has been written to disk. </p>
<p>Due to the fact that Grunt processes each task sequentially (although there is a <a href="https://github.com/sindresorhus/grunt-concurrent">plugin</a> that will allow you to run tasks concurrently with some caveats) you can build up complex flows with each item working with the output of the previous one.</p>
<p>One thing Grunt also supports is the ability to have tasks in there own separate files which can be combined together. This allows you isolate the tasks and keep the overall file size down making it easier to manage and maintain the tasks as your scripts grow and become more complex.</p>
<p>You can find more information and a larger example of a gruntfile <a href="http://gruntjs.com/sample-gruntfile" target="_blank">here</a>.</p>
<h4>Gulp</h4>
<p>Gulp stores its instructions in a GulpFile.js and it reads more like code than configuration:</p>
<div class="csharpcode"><pre class="alt"><span class="lnum"> 1: </span><span class="kwrd">var</span> gulp = require(<span class="str">'gulp'</span>);</pre><pre><span class="lnum"> 2: </span> </pre><pre class="alt"><span class="lnum"> 3: </span><span class="kwrd">var</span> uglify = require(<span class="str">'gulp-uglify'</span>);</pre><pre><span class="lnum"> 4: </span><span class="kwrd">var</span> concat = require(<span class="str">'gulp-concat'</span>);</pre><pre class="alt"><span class="lnum"> 5: </span> </pre><pre><span class="lnum"> 6: </span>gulp.task(<span class="str">'build'</span>, <span class="kwrd">function</span>() {</pre><pre class="alt"><span class="lnum"> 7: </span> <span class="kwrd">return</span> gulp</pre><pre><span class="lnum"> 8: </span> .src([<span class="str">'js/lib/jquery.min.js'</span>,<span class="str">'js/*.js'</span>])</pre><pre class="alt"><span class="lnum"> 9: </span> .pipe(concat(<span class="str">'app.js'</span>))</pre><pre><span class="lnum"> 10: </span> .pipe(uglify())</pre><pre class="alt"><span class="lnum"> 11: </span> .pipe(gulp.dest(<span class="str">'.'</span>));</pre><pre><span class="lnum"> 12: </span>});</pre><pre class="alt"><span class="lnum"> 13: </span> </pre><pre><span class="lnum"> 14: </span>gulp.task(<span class="str">'default'</span>,[<span class="str">'build'</span>]);</pre></div>
<p>Gulps main difference from Grunt, as far as I can tell, is that it works with streams which means that the contents of a file are worked on in memory and then streamed to the next task. </p>
<p>One big advantage of this is speed since nothing is written to disk until all the tasks have been completed, and if you forget to pipe to gulp.dest then it won’t even make it to disk!</p>
<p>Gulp processes its tasks asynchronously which means that if you specify multiple tasks to be run it will not guarantee the order that the tasks run in, there is a library you can download called <a href="https://github.com/OverZealous/run-sequence" target="_blank">run-sequence</a> which will execute task in a specific sequence allowing you to wrap the tasks</p>
<p>Gulps tasks look nothing like most Grunt tasks since they are JavaScript functions and the plugins themselves are simply called as a function, in the example above you can see that the input to a pipe method takes the return from the concat method which we get via require.</p>
<p>One additional thing you are able to do with Gulp is to pass other tasks as parameters, so if you need another specific task to run before the current task you pass the name in the task definition e.g.</p><pre class="csharpcode">gulp.task(<span class="str">'build'</span>,[<span class="str">'clean'</span>], function(cb) {…}</pre>
<p>In this example the clean task has to complete before the build task will run, a note of caution as currently if you pass multiple tasks you cannot guarantee the order they will execute it.</p>
<p>You can more information about Gulp and a larger gulpfile example <a href="https://github.com/gulpjs/gulp/blob/master/README.md#gulp-----" target="_blank">here</a>.</p>
<h3>Summary</h3>
<p>Both of these systems will provide you a multitude of functionality ranging from simple minification through to use in day to day development.</p>
<p>Currently Grunt feels to me slightly more mature with a bigger range of plugins available but due to its architecture it will always execute more slowly than Gulp.</p>
<p>There is a Visual Studio extension called <a href="http://visualstudiogallery.msdn.microsoft.com/dcbc5325-79ef-4b72-960e-0a51ee33a0ff" target="_blank">Grunt Launcher</a>, the name is slightly misleading as it also works with Gulp & Bower, which will allow you to launch tasks from inside Visual Studio simply by right clicking the file.</p>
<p>Hopefully this overview has given you an insight into the two tools whether you simply wanted to know what all the fuss was about or you have some understanding if you intend to pick them up and use them.</p>Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0tag:blogger.com,1999:blog-9220389270062827818.post-30445559896698551912014-05-21T08:00:00.001+01:002014-05-21T10:25:42.872+01:00Fashion<a href="http://lh6.ggpht.com/-HQxmpJVh7mE/U3vC3bIFdpI/AAAAAAAAAT0/yXr-xAQS_C0/s1600-h/fashion2.png"><img align="left" alt="fashion" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlYO2N8vcGQxfGhP1F8ku_-hN7QlhWPU6pYDSJRRmomMhWhT9oY9RaNHXMyt40aQZ9nLKYwrZoHZeKPn7YjiWWCmRIN64BPbX5zUYuPYcuaQQN19hD8XO0omQk2F9mC84eHFqzerdRH5s/?imgmax=800" height="244" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; float: left; margin: 0px 13px 0px 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="fashion" width="182" /></a>Fashions come into style and go out of style and when they’ve gone you often look at pictures of yourself and think “why on earth did I wear that”.<br />
Its no different in software development, with various tech gaining favour and becoming “fashionable” with everybody wanting to be using that tech only to find that it drops out of fashion later. It used to take years for things to become unfashionable but with the rate of change increasing this may drop to a few months or even weeks.<br />
<br />
<a name='more'></a>For example at the moment micro-services appear to be becoming fashionable but interestingly if you follow the conversations around this you’ll find that its really “SOA done right”, and SOA apparently became unfashionable a while back.<br />
As with fashion the popularity of a particular technology is decided not necessarily by its technical merits but by widespread adoption think VHS vs BetaMax.<br />
For the most part people will tend to follow fashion and this is why you suddenly see a lot of people pick up the latest fashionable tech without stopping to consider if it actually fulfils a need or solves a problem they have.<br />
When you see the next fashion in tech don’t be blinded by the new and shiny, take the time to investigate it and see if it is actually useful to you before deciding to use it.<br />
Also look around and consider alternatives, there is a big eco-system out there and you might be surprised at what you find when you don’t follow the latest fashion.<br /><a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=719235" rel="tag" style="display: none;">CodeProject</a>Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com2tag:blogger.com,1999:blog-9220389270062827818.post-64681693544164945622014-05-19T08:48:00.001+01:002014-05-19T08:48:56.805+01:00DDD South West 5<p>This weekend saw the return of DDD to Bristol after a break of a year, with a new location and changed team behind the organisation.</p> <p>As per previous years the weather on the day was absolutely fantastic with blue skies and sunshine as far as the eye could see.</p> <h4>The venue</h4> <p>This year instead of being held at UWE the Redcliffe Sixth Form Centre which is closer to the centre of Bristol making it easier to access via Train but a little more difficult by car, but with plenty of car parks nearby I don’t think it was a big problem.</p> <p>On entering the venue you proceeded upstairs into a large “common room” area which is where the attendees would be between sessions. One advantage this had over the previous venue was that the area was large enough for the sponsors to be in as well as attendees being able to get coffee/food and socialising.</p> <h4>My Day</h4> <p>On arriving at the conference I found coffee & Danishes waiting for attendees, which was much appreciated, and whilst waiting for the welcome I took the opportunity to catch up with people I knew some of which I hadn’t see since the last DDD I attended.</p> <h5>Welcome session</h5> <p><a href="https://twitter.com/RossDScott" target="_blank">Ross Scott</a> gave the welcome telling everyone about the day, house keeping information, etc. One change for this year was that there would be no evaluation forms instead all feedback would be recorded by <a href="http://pocketddd.azurewebsites.net/">Pocket DDD</a> and each session you entered feedback for would count as a single entry into the prize draw at the end of the day.</p> <h5>Session 1</h5> <p>I didn’t actually attend any of these sessions, none of them had piqued my interest (although having listened to people who did attend I think I may have missed an opportunity to see <a href="https://twitter.com/stevensanderson" target="_blank">Steve Sanderson</a>s talk) instead taking this time to catch up with some people I specifically wanted to talk to.</p> <h5>Session 2 – Redis Cluster</h5> <p><a href="https://twitter.com/marcgravell" target="_blank">Marc Gravell</a> started off by explaining what Redis is, how you can install it, basics of Redis, etc.</p> <p>He then showed us how simple it was to use Redis using the <a href="https://github.com/StackExchange/StackExchange.Redis">Stack Exchange Redis client</a> and also touched on how to monitor Redis using the <a href="https://github.com/StackExchange/Opserver">Stack Exchange OpServer</a> which he uses daily - both of which are available for free.</p> <p>Marc then covered various replication configurations for Redis with master-slave relationships before moving onto Redis Cluster.</p> <p>Redis cluster is currently unavailable on windows (MS Open Tech that are porting Redis are slightly behind) Marc then explained why you’d want a cluster rather than using a master-slave configuration with a demo of how to set up a cluster which currently needs Ruby to achieve.</p> <h5>Session 3 – Supercharge you JavaScript Development </h5> <p>Chris Canal’s session was packed, people were obviously interested in the subject.</p> <p>Chris had chosen to video all of the “live coding” to ensure no issues with the internet and for the most part it worked really well with Chris being able to add additional commentary on what was happening whilst the video was running.</p> <p>Chris covered using npm, grunt, bower and yeomon to get a project started quickly and then covered using the lodash library in your code.</p> <h5>Lunch</h5> <p>Lunch was held in the common room area and the team had laid on pasties for the attendees which were very nice.</p> <p>There were a few groks and a 20-20 presentation by Phil Winstanley, although with the common room although more people <em>could</em> watch it the noise from people talking and not watching did make it more difficult to hear the speaker.</p> <p>By this time the heat in the presentation rooms had increased and a lot of attendees were commenting on it.</p> <h5>Session 4 – Hadoop and Big Data</h5> <p>Gary Shorts’ session was packed, again a good indicator that people wanted to know more about this subject.</p> <p>Gary took us through how hadoop works and then showed us how we could use .Net to work with it using the obligatory word count demos.</p> <p>Once he had explained how we could use it he managed to squeeze in a real world example, including some visualization, around trying to predict the results of horse races. </p> <h5>Session 5 – 10 things I learnt about web application security</h5> <p>James Crowley started his talk explaining he wasn’t a security expert but was passing on his experience from working on a product that had had professional penetration testers trying to break into it.</p> <p>He went on to show us just how easy it was to break into a site using fiddler before moving on to more sophisticated tools such as <a href="http://beefproject.com/" target="_blank">BeEF</a>.</p> <p>James showed just how easily your site could be compromised and more than one person I talked to said they were more than a little concerned about their sites after seeing this session.</p> <h5>Closing Session</h5> <p>Ross Scott presided over the closing session, thanking the speakers and everybody for coming, and then handling the swag giveaway.</p> <p>And with that it was over.</p> <h4>Summary</h4> <p>The new team put on a really good day, pasties and cream teas adding to the west country flavour of the day. I thought the new venue worked out well, especially the common room area, the only downside seemed to be the session rooms were so hot by the end of the day but it does seems this happens at every DDD SW.</p> <p>I think the team can be rightly proud of what they achieved and I look forward to seeing what happens next year.</p> Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com1tag:blogger.com,1999:blog-9220389270062827818.post-19148335649969669592014-04-22T09:00:00.000+01:002014-04-22T09:00:01.278+01:00No Backend<p>In the .Net world if you were to create a web application historically you’d be developing the full stack: web pages, an API (of sorts), business logic and database.</p> <p>As JavaScript MV* frameworks have become more prevalent a .Net web dev may use one of these frameworks, such as Angular or Knockout, to create a the UI but often will still be creating the rest of the stack.</p> <p>As part of learning more and more about JavaScript I’ve come across the concept of “No Backend” or “backend as a service” where a company may provide all the server side functionality you might need (different companies often offering different levels/types of services).</p> <a name='more'></a> <p>Often in <a href="http://www.youtube.com/watch?v=6CRyy4-SMAM&list=PLXmT1r4krsToVklvuAMvfqrYqhnmH6V93" target="_blank">presentations</a>, <a href="http://www.infoq.com/news/2013/05/nobackend" target="_blank">articles</a> and <a href="http://dailyjs.com/2013/11/11/hoodie/" target="_blank">blog posts</a> the reasoning for using a No Backend service is often outlined as:</p> <ul> <li>As a frontend developer I know HTML, CSS & JS inside and out, I enjoy working with that stack. <li>Although I can write server side code I don’t enjoy it and its not my main focus. <li>So why not let somebody who <strong><em>is focused</em></strong> on server side dev create that code which I can then consume through an API</li></ul> <p> </p> <h3>Why should I use this?</h3> <p>Putting myself in the shoes of a purely frontend developer this sounds like a really good idea, it offers me the benefit of being able to host my content using a static web server in something like <a href="http://harpjs.com/" target="_blank">Harp.js</a>, simplifying my hosting needs and allowing me to focus on creating the application/site rather than having to deal with “infrastructure”.</p> <p>A downside is the fact it may cost me more than if I were to host everything myself, but since most of the services are cloud based if my application took off I shouldn’t have any problems scaling.</p> <h3>Isn’t this what mobile app devs already use?</h3> <p>If you were thinking I’ve seen this idea before you wouldn’t be wrong, mobile app developers have been using this sort of service for a while and of the services listed on the <a href="http://www.nobackend.org" target="_blank">noBackend</a> website the majority of them provide samples not only for JavaScript but iOS, Android and often other platforms as well.</p> <p>In the mobile sphere these services are know as Mobile Backend as a Service or MBaaS and have been around a couple of years so there are lots of companies that are offering this type of functionality. The services grew out of the need for mobile apps to store information, manage user accounts, push notifications, etc without the app developer needing to purchase/rent/host the infrastructure themselves.</p> <h3>What’s in a name</h3> <p>Although I came across this under the name noBackend I’ve seen other names for the same thing, recently <a href="http://www.codylindley.com/" target="_blank">Cody Lindley</a> was tweeting about this subject and had this to say: </p> <blockquote lang="en-gb" class="twitter-tweet"> <p>leaning heavy towards term FDA = frontend driven apps (i.e. static apps) given frontend replaces the backend in terms of authority & func</p> <p>— cody lindley (@codylindley) <a href="https://twitter.com/codylindley/statuses/443415755975954432">March 11, 2014</a></p></blockquote> <p>But it doesn’t stop there, one of the better resources around this type of app is <a href="http://www.staticapps.org/" target="_blank">A Field Guide To Static Apps</a> where, unsurprisingly, this type of app is called a static app.</p> <p>With the various different names out there for this type of application I wonder if there will ever be a single name, leaving people in the situation of having to understand that the various names are in reality all the same thing. </p> <h3>Is there anything to worry about with this approach?</h3> <p>Looking at this there are two things I would be concerned about: security & lack of control over the platform.</p> <h4>Security</h4> <p>My main concern is around security, in this respect mobile apps using the same/similar service are in the main no different, and couple of things that stand out for me:</p> <ul> <li>Is the communication between your site and the service using Https or is it all Http? How can you tell? Can you force it to be Htttps? <li>Most of the services use an api key to identify my site to the service. This api key needs to be in my code but what is to stop somebody taking the api key for my app and creating a bot to sign up thousands of users either costing me, potentially, a lot of money or impacting my existing users?</li></ul><br> <h4>Control</h4> <p>If a 3rd party is handling all your server side functionality then you aren’t fully in control of your application, consider:</p> <ul> <li>You are reliant on that 3rd party to be available if its unavailable there is nothing you can personally do to try and resolve the situation. <li>As you don’t necessarily have direct access to the data you use (is it really <em>your</em> data anymore?) is it being backed up? who at the service can access your data? <li>What happens if the service you use happens to shut down? </li></ul> <p>On that last point recently PayPal brought <a href="https://www.stackmob.com/" target="_blank">StackMob</a> and gave users 1 month notice that they were closing it down leaving anyone using the platform to find alternative arrangements and migrate any existing data whilst of course trying to support their existing customers. </p> <h4></h4> <h3>Is this the future of front end development?</h3> <p>Just as the use of MBaaS has grown over the last few years I wouldn’t be surprised to see noBackend to increase with more sites making use of these services especially where speed to market is a factor.</p> <p>NoBackend frees the developer from the need to worry about creation of the whole server side of the application, and for some this will be the best way to get their app out there and in front of potential/paying customers. It doesn’t remove the backend entirely but changes it from a “build from scratch” exercise to “configuration only” task.</p> <p>You can also tell that a subject is gaining traction when conferences devote significant time to it and the <a href="http://qconsf.com/" target="_blank">QCon conference</a> in San Francisco (Nov 2014) is devoting <a href="http://qconsf.com/track/nobackend-%E2%80%93-front-end-first-web-development" target="_blank">an entire day to noBackend</a> </p> <p>I think any dev should keep an eye on this area to see how it evolves, the services that are offered and the companies that are in, or come into, the market.</p> <p>It is just possible we are seeing the future of front end development</p> <p> </p> <h5>Additional resources</h5> <p><a href="http://codylindley.com/popupfrontendapplications/" target="_blank">Popup? Frontend Apps - A New Frontier!</a><br clear="all"><a href="http://www.staticapps.org/" target="_blank">A Field Guide To Static Apps</a><br clear="all"><a href="http://nobackend.org/" target="_blank">noBackend</a><br clear="all"><a href="http://www.infoq.com/news/2013/05/nobackend" target="_blank">noBackend:Front-End First Web Development</a><br clear="all">Look ma, no backend (<a href="http://vimeo.com/68987290" target="_blank">video</a>) & <a href="https://speakerdeck.com/gr2m/look-ma-no-backend" target="_blank">(slides)</a><br clear="all"><a href="http://www.youtube.com/watch?v=6CRyy4-SMAM&list=PLXmT1r4krsToVklvuAMvfqrYqhnmH6V93" target="_blank">I have a Dreamcode: Build Apps, not backends (video)</a><br></p> <p><br><a style="display: none" href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=719235" rel="tag">CodeProject</a></p> Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com2tag:blogger.com,1999:blog-9220389270062827818.post-9411240254046792562014-03-05T08:24:00.001+00:002014-03-05T08:24:41.362+00:004 Places to load JavaScript<p>I watched <a href="http://www.youtube.com/watch?v=li4Y0E_x8zE" target="_blank">Enough with the JavaScript Already</a> by <a href="http://www.nczonline.net/" target="_blank">Nicholas Zakas</a> the other day and one thing that stuck with me was him outlining 4 places within your page to load JavaScript </p> <ul> <li>In <head> <li>Before </body> <li>After page load <li>On demand</li></ul> <p>Nicholas points out that you don’t just have to load JavaScript in one place, you need to think about what your users will do on the page and this should guide where you load your script.</p> <p>He then went on to offer some guidance on common things you’d load in each place:</p> <p><strong><font size="2">In <head></font></strong><br clear="all">To determine how your users are using the site you need analytics, often those scripts state they have to be in the head e.g. Google Analytics. If you are going to put something here it should be absolutely minimal such as boot strap code. </p> <p><strong><font size="2">Before </body></font></strong> <br clear="all">You should add scripts here that control functionality that users do <em>immediately</em> the page is loaded.</p> <p><strong><font size="2">After page load</font></strong><br clear="all">Once your page is loaded then load scripts that control functionality that the user may do shortly after the page is loaded scripts needed soon after page load</p> <p><strong><font size="2">On demand</font></strong><br clear="all">This is loading a script when needed specifically relating to what the user is doing. The functionality this relates to is code that is used infrequently by the majority of the users of your site (<25%). Nicholas mentioned a <a href="https://alexsexton.com/blog/2013/03/deploying-javascript-applications/" target="_blank">blog post</a> by <a href="https://alexsexton.com/" target="_blank">Alex Sexton</a> which talks about doing this amongst other things (also a good read).</p> <h2>Summary</h2> <p>What I specifically took away from this part of his presentation was that all too often before </body> becomes a dumping ground with scripts being put there with no real thought as to what is actually needed on the page. </p> <p>Something else that crossed my mind is if you’re building a SPA you may think you’re already doing this using require.js or similar mechanism, loading only scripts as you need them, but it may pay you to take a closer look and work out exactly what is loaded and when, perhaps its not being as efficient as you think.</p> <p><br><a style="display: none" href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=719235" rel="tag">CodeProject</a></p> Nathanhttp://www.blogger.com/profile/02284010981286464436noreply@blogger.com0