.Net Demon Review

In the last couple of weeks I have been using .Net Demon which is an add-on for Visual Studio 2012.

As you write your code in Visual Studio code it can take time to stop and check if the solution still builds as expected, with a larger solution this can become a fairly slow and laborious task – .Net Demon compiles your code as you type, this means you no longer have to stop coding and then rebuild your solution which is a really nice feature. The second you introduce an error you will be notified in the bottom right hand corner – this may sound intrusive but its far from that, your simply notified when you introduce an error.

The tool comes with some nice options including:-

And the description for these options:-

Below I have just opened Visual Studio 2012 and .Net Demon is building the project:-

Below .Net Demon has built all the projects in my solution and is showing no errors:-

Below .Net Demon has built all the projects in my solution and is showing an error after introduced a typo:-

Summary
.Net Demon is a very nice little inexpensive add-don for Visual Studio which will speed up your development process and give you a nice little productivity boost for a very small amount of your hard-earned cash, I recommend you give it a try, a 14 day trial is available

Let me know if you try it and what your thoughts are – enjoy.

RavenDB – Safe By Default

Tags

One of RavenDB’s unique features is something called safe by default – this means that the database is configured to stop users querying for large amounts of data which is never a good idea, to have a query return thousands of records is inefficient and can also take a long time.

With RavenDB safe by default limits the number of records by default on the client side to 128 (by default means its configurable) if you don’t make use of Take(). Server side you can use .Take(1024) if you want to go up to the limit configured by the server, if you try to bring back more than 1024 then it will default to 1024 results returned if you need to return more data than that then you should be asking yourself why?, page your data if you need to return more than this number of records.

Safe by default is attempting to stop a developer from writing poor queries, there is nothing to stop you from changing the defaults to a higher level but if you’re looking to display thousands of records on a webpage without paging through your data then this is seen as poor design, here is a nice a quote from the RavenDB website: -

RavenDB will let you shoot yourself in the foot, but only after you make it absolutely clear that this is what you actually want to do

It seems to be quite common for developers to try to work around the limits and actually want to block their leg off, this usually stems from a misunderstanding of how to use RavenDB, it really is a very simple concept which I find to be a nice feature.

RavenDB also had a very useful option to stop yourself from creating the dreaded SELECT N+1 scenario – this feature stops after 30 request to the server per session, again configurable but if you’re hitting this limit then your more than likely querying incorrectly.

To summarise safe by default is there to help and not hinder, yes you’ll write code then realise your only returning 128 records when there should be more results, no doubt everyone has done that whilst using RavenDB, either your unit tests aren’t right or you’ve forgotten to use .Take()

Free RavenDB Talk in Glasgow on November 14th

My colleague at work Mohammed Ibrahim is doing a free talk titled RavenDB: working with NoSQL data in .NET at Glasgow Caledonian University on Nov 14.

If your unfamiliar with noSQL and want to know more then come along and you will learn all about it and more.

So come along, learn, ask some questions and to get an insight into why RavenDB rocks, register at
http://ravendbglasgow.eventbrite.com
– tickets are selling fast so get yours while you can.

There will be free swag! to give away at the event, including t-shirts and RavenDB stickers.

What I learned last week – 3rd September – 7th September

This past week I have been mainly working with KnockOutJS, if you looking for a way to create a rich UI that users will love and your building a website then I highly recommend you take a look at KnockoutJS

What I learned this past week

  • Web Essentials 1.1 for VS 2012 by Mads Kristensen has been updated, you can read more here – go check it out.
  • RavenDB Backups – I decided to instead of using the RavenDB Backup.exe – I am going to stick with just exporting the tenant database and saving this off to a network share.
  • At work we are looking at introducing CoffeeScript – CoffeeScript is a language that sits on top of JavaScript and compiles down to JavaScript but has added benefits including making your code cleaner and has much more signal to noise ratio – more on CoffeeScript soon , I’m off to learn more on it via PluralSight.
  • Redgate have taken on the 2 developers who write Glimpse and will be adding to the project – you can read more here.

What did you find useful this week? – please let me know by leaving a comment after the beep.

jsfiddle.net – what is it and why is it so useful?

If your writing a web application and using any kind of JavaScript library then jsfiddle is something worth taking 5-10 minutes to look at in my opinion.

You can try out your JavaScript (any library you can think of) add some HTML and sprinkle with CSS and quickly see the results, its a no brainer.

At work we are starting out on a web application which we will be using KnockoutJs on and jsfiddle will be invaluable, I have been watching the Pluralsight and Tekpub videos on KnockoutJs and wanted to blog about jsfiddle after watching John Papa talk about it in one of his KnockoutJS modules.

John’s courses on Pluralsight are awesome and I highly recommend them, the one I refer to was his course on Buiding HTML 5 apps (middle one below):-

jsfiddle.net is a website where you can test out some JavaScript code snippets you have, before you add them to your project, it’s an excellent little test harness for ideas and trying things out.

You can save the fiddles you create and share fiddles with others if you can’t get something working and could use some help with some tricky JavaScript.

Ok less talk more action:-

  • Browse to jsfiddle.net and then sign up for an account, the reason you want an account is so you can save fiddles for later and come back to them in the future.
  • You can add in pretty much any JavaScript library as a a managed resource so that you test all kinds of stuff, jquery, jquery ui, knockoutj, kendoui and more.
  • If you see a blog post that mentions a js fiddle and you want to it then I will show you how to use it below:-

How to create your first fiddle using jsfiddle

  1. Since this demo is going to use KnockoutJS we will add a reference to KnockoutJS
  2. Browse to https://github.com/SteveSanderson/knockout/downloads and then copy the location to the latest version of the knockoutJS library, at this moment in time this link to the file we need is :- https://github.com/downloads/SteveSanderson/knockout/knockout-2.1.0.js
  3. To add this to our jsfiddle look at the left hand side looking for ‘Add Resources’ and then paste in the link to the js file and then click the plus icon.

  4. The screen is split into 4 sections:-

    • Top Left is for HTML
    • Top Right is for any css styling you wish to add/try out
    • Bottom Left is where you add your JavaScript code.
    • Bottom right shows the output you would see in the browser
  5. Add the following into the top left hand window pane (Html):-
    <p>First name: <strong data-bind="text: firstName"></strong></p>
    <p>Last name: <strong data-bind="text: lastName"></strong></p>
    
  6. Now add the following into the bottom left window pane (JavaScript):-
    // This is a simple *viewmodel* - JavaScript that defines the data and behavior of your UI
    function AppViewModel() {
        this.firstName = "Bert";
        this.lastName = "Bertington";
    }
    
    // Activates knockout.js
    ko.applyBindings(new AppViewModel());
    
  7. And thats it we are ready to save the fiddle and test it out.
  8. To test out our code click Run up at the top and you can use your favourite browser to check for any errors that may arise as you play around with the code.
  9. A very simple demo but you get the idea on whats possible, and if like me your trying to learn KnockoutJS its an invaluable tool.

Ok now that you get the idea, go create some fiddles and test our your ideas using any JavaScript library you can think of – enjoy!

Starting out learning KnockoutJS

Tags

So I want to learn KnockoutJS as we are going to be using it on a project at work very soon, I have had a look at it briefly but not really used it in anger as they say. I will be using this for the next few weeks at the very least so lets get started learning it.

In order to learn knockoutJS I will be using the following resources (click the images):-

  • Official KnockoutJS site
  • Tekpub Course
  • Pluralsight Courses
  • KnockmetOut.Net

Ok so thats enough to get me started with, I’ll blog more each week maybe even each day as I come across useful tidbits of learning KnockoutJS.

If anyonelse has useful KnockoutJS let me know and I’ll add them as I go.

Error handling using aspect-oriented programming (AOP)

Tags

,

Code become’s messy with error handling logic all over our code, wouldn’t it be nice to be able to log the error, the offedning method name and the line number of the code that caused the error in the first place.

If you’ve done any MVC development then you are already familiar with AOP, [HandleError] is an example of an aspect and with very little effort indeed you can create your own. Creating an aspect means you can reuse logic for tracing, error handling and more very easily.

At work we use PostSharp for our AOP aspect-oriented programming and its doesn’t get much easier. The guys even give you an add on in visual studio and it walks you through how to go about learing AOP and how to create aspects using PostSharp – the tutorial is superb and very well thought out.

We have a class library logging class which we use as an aspect using Postsharp and this means that we can add a [Catch] attribute to the method and we now have error logging for this new method:-

[Catch]
public MyNewMethod()
{
    throw new applicationException();
}

And that is it, download the demo and give it a try its so easy but quite powerful – I recommend you take a look.

What I learned last week – 13th August – 17th August

This week I have been busy mostly busy with bug fixing some code we have which used to be a windows service but is now a TopShelf service – if you use windows services you’ll know that there hard to debug, enter TopShelf

TopShelf is almost identical to a windows service but runs like a console app and that allows you to debug the code you would have within your windows service. To change your code from a windows service to a TopShelf service is minimal code indeed and well worth the small amount of effort.

What I learned this past week

  • Visual Studio 2012 and Windows 8 are available, if you use Visual Studio 2012 then check out a fantastic extension called Web Essentials – go check it out.
  • RavenDB – the guys who bring you Raven are hard at work on a 1.2 release which will bring a number of great changes, I have upgraded my home-brew project to the latest unstable version and the upgrades to the front end are cool and most welcome – more soon when I get more time hands on.
  • Select2 is a very neat little javascript library which you use to make your select boxes on web pages far sexxier – take a look here.
  • Elmahr 0.91 is out – more here.

What did you find useful this week? – please let me know by leaving a comment after the beep.

Using twitter to stay up to date as a developer

Having listening to hanselminutes podcasts and a few other ones as well as discussions with others I felt the need to ask people out here – how do you keep up to date?

I speak with a good friend of mine who is a social carer and she is always talking about how hard it is to keep up to date and how often things change and how she goes about keeping up to date with these changes – as developers I’m sure we can all relate to that in some way.

How I keep up to date
In order to at least try to stay up to date I read blog posts and carefully select who I follow on twitter. For me the easiest way to stay up to date is to actually harness twitter in a way that allows me to follow the people who tweet about content I want to learn about, of course they also tweet other stuff which is also good but I use twitter as a learning tool, if people stop tweeting useful content then I will unfollow them as I like to have a useful twitter stream as a posed to tweets about running times and how they became the major of some place I’ve never heard of ;)

People ask me a lot why am I always on twitter – the real answer is I keep my ear to the ground and I like to learn whats
new out there or what people find useful.

Yeah blog posts are an invaluable tool but I have spent less time recently reading my rss feeds and more time reading what people are tweeting about – I like to try to encourage people to tweet about useful stuff they come across on a day-to-day basis and is a reason I started my what I learned last week blog post series.

So my question to you guys out there is how do you go about keeping up to date, so you use twitter like me or not really? has it made you think about what you tweet or you dont care who reads what you tweet? discuss…

Small Nuget gotya with our TeamCity builds

Tags

, ,

At work we use TeamCity from Jetbrains on our build server, the product itself is the best there is out there.

Good products should be talked up more on twitter in my opinion, so that more people learn about what is good out there. If you’re considering software to use for building software then look no further than TeamCity.

We recently created quite a few nuget packages for internal use at work and we have them building as part of our builds on the buildserver using Teamcity. They used to be class libraries used as externals and these were causing us some pain so we decided to make them into Nuget packages and build them as part of our build process.

Our build process at work is pretty neat, I can push a website/windows service to dev, or staging environments with once click and it build the code, runs all the unit tests, check the level of code coverage is above a certain level and then removes the current installation and installs the new version – all in one click (for production we have 3 clicks due to having to log onto production servers and clicking on a batch file to do remove the old code and install the new version)

To set that up took time but worth doing as it means anyone can build and deploy to any environment with 3 clicks or less, thats quite powerful.

Now before going into the issue, let me say that people use TeamCity in different ways, the way people build Nuget packages will also no doubt differ.

Our Issue
As part of the code we were referencing internal and external Nuget packages, the NuSpec files had the following:-

<dependency id="ExamplePackage" version="1.3.2" />

Wasnt till I suddenly realised that this means go get the latest version of the example package from Nuget if one is available, which wasnt really what we wanted in this scenario.

Versioning packages within Nuget is covered here Versioning Nuget packages and was just what I needed.

Once I updated the Nuspec files to have:-

<dependency id="ExamplePackage" version="[1.3.2]" />

This square brackets around the version number means that instead of going off to Nuget to get the latest version, go off and get this version (if not installed already).

Now when i do a build it wont try and pull down the latest version of Nuget goodies such as AutoMapper and StructureMap.

Feel free to ask any questions or leave a comment on this post.

Follow

Get every new post delivered to your Inbox.