kian ryan - code, photography, bob » Archive of 'Sep, 2009'

Guathon – After Tea

Here we go Visual Studio 2010 & ASP.NET 4.0

  • Lots of content not being covered. At least he’s clear about this.
  • Now built on WPF – woof. Multi monitor support.
  • Demos being done on the MVC codebase :-)
  • Code navigation – select param, highlights all instance usages.
  • Intellisense – Mid term search, no longer need to type start of term. Filters based on camelcasing woot. Someone has been using Quicksilver.
  • Oh dear – resharper is in trouble. Navigate to – “goto Type”. Although now quite as neat – needs keyboard interaction.
  • View call heirarchy – more Resharper features :-) (althought being able to keep searches around is a nice feature.
  • Col based code selection as well as line selection.
  • TDD support – “Consume First”, stops intellisense from attemting to autocomplete when writing not-yet-existing classes. Then becomes aware of class and allows you to define/work with properties. Nice.
  • TDD support – generate class (wait – this wasn’t in 08? More resharper?)
  • MY GODS – 2010 really is 2008 + Resharper (so far). Remind me to reiterate my love for Resharper.
  • CodeSnippets in VS2010 feel like completion in TextMate. Nice mechanism. Extended for ASP.NET, download extra snippets.
  • #scottgufact – Scott Gu works at Redmond, you don’t.
  • Debug history – useful landmarks in lifecycle.
  • Historic debugging – allows step forward/step back through source code.
  • Test tool – run on client, captures information on state of crash. Sends state back to developer. Developer can debug from the state of the crash. That’s pretty damn neat. Can also capture screenshots/video.
  • .NET 4.0, new version of CLR (guessing because of dynamics, etc).
  • Visual Studio 2010 filters intellisense and properties for target framework. Uses reference libraries.
  • ASP.NET 4 – emphasis on clean HTML and SEO (routing, user configurable ClientIDMode), etc.
  • Are we back on web apps vs web sites? (Scott jumped straight to web app rather than web site).
  • New web app template looks good. Jquery, logins, etc included out of the box. Very nice.
  • ClientIdMode – Predictable is the new black (and will save front end developers having migraines when given ASP.NET apps).
  • CSS rendering for controls – YES! THE TABLES ARE BANISHED! RenderTable=false
  • Finer grained control over the viewstate.
  • Improvements coming to the WYSIWIG designer – who uses the designer for ASP.NET? Really?
  • Routing support for ASP.NET 4 – quite elegant :-) Page.RouteData.Values. Doesn’t to URL rewriting, more subtle mechanism.
  • IIS SEO Toolkit. Analysis tool for SEO optimisation of sites. Target site does not need to be running on IIS. Can perform some optimisations to IIS sites – hence linked to IIS manager.
  • It looks like VS 2010 javascript support no longer sucks. A seriously robust engine. Involves intellisense which can keep track of quite impressive object definition at design time. Woot!
  • ASP.NET Ajax – new things for those people that use it (I’ve never got on with it).
    • ADO.NET Entity Framework – more T4 support good. Model first and POCO to boot.
  • Apparently LINQ 2 SQL is not dead – improvements coming. I remain sceptical.
  • Design surface no longer has a “dump and replace” attitude. This may rendel DBML Tools redundant.
  • Inbuilt fake support, reliance on T4 – looks like MS is buying hard into T4 for code gen. I see this as a positive thing.
  • I admit – the chart control is cute :-)
  • WAIT? Multiple config file support – build config dependant. I do this already! I will no longer be special! Don’t like deployment support from within VS, prefer to do it clean from a build server.
  • Release specific configs only contain overwrites – this is useful.
  • If you can tie the Deployment Projects up with build servers (I’m looking at you CCNet), you’ve got a rather powerful test & deployment environment.
  • Seriously folks – this is one of the really nice things…

[Please note these posts are done from my G1. Typos and errors may/will/are included].

Guathon – Before Tea

Covered so far:

  • Websitespark (we know about this already
  • Web Platforms Installer (Apt for windows – this looks good – can developers submit apps to it?)
  • MVC (we’re here for two hours on this – basic intro and new stuff on 2.0)
    • Support for jQuery.validate in MVC2
    • (Usual MVC basics – saw this at Mix 07)
    • Humm, routes supports reg-ex. Is this new to 2.0?
    • Ahh – scaffolding, etc is T4. That’s been an itching question. I severely like the layout of the default generated views.
    • MVC2 – new “filter” attributes. [HttpPost] replaces [AcceptVerbs(Http.Post)]. Small but nice detail.
    • Ohh, you can mark which attributes are bindable in the class – you don’t have to do it in UpdateModel.
    • “buddy class” – way to get around partial method limitation. Haven’t seen this before… Link the buddy class to the type class using [Metadatatype(typeof(buddy))]
    • Er, okay. This is new stuff in the validation. Direct validation attributes using the buddy class. COOL! System.ComponentModel.DataAnnotations.
    • The binding has changed quite a bit. I like the new architecture, much less messy, much stronger.
    • MicrosoftMvcJQueryValidation.js <– nice one.
    • Complex validation – base off a webservice.
    • New helpers: Html.EditorFor, Html.DisplayFor. Strongly typed lambda syntax – compile time checking.
    • Templates allow override of HTML generated for EditorFor and DisplayFor. Uses partial views. Name partial view to type (e.g. Decimal). Drop in “EditorTemplates” folder. Can be applied to shared folder and/or view specific. Nice.
    • Can also generate templates not related to type, pass to “EditorFor” as a parameter. Also nice.
    • Can use the buddy class with [UIHint] attribute to specify type to field. Big emphasis on DRY. Ohhh nice.
    • Whole model can be CRUD rendered on the fly. [ScaffoldColumn] can be used to inclue/exclude properties.
    • Unit testing time… First up the unit testing sales pitch.
    • “Vs 08 adds all this value added … crap” as the Gu goes mad with the delete key.
    • Unit testing models, unit testing controllers (nothing new here so far).
    • Simple testing on controllers to ensure they render views, etc.
    • Here we go – the hiccups with tight binding to the DB for tests. Ohh, dependancy injection.
    • IService, Db imp of service. Pass into constructor.
    • Use 3rd party dependancy injection or “poor mans – pass through the controller”.
    • Pass collection of objects to “FakeService”. How should you happen multiple services?
    • No shame in writing tests to test the database and tests against the fake services.

First Techcrunch – Now Forbes

Polanski

Apparently, hitting the “publish button” on articles that aren’t finished, or in some cases even started is all in vogue this year. First of all techcrunch manage foot-in-mouth syndrome over Spingate, and now Forbes has managed one, publishing an internal memo or note over the Polanski affair. Link available as long as it’s live.

This begs several questions:

  • Who is Frank?
  • Who are the sources in the Justice Department.
  • Does no one even look for the draft button anymore?

Fencing for Geeks

Sheffield Open 2006

Since a few people have been asking recently… I am currently coaching at two clubs in the North-West: Manchester and Altrincham. Beginner geeks are welcome to turn up to either, and will be welcomed by a smile and a circuit board.

Manchester – Manchester Fencing Club
This club caters for all fencers from beginners to international.
I’m here every other week (other coaches are availible at other times). Ping for details.
West Hill School, Stalybridge, SK15 1LX
Thursday 1900-2130

Altrincham – Salle Kiss This club is a new club, currently catering to beginners. A good environment for beginners to feel comfortable.
Altrincham Grammar School For Boys, Altrincham, WA14 2RS
Wednesday 1900-2100

Fees vary from club to club. For your first session, stick a tenner in your pocket and you’ll get plenty of change (I don’t handle money and can rarely remember what fees are from one week to the next).

I’m horribly unfit!

Isn’t that the point? Seriously, we cater for all shapes, sizes and fitness. Turn up and give it a try. The sport is fun, addictive, painless (mostly) and we provide all the kit you need. Just bring yourself, a pair of trainers or squash shoes, tracksuit bottoms and a t-shirt. You’ll want some water and a towel as well.

To make it a bit more fun (and to leave out those first week blues), why not organise a couple of you to turn up together?

Oh, and you’ll get to hit me in a large leather jacket repeatedly. What could be more fun?

Interested?

Drop me a quick e-mail or comment to let me know you’re coming. It’s also useful to know how big you are (chest size and height) so I know if I need to grab some larger jackets from elsewhere.

But I’m a Foreigner!

Not a problem – there are plenty of clubs out there. Have a look at the British Fencing Club directory, and contact the club secretary (using that old-tech thing called a phone). That’s why they’re listed.

Ecommerce Headaches – Prices & VAT

Hector the Tax Inspector I felt this warranted a blog post.

I’m currently writing an e-commerce system for some very nice people which is quite literally all-singing, all-dancing. When we originally wrote the prices part of the system, we had a very serious conversation about how pricing and VAT would be handled. It went something like this:

Client) We want to store prices inclusive of VAT.
Me) Are you sure? Inclusive of who’s VAT?
Client) We want the prices to be nicely rounded, and then we take the VAT off the total price.
Me) Are you sure? This has some interesting international implications.
Client) Yes, we’re sure. Here – go do pretty things.
Me) Ok.

Seems fair enough. They want pretty rounded prices on the site which meant they didn’t have to think about VAT. Which is great for working in the UK. Then I received a change request asking us to display the VAT dependant upon which country the user was purchasing from. This would still be calculated as a percentage of the earlier specified total price.

Me) So if the user’s country has a VAT of 90%, you’re happy to only receive 10% of the total sale value?
Client) Erm…. Ah.

This is a little extreme, no-one as of yet uses a VAT of 90%. The UK has a rather modest 15%, but countries such as Norway have a rather more eye-watering 25%. Admittedly, if you’re shipping to Panama, you’re quids in, since VAT is only 5%.

There are several different ways pricing and VAT can be managed on an e-commerce site. When I brought this topic up in an IRC channel I frequent, I thought the following exchange illustrated the complexity and confusion rather nicely:

15:17 <@ccooke> kian: you need to store the VAT on the exact item at the exact moment it was stored.
15:18 < kian> ccooke: no you don’t.
15:18 < kian> ccooke: hold. for which scenario. a, b or c?
15:19 <@ccooke> which one’s which?
15:19 < kian> ccooke: a) static price, flexible VAT b) static base price + UK VAT, remove VAT add countries VAT, c) Price Ex VAT + WhateverVAT, d) sod this – pub.
15:20 <@ccooke> d!
15:20 < kian> I’m with you. Be there in three hours.

So, for your interest and ponderings, here are the three options I see:

Fixed Price, Flexible VAT

Price is stored, inclusive of VAT. VAT is calculated as a percentage of the price at point of sale with respect to the user’s country. So if you buy from the UK, you’re paying £100 of which 15% is VAT and if you buy from Norway, you’re paying £100 of which 25% is VAT.

Pros: Nice pretty prices. Cons: The amount of money you return from each sale is dependant upon where the user purchases your item from.

Price + “Home” VAT, Flexible VAT

Prices are stored, inclusive of “home” VAT. When calculating prices for foreign countries, the VAT for the home country is deducted before adding on the VAT for the user’s country. So if you buy from the UK, you’re paying £100 of which 15% is VAT, and if you buy from Norway, you pay £108 (100 * 1.25 / 1.15 ) of which 25% is VAT.

Pros: Pretty prices for home country, protected base price for foreign country. If home VAT rate changes, prices remain same (gain or loss dependant on home VAT). Cons: You could end up with some odd prices for non-home countries.

Price Ex VAT, Flexible VAT

Prices are stored, exclusive of any VAT. VAT is calculated on the shop at run time dependant on the user’s country. So if you buy from the UK, you’re paying £115 of which 15% is VAT, and if you buy from Norway, you pay £125 of which 25% is VAT.

Pros: Your base price does not fluctuate, therefore the value of the VAT is irrelevant. Cons: Potentially ugly, non marketing friendly prices. Price changes on VAT changes.

We’re still debating which one of these is the best option for the system we are currently building. We are currently using “fixed price, flexible VAT”, but this position may change as we delve into the implications more deeply.

If you’re still with us at this point, well done. I’ve spent an hour trying to get my head around this rather prickly topic, double checking import/export and VAT regulations as I go. But its a good example of how something so initially clean-cut as product pricing can lead into a headache of trouble.

It’s all about scope.

Android 1.6 – Brings Awesome Bar

The Android 1.6 API has now been released, and with it is coming one feature which outshines all others. The “Quick Search Bar” provides instant access to local phone and Google results in near real-time.

Basically, it’s spotlight for Android, launched as a widget from your home screen. I can see this really becoming the central hub of any phone.

The new marketplace looks a hell of a lot better as well.

Log Parser Is My New Best Friend

SEO may be something of a dark art, but even if we don’t practice it, as web developers we’re usually responsible for putting into place the mechanisms that allow the Mouldy-morts to practice their forbidden forms. Recently, that usually consists of dropping analytics code onto a page to track your users every move, but what do you do when someone’s “forgotten” the analytics code, or it fails for some unknown reason?

Step up to the plate server logs! Both IIS and Apache quite happily dump their site logs for you to parse through them. But this is where the fun bit comes in, since they can get quite large. How large? This morning I’ve had to wade through 102GB of logs. Most unix monkeys will probably laugh at their windows using counterparts, and with their long hair and sandals decry, “102GB! Hah, I eat 102GB of server logs for breakfast with my organically grown shredded wheat!”. And yes, with Perl, awk and sed, 102GB is pretty much nothing. But you don’t tend to have these tools easily accessible on a window box, and if you’re messing around on someone else’s Windows box, you want to create the smallest footprint possible.

And here’s where Microsoft has been quite clever with a little known, but very powerful tool called LogParser. Log Parser provides you with SQL-style syntax access to the data contained in those log files and can output it in a range of formats from CSVs through to charts. I’ve been playing with it most of the morning. It’s nice.

Install it, add it’s location to your path variable and the log world is your oyster. Open a command prompt and traverse to your IIS log directory (mine is at c:\iislogs) and execute the command using the following:

logparser -i:iisw3c -o:csv "{insert-sql-query-here}"
or
logparser -i:iisw3c -o:csv file:query.sql

-i:iisw3c tells log parser its looking at w3c formatted log files, -o:csv to output as CSV and you can either present your sql inline or reference an external file. I’ve listed a few examples below to get you started:

-- Return page hits for all aspx pages handled from the beginning of the year to today in a given directory.
SELECT COUNT(*), cs-uri-stem 
INTO hits.csv 
FROM *.log WHERE EXTRACT_EXTENSION(cs-uri-stem) = 'aspx'
AND cs-uri-stem LIKE '/subdirectory/%'
AND date between timestamp('2009-01-01 00:00:00','yyyy-MM-dd hh:mm:ss') 
    AND timestamp('2009-09-11 00:00:00','yyyy-MM-dd hh:mm:ss')
GROUP BY cs-uri-stem</p>

<p>-- Return number of hits for different query string tokens
SELECT COUNT(*), EXTRACT_TOKEN(cs-uri-query, 0, '&amp;'), EXTRACT_TOKEN(cs-uri-query, 1, '&amp;')
INTO search.csv 
FROM *.log WHERE cs-uri-stem LIKE 'Query.aspx'
AND date between timestamp('2009-01-01 00:00:00','yyyy-MM-dd hh:mm:ss') 
AND timestamp('2009-09-10 00:00:00','yyyy-MM-dd hh:mm:ss')
GROUP BY cs-uri-stem, EXTRACT_TOKEN(cs-uri-query, 0, '&amp;'), EXTRACT_TOKEN(cs-uri-query, 1, '&amp;')

And here’s a few links to other people who’ve done more with it than I:

© 2008 kian ryan – code, photography, bob is powered by WordPress

Bad Behavior has blocked 75 access attempts in the last 7 days.