Glencoe Scotland – road trip

Today I went for a run and having never been to Glencoe in Scotland I decided to go for a drive and see the stunning scenery for myself – unfortunately my pics don’t do the place justice, but here are a few of the ones that turned out some what ok. If you ever get the chance to visit then you should take a run up there its awesome – Scotland has some stunning scenery.

Pic1
Pic2
Pic3
Pic4
Pic5
Pic6

In 2012 I plan to see more of the beutiful country I live in – hope you enjoy.

Real World MVC 3 Development

During the last couple of months I have been working with MVC 3 daily and I have used Nuget packages and tools which have helped in a number of areas, in this post I will give a shout out to these tools which help make MVC 3 a pleasure to work with. For the most part Nuget packages can be found for these tools so you can add them very easily and get going quickly.

Routing

    • Attribute routing for MVC – Remove any routing concerns/issues and start using this now.
    • T4MVC helps make your MVC code much more maintainable, enough said.

Page Performace

      • Chirpy is an open source Visual Studio Add In For Handling JavaScript, Css, DotLess, and T4 Files, which in essence improves page performance.
      • Cassette – Cassette automatically sorts, concatenates, minifies, caches and versions all your JavaScript, CoffeeScript, CSS, LESS and HTML templates.

Profiling

      • Mvc Mini Profiler – A simple but effective mini-profiler for ASP.NET MVC and ASP.NET.
      • Glimpse – What Firebug is for the client, Glimpse does for the server… in other words, a client side Glimpse into whats going on in your server.

Error Logging

      • ELMAH – ELMAH (Error Logging Modules and Handlers) is an application wide error logging facility that is completely pluggable. It can be dynamically added to a running ASP.NET web application, or even all ASP.NET web applications on a machine, without any need for re-compilation or re-deployment

All MVC posts

        • All of my MVC blog posts can be found here.

Conclusion

MVC is great to work with on its own but these tools can only enhance the development process. Please leave feedback or comments, and also let me know if I have missed out on any tools which I can add to this list.

Job: Developer Role

The place where I work is looking for a new developer to come on board and join our small team of talented developers working with the latest technologies in a great working environment and only 10 minutes from Glasgow. If you want to work on some cool stuff then have a look at the job role below:-


Role: Developer
Company: MacLean Electrical (MacLean Electrical)
Location: Westfield, Cumbernauld, Scotland, G68 9LD
Job Description:

Do you want to be involved in leading edge projects using Microsoft technologies working with a company that cares about building quality software? If so, we have an exciting and challenging opportunity for a motivated and talented C#/.NET developer to be involved with the development of highly-performing enterprise systems to increase the productivity of our employees and the efficiency
of our operations.

Based in our brand new Cumbernauld offices the successful candidate will enjoy working within a small, experienced, energetic agile team on a rapid, agile development schedule.
The successful candidate will have an exceedingly strong technical background and be able to clearly demonstrate a sound understanding of advanced language concepts and designing enterprise n-tier platforms. Experience with TDD is essential for the role.

You will be of graduate calibre and have relevant experience in a similar role. A competitive package is available to the right applicant with the opportunity to build a career and enhance their technical abilities with a successful and progressive company.
Desired Skills & Experience

Required skills

• Deep knowledge of C# 4.0 and Microsoft .NET Framework
• Solid competency in SQL with MS SQL Server
• Experience with high performance scalable application design
• Strong understanding of OO principles, SOLID principles and Design Patterns
• Strong knowledge of software implementation best practices
• Good communication and interpersonal skills with individuals and in groups, with technical and non-technical staff, orally and in writing
• Ability to quickly learn new tools/technique
• Candidate should be a self-motivated, detail oriented, and exhibit exceptional relationship management skills.
• A demonstrable knowledge of ASP.Net MVC3, jQuery, HTML and CSS (HTML 5 and CSS 3 desirable)
Ideal Candidates will have the following experience:
Years of Experience
• 6+ years experience as a developer
• 3+ years experience with C#
• 2+ years working with SQL Server (2005/2008 preferred)
• 2+ years working with HTML/CSS


Interested? – If so please email recruitment.jan2012@maclean.co.uk


MVC – get some help

If you’re using MVC and you’re looking for some in-depth information on basically whats going on when you run the code then you should take a look at Miniprofiler (from the guys at StackOverflow) or Glimpse.


Miniprofiler can be added in to your solution and can give you all sorts of really useful information such as which view is currently being rendered and from which method in the controller (which is not always obvious). this can be quite a time saver if you’re not used to the codebase and just want to quickly find the ActionResult which has been hit.

To Add MiniProfiler to an MVC application install it using the Nuget Package Manager console. (you need to use the console sometimes if the package uses a Powershell script)

Once added via Nuget browse to your global.asax file and add in the following 2 methods:-

protected void Application_BeginRequest()
{
    if (Request.IsLocal)
    {
        MiniProfiler.Start();
    }
}

and then :-

protected void Application_EndRequest()
{
    MiniProfiler.Stop();
}

Rebuild your code and run your application and you’ll see info being displayed by MiniProfiler in the top left hand corner as follows:-

Glimpse


Glimpse is a JavaScript plug-in which informs you of information such as Route Debugging which is a superb feature. Add Glimpse via Nuget and then browse to your site and add /glimpse.axd to the end of the url from your application:-

Glimpse

Pres enter and you’ll be taken to this screen, this nice bit here is you can drag the ‘Turn Glimpse On’ and ‘Turn Glimpse Off’ to your fav bar and just click them to do as it says on your site. (This is all done in JavaScript and has very little overhead)

Glimpse

After clicking on ‘Turn Glimpse On’ we see the little eyeball bottom right of the screen:-

Glimpse

When clicking on that you’ll see something like the following:-

Glimpse
Here we can drill into all sorts of information such as:-

  • What route has been called
  • Which view has been rendered
  • Time spent to render the page and timings for each part
  • Config on the server

Again go get them and you’ll have them up and running very quickly and benefit from the features they come with.

AttributeRouting for MVC

AttributeRouting is a fantastic open source Nuget package which allows you to specify routes using attributes on your MVC controllers and actions. We use it in all of our MVC projects at work and I highly recommended it, saves you having to map all y.

Attribute Routing

The QuickStart Guide can be found here.

Main reasons to use AttributeRouting

•Decorate your actions with GET, POST, PUT, DELETE, and verb agnostic attributes.
•Map multiple routes to a single action, ordering them with an Order property.
•Specify route defaults and constraints inline and also using attributes.
•Specify optional params inline with a token before or after the parameter name.
•Specify the route name for supporting named routes.
•Define MVC areas on a controller or base controller.
•Group or nest your routes together using route prefixes applied to a controller or base controller.
•Support legacy urls.
•Set the precedence of routes among the routes defined for an action, within a controller, and among controllers and base controllers.
•Generate lowercase outbound urls automatically.
•Define your own custom route conventions and apply them on a controller to generate the routes for actions within the controller without boilerplate attributes (think RESTful style).
•Debug your routes using a supplied HttpHandler.

Go check it out you wont be disappointed.

Chirpy for MVC

Chirpy is an open source Visual Studio Add In For Handling JavaScript, Css, DotLess, and T4 Files.

Better Page Performance
When you validate your site against YSlow it gives you reports on why your webpages may take some time to render in the browser – Chirpy can help with this big time by minifying script files like javascript, css and more so that there are less requests made to the server on each page request – better page performance is always good.

YSlow

The full list of what Chirpy can do can be found here.

T4MVC for MVC

If your using MVC then please at least take a look at T4MVC or better still add it to your project from Nuget here T4MVC from Nuget – It’s written by David Ebbo who works for Microsoft and works on Nuget as well as a lot of other cool stuff.

What is T4MVC? – the following is lifted from the documentation:-

“T4MVC is a T4 template for ASP.NET MVC apps that creates strongly typed helpers that eliminate the use of literal strings when referring the controllers, actions and views. It helps make your MVC code much more maintainable, and gives you intellisense where you normally would not have any.”

Some links for more info:-

  • David’s Blog posts on T4MVC can be found here:- Posts
  • T4MVC Introduction Video here.

An example again lifted from the site would be:-

@Html.RenderPartial("DinnerForm");

Now becomes

@Html.RenderPartial(MVC.Dinners.Views.DinnerForm); 

and you get Intellisense for free which is nice.

Also this

@Html.ActionLink("Delete Dinner", "Delete", "Dinners", new { id = Model.DinnerID }, null)

becomes this

@Html.ActionLink("Delete Dinner", MVC.Dinners.Delete(Model.DinnerID))

The beauty of this needs to be tried to ge the full extent of whats available but its really easy to add in and change your links in a flash.

By the way it even works for images so heres an example using the aspx syntax.

<img src="/Content/nerd.jpg" />

becomes

<img src="<%= Links.Content.nerd_jpg %>" />

T4MVC is very handy indeed and you should definitely check this out.

Steps for improving my development skills in 2012 (Jan-Feb)

Note:- This will be an on going blog post.

My plan is as follows:-

Firstly I plan to write a lot more code at home, to me thats deffinetly the best way to learn. My first goal this year is to get better at writing unit tests/tdd and learning how to use mocking properly.

January: Watch all of John Skeets Tekpub series on C#, go through Roy Osherove’s Unit Testing Kata’s and watch the @tekpub and @pluralsight videos on Unit Testing.

February: Get up close and personal with RavenDB.

I shall update as we go but this is a good start. Let me know if you come across something you think is worth learning.

Deploy more often

As simple as it sounds deploying to production can be a complete nightmare, however I reckon it should be done fairly regularly, if you don’t want to deploy to production then there must be valid reason for this – yeah I hear your cry.

Not wanting to deploy to production really means that either you don’t trust your deployment process to production, it takes too long or something else makes you wanna run in the other direction when someone mentions the need to deploy to production.

Deploying to production on a regular basis might seem like a bad idea but really I don’t think it should ever be – you may only deploy to production when a change has been made or a release is ready to go out and that’s a fair point, however deploying even without change can and should in my opinion be welcomed.

A question for me would be can everyone in the team working on the project be able to deploy to production, does your team fully understand whats involved, if not should they?

These are just things to consider but in my opinion no matter how hard a release to production is – the more you do it the less of an uphill struggle it will become and perhaps a different solution will appear.

Comments welcome.

Follow

Get every new post delivered to your Inbox.