1

DDD9 Community Developer Day at Microsoft Reading

by Jon 29. January 2011 19:24

Travelling home after another fantastic DDD; an annual UK development community held at Microsoft Reading.  A big thanks must go to all the organisers and speakers that have yet again made this a fantastic day. 

Some of the topics were a bit techy so I am using this blog to attempt solidify the notes I made.  If you see any mistakes or oversights please please please get back to me so I can rectify them. 

I managed to cover Liam's talk and the basics of the other talks, I had planned to do more but I have been ill this week.  I may try to fill it out with more details if I time this weekend, or if someone gets back to me with a suggestion.

Go Asynchronous With C# 5.0 - Liam Westley

Liam went through one of the headline new features that is coming in C# 5.0 (also in vb.net 5.0), which was announced at PDC 2010 last year.  The New async keyword and its sister keyword await, are two new keywords in the language that simplify the way we perform asynchronous operations. In this world of multi-core processors and responsive handheld devices we need to be able to do several things at the same time more efficiently without making an accidental mistake that brings your code crashing down.  Liam demonstrated the problem we face by offering three members of the audience hot drinks.  If you want to do three things at the same time, (make three hot drinks), there is a temptation for a developer to start up three threads, the analogy Liam made was this is like getting three kettles out and making three hot drinks at the same time.  Its not sensible, it uses too many resources and it will take you longer!  Its better to do it in a more controlled way, but in c# 4.0 (and other languages) the extra code needed to achieve this will add extra lines to your code that muddies the water hiding the detail of what we want to achieve.

Async and Await are two words that we will use to manage the complexity better, enable use to boil hot water and make drinks quicker without hiding the complexity involved in asking people what drinks they want.  The process of making three hot drinks is pretty simple so if we can describe it in a simple way but include markers to say how we are going to achieve this asynchronously we are onto a winner. 

The two new keywords means we are able to write asynchronous code but it looks like single threaded code in your source file.  By placing the Async and Await Keywords in the right places the dotnet compiler will take your essentially single threaded code and construct call backs in the right places at compilation!

Async – We use this keyword to mark a method, its a statement of intent to say we may be performing asynchronous operation.

Await – Await can only be used within a method that has already been marked with an Async keyword.  If you place the word Async before you call a method you want to be run asynchronously the compiler will ensure the code that is after the keyword will be executed on a Callback without you having to write any extra code.

The code looks amazing but there appear to be a couple of gotchas:

  • You have to be really careful not to use the word await in your method names, you need to check your naming conventions before you implement.
  • A method marked with the async keyword can only return void, task or Task<TResult>
  • The naming convention seems a little off, as await doesn’t wait.  It is a request to continue running on a callback
  • Exception handling looks a bit funky less than clear in some scenarios which could get confusing.

It looks fantastic, and I look forwards to using it but it almost needs a health warning because it so much easier to write asynchronous code, i can see that lots of people may start using the keywords everywhere. When they start getting weird exceptions they can’t fix there will be the temptation to swallow them.  Obviously this can happen today in our current callback centric world, but there is a smallish barrier to entry.  I’m looking forwards to seeing this in the framework, if the names will stick, and what if anything will change with the exceptions.  If you want to look at this now you can grab the CTP here, but be warned its not compatible with MVC3 or VS2010 SP1.  Liam mentioned that as this is a CTP we as developers have a chance to get back to MS to ask for features or changes we want to see in c# 5.

Monads! What are they and why should I care? - Mike Hadlow

Mike Hadlow is one clever bloke, I got to the end of the talk and I wasn’t even sure if the questions I had were valid.  I thought I knew what monads were by the end of the talk but looking at my notes its still not clear.  In summary most developers probably shouldn’t care unless they are really interested in it.  From what I understand monards are used all over the dotnet framework, LINQ, IEnumerable<T> by understanding the concept you will better understand what is going on under the seams.  I need to see this again, and probably again and do some sample coding to get my head round it before I can put together a sensible overview.

But it does beg a bigger question, does the average developer need to know what a monad is?  A developers job is to create software that solves a problem quickly and cheaply, it doesn’t really matter how this is done.  It goes back to my previous post on what is Lean.  The customer couldn’t care less if you know about monads, they don’t even want a piece of software, they just want there life to be easier/nicer.  If knowing monads helps developers achieve this; great.  Its one for my list of things to read about.

Functional Alchemy: Tricks to keep your C# DRY - Mark Rendle

DRY stands for Do Not Repeat yourself.  As a developer if you find yourself writing the same code, or even doing the same thing over and over again your doing something wrong.  Mark Rendle showed us some ways we can use Functional Tricks to reduce the amount of code we write and reduce repetition.  Mark made a great point that using an OO language is can be like using a Hammer to crack a nut, not everything is an object.  Mark then went through some code, I especially liked the functional catch and the cached dictionary looked useful, although the lock looked a little dangerous for my liking.

Again in my mind software development is getting something done as quickly and as simply as possible, not having to write the same line of code over and over again is an advantage, and I loved the extra readability some of the sample code added.

Is your code S.O.L.I.D ? - Nathan Gloyn

Nathan about to start his talkKind of, but it could be alot better.  I loved this talk, Nathan took a pretty dodgy asp.net project which had inline SQL and transformed it into a thing of beauty.  He showed how you can take any dotnet code and make it much better using SOLID principles.

SOLID is a set of principles about class design, they are principles to consider not rules to apply.  Each letter of SOLID stands for a different concept which is designed to remove the nasty ‘Design Smells’ that infect code bases.

Nasty Code Smells Nice SOLID Principle
  • Rigidity – Cant Change
    Fragility – one change will break other things
  • Viscosity – changes are too much work, and a dirty hack is preferable
  • Complexity – Makes it difficult to change in future
  • Repetition – Waste of time writing the same thing over and over again
  • No Opacity – lines are code are confusing, do different things
  • Single Responsibility – Each object has a single responsibility
  • Open/Closed – Software is open for extension closed for modification
  • Liskov substitution – objects can be swapped out for different reasons, ie testing, for different database back ends etc etc.
  • Interface Segregation – Lots of client interfaces are better rather than a single fat interface
  • Dependancy Inversion – Dependencies are turned on there head so objects are loosely coupled


After whistling through the concepts Nathan then dived into code taking a legacy application and applying each of the SOLID principles in turn to refactor the solution into a much cleaner, more testable manageable project.  Nathan covered alot in this presentation and I was glad I took notes so I could look into it further when I got home.  I’m looking forwards to going to the next talk that Nathan gives.

Enforcing Code ‘Beauty’ With StyleCop - Guy Smith-Ferrier

Unfortunately I made it to this session a little late, because I had got myself into a table tennis match on xbox kinect!  Unfortunately as soon as I made it to the session I found that StyleCop is of no use to our business because it doesn’t support vb.net.  A bit of a surprise as StyleCop is open source, might take a peek if I ever get any time!

Beginners Guide To Continuous Integration - Paul Stack

I have recently implemented TeamCity in our organisation, CI is life changing.  It fits in with the DRY principle, developers should be aiming to automate any repetitive tasks and for many organisations software Builds, Testing and Release take an inordinate length of time.  Paul covered the basics of what CI is, how you should pick a CI and did a quick demo, a nice taster session for anyone who hasn't thought about CI.  It didn’t cover anything really new for me but it was nice to see a different perspective., and I liked the presentation style.  I was set next to a guy who got really interested and ended up giving him a link to my blog so he could take look at my beginning TeamCity blog series.  I think this session interested alot of people; who just want to save time and .’. save money.  The advantages to CI are clear, reduced risk, reduced bugs better testing, faster release, you can take it to another level it has even been joked on twitter that ideally your CI system should order you a pizza if you break a build Smile with tongue out

Tags:

conference | ddd | development

0

Using Windows Phone 7 as a modem from your laptop

by Jon 28. January 2011 21:35

As DDD9 is tomorrow I was looking for a way to connect to the internet my laptop on the train.  I assumed that using my new WP7 as a modem would be impossible, but appears not.  The folks at hdblog.it got it working in November!  Its a pretty simple process and quick enough for you to setup as you travel down, but you need to have ZUNE installed on your laptop for the drivers.

  1. Goto the Phone Dialler on your WP7
  2. Enter ##634#
  3. Press Call
  4. The screen will change, show the WP7 Loading clock  then change to ‘Diagnosis (ver.0929)’
  5. Enter *#7284#
  6. The screen will change to ‘Micro USB Test’ and show three Options
  7. Press ‘Modem, Tethered Call’
  8. You will get a confirmation telling you that you have to reboot the device
  9. Press ‘ok’
  10. The device will reboot
  11. Plug your WP7 phone into your laptop using a USB lead
  12. Your laptop will install modem drivers
  13. Make a new dialup connection, enter *99# in the Dial Box and leave user name and password blank
  14. Press Dial
  15. Your are using your WP7 device as a modem


Repeat the process and select Zune to revert back to Zune Sync, you will nee to revert back to Zune Sync to re-enable side loading of apps.

Enter ##634# into the dialer Enter *#7284# into the diagnositics window
Choose Modem, Tethered Call
Add a Dialup Connection using your Wp7

Tags:

conference | ddd | General | windows phone 7 | WP7

0

Deploying Asp.Net to a different time zone, Temporal Future Shock! Specified argument was out of the range of valid values. Parameter name: utcDate

by Jon 17. December 2010 09:57

You would have never of thought it but if you compile ASP.NET in a different timezone you could cause yourself some temporal problems.  I recently discovered that parts of ASP.NET are date specific and if you compile an ASP.NET application in one timezone (The UK), and deploy to another timezone (California) you may find that your web application won’t work correctly until the time catches up.  Its all to do with the date stamp in the assemblies, when you install your application onto a server in california the timestamps on the assembly files may be in the future and parts of the ASP.NET framework will refuse to load them.  Just by waiting 8 hours for time to catch up the problem will resolve itself!  Its defiantly worth saying this doesn’t effect all server setups I had no problems with a customer running server 2008 in a different timezone, I only came across this problem with an AJAX enabled system when a customer was running server 2003, but I haven’t had time to test different scenarios

I installed the application the AJAX was ‘working’ however nothing was styling correctly

I viewed the source of the page and started debugging by copying the WebResource.xsd url into different tab, I was surprised to see the following error:

Server Error in '/' Application.

Specified argument was out of the range of valid values.
Parameter name: utcDate

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: utcDate
Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

I returned to the system after 8 hours and the site was working and the error was gone! Be careful out there, this was a fully patched server 2003!

Tags: , , , , , , ,

asp.net | Deploy | development | General | IIS | Maintanance | TechSupport | vs2010

1

What is Lean?

by Jon 11. December 2010 13:08

Its a simple question, but as a software developers what do we think lean is and are we actually right?  I was asked this very question yesterday by a Lean Manufacturing Expert and I got it wrong!  As software developers we love to dive into detail and explain and extend a philosophy much more than we should.  If you look at the origins of lean it means just one thing and it pretty simple.

Eliminate Waste

If someone asks you what lean actually is remember it is one thing! Everything else you have read  and learnt about lean is just there to support this one principle; the elimination of waste.  Its Lean and simple, don’t make it more complicated than it needs to be!  Good luck in your quest to eliminate waste for yourself, in your business/day job and your customers.

Tags:

development | General

2

2GB Memory Upgrade on a Acer Aspire One 1.83Ghz (533-23Dkk) from 1GB

by Jon 6. November 2010 16:55

This turned out to be trickier than I expected due to a stubborn keyboard, but upgrading my netbook to 2GB of memory has given me a pretty big performance boost so it was well worth doing.  One important point is do not touch the screws on the back of the notebook, the first step is to remove the keyboard and wont need to go anywhere near a Phillips screwdriver until you have removed the keyboard.

What you need:

  1. 2GB laptop memory chip, I used Kingston Memory 2GB PC3-8500 CL7 204 – Pin SODIMM, I got mine from aria.co.uk for £27.99 which seemed like a good/cheap price
  2. A small flat screwdriver to prise off the keyboard
  3. A small Philips screwdriver to remove the screws under the keyboard
  4. Optional - Anti Static wrist strap

The Tools you need - Anti Static wrist strap is optional

1. Open the lid and prise off the Keyboard with a flat screwdriver.  This is actually quite tricky, the keyboard has three clips which you need to press in.  When all the three clips which are coloured in red on the picture below are pressed in you can raise the edge of the keyboard past the clips.  Once you have raised the edge of the keyboard you will feel some resistance from three additional bumps that hold the keyboard in place.  The bumps are coloured in blue in the photo in below.  You need to slightly bend the keyboard on itself to force it past these three bumps.  When you have done this the keyboard will be free and will pivot around the base.

The holding clips, and bumps

2. Once you have removed the keyboard you will see 7 holding screws, remove these screws with a small Philips screwdriver.

Remove the 7 screws

3. When you have removed the screws, place the screwdriver in the small hole on the right to force the back cover off the notebook, turn the notebook over and prise the back cover off.

Push here, to push the backcover off

Prise off the back cover

4. Replace the memory with the new chip, the turn the netbook over and turn it on to confirm it is working correctly.

Swap out the 1GB chip with a 2GB chip

It boots, and shows 2GB

5. Turn the notebook off, put the back cover back on, screw in the 7 screws back in, clip the keyboard in and that’s it, sorted.  You can use the same steps if you want to swap out the HDD for a SSD.

Tags:

Maintanance

Powered by BlogEngine.NET 2.0.0.36
Original Design by Laptop Geek, Adapted by onesoft, and finally some tiny tweaks by JonAlb