Wednesday, 28 May 2008

Pdc2008 here I come

One of the first thing I did this morning was to make sure I had registered for the 2008 edition of the Pdc.

Any brits travelling to LA or any alt.net guys want to organize an unconf, let me know.

Now they need to open the registration for TechEd Europe and I'll be booked for the year.

Technorati Tags:

Monday, 26 May 2008

Retrospective on my asp.net MVC talk

I'm publishing this a bit late, but I took a few days (a whole two of them) without working. How refreshing!

In an effort for a more transparent process, here are a few things I think went well and didn't go too well. If you've been at the talk I would absolutely love your criticism. Practice makes perfection, but before that it makes for nicer presentations and a less worried Sebastien!

Preparation god damn it!

The font-sizes were all wrong in everything but the code-editor, this is quite unacceptable and certainly not like me at all. So be prepared if you install vs 2008 SP1 beta, it will reset all your settings. That explains the lack of proper configuration in visual studio. And of course, a problem never comes alone, vs refuses to start under my Presentation account that is set with ridiculously large DPI setting. But it all comes down to me installing this stuff too late, which left me no time to make sure everything was configured properly. Apologies to the audience, I should have had a VM up-and-ready with all my content. And apologies to myself for installing a beta service pack on my main development machines.

Tools

All the usual presentation tools were not installed on that laptop either, so no ZoomIt and no Keyboard Jedi. Again, with a reinstall of vista a couple of days before, I just didn't have the time to get it right.

One thing I find difficult is choosing a screen mode. When showing code, I want to show you my Visual studio and whatever other programs get spawned by it (ie, firefox, the command prompt) while still seeing them on my screen. For powerpoint, I want to keep presenter-specific stuff from your eyes (a timer, some notes, and in general the whole content of the slide you'll see appearing as I talk).

I need a hybrid between Clone and Span modes. I may have something working, so my next talk will guinea-pig the idea. I'll blog about it after trying it out. :)

Not having slides...

Some people didn't completely see how the asp.net MVC and the REST part of the talk connected together, and maybe I should've introduced that at the beginning on the slides. But if you know me, I don't like slides and will avoid them at all costs.

This is the first talk I give where I put some content on slides, to refresh everyone on MVP and MVC and how the models differ. I like how visual it makes the explanation, but I'd rather manage to do it graphics only, with no text whatsoever. That requires more work, a tiny bit of animation and very good graphics. Nothing that can't be done with enough time for pimping it up.

Body language

I used the MacBook remote to change slides, and the freedom to move around to move slides is next to none. I also find that having the remote to hold from the tips of my fingers helps me avoid leaving my hands hanging. Hold something to keep your hands at chest level, it puts your body language into explanation mode. Relax and put one hand in your pocket and you switch to opinion mode.

Eye contact is the best tool to calm anxiety. You'll always find a couple of people in the audience being very expressive, that lets you judge the rhythm of the presentation. There's nothing worse than an expression-less audience.

Messy content

I'm a bit in-between two waters on this one. The whole point of the talk was to see what toolkits you can use today to do REST applications, but, for various reasons, I fit in there an introduction to asp.net MVC as a first part. That just doesn't flow well, and I think I'll split those two in two different presentations: asp.net MVC introduction (I have some AJAX stuff to make that presentation complete), and REST today, rest tomorrow. They can both stand on their own feet, and it would leave me more time for doing what I prefer doing: talking rather than coding and rushing.

I'm not funny

I tend to make jokes during the talk, they're usually completely spontaneous, but they fall flat every time, except for a few friendly grins from people I've met or talked to before. I shall prepare my jokes in advance and only use them after having tested them. But not on animals.

Speak more slowly

My voice level seems to be alright, but I speak too fast. And I have those pet words that creep in, amongst them "I think" (very annoying one I have a lot of problems getting rid of, even in day-to-day conversation), and Ok (very patronising, hate it, think I managed to mostly kick it off my presentations).

It's quite funny how the brain gives you those little fetish words. I think they creep-in because they trick your brain think there's a rhythm to what you're saying, when simple punctuation and sentences should be enough. It may also be the case that they give your brain enough time to reformulate when you're mid-sentence and unsure about what to say next. Again, preparation is the key.

Have different solutions, not different projects

This one bit me during the presentation. As I prepare the code for all the major steps, I end up with the same project at different stages, and I made the mistake of keeping all the projects in the same solution, often resulting in the wrong code being ran when pressing F5 and the wrong files being shown when I expected to show some code.

From now on, I'll keep all the projects in separate solutions.

Conclusion

I really like giving talks. It is a bit frustrating to come up with new material every time and only use it once, as you don't get the opportunity to retrofit what you learnt from presenting it once. Hopefully that will change as I get new speaking opportunities.

Wednesday, 21 May 2008

Presenting at the London .net User Group: Put your webforms to REST - how to build rest-y architectures with .net

What:
With the raise of the web 2.0 meme, more and more web applications claim to support REST architectures. We'll explore together what is REST and what is not, and how we can write a testable web application that supports the REST concepts on the asp.net platform, with a code-intensive overview of current toolkits (asp.net MVC and others).

Where:
MRM Worldwide London
76 - 80 Southwark Street , Bankside Studios, London SE1 0PN

When:
Tomorrow Wednesday the 21st of May, 18:30

Why:
This, I have no idea of :)

That is, if I get Visual Studio 2008 SP1 installing properly on my demo laptop, which is no small feat in itself, or face a frantic rewrite of some of the presentation tomorrow.

Wednesday, 14 May 2008

Reflecting on my last project

Today is a day off, as I've accumulated 36 hours of work between Monday and Tuesday and needed some rest. The last project I've been working on has been one of the most interesting I've had in a long time, not only because I took more responsibilities than usual, being both a lead dev and as a scrum master, but because of the amount of technology we've fetched in one app. To give a quick run-down:

  • Fluid database design with an object-based linq2sql database (no dbml file and no sql files in the whole project)
  • Sql Compact Edition
  • ado.net synchronization services to sync to a central database, and hopefully the sync framework for multi-party syncrhonization
  • WPF all the way, with a ViewModel way of developing
  • Castle stack, for Windsor and a bit of DynamicProxy2 love
  • 3G support for an always on experience

I've learnt quite a few things in the process, so here's a few reflections for my own benefits.

  • When you don't know what you're building, you're going to have a hard time knowing when it's done
  • Working under pressure can be fun, but it's exhausting and it does highlight a failure in the planning part. We're getting better but we're nowhere near there yet
  • It's fun to see people with a background go around in WPF. It always starts quite code-centric and evolves into more XAML as time goes by
  • I still don't see people using Blend for anything meaningful. There's a wide range of reasons why, from crashes to not liking esoteric Xaml to the recording model. It doesn't go down well with either populations right now, at least as far as WPF is concerned.
  • The only reasonable way to monitor the correct use of patterns and abstractions is to do it continuously. Not paying attention to the code base and coming back with changes weeks later is not a good idea, and a complete failure on my part. I need to get better at agreeing, explaining and enforcing design decisions.
  • No one can work on several projects within a company and stay focused. This doesn't work at all. From now on, I will flat out refuse to work on  something else in the same day. If you want my time for two projects, my minimum time unit will be a day. Interruption decreases my productivity so much it's unreasonable, and the project (and my nerves) suffer.
  • Frameworks that hide all of their internal implementation suck big time. Understanding object tracking in linq2sql is not easy or enjoyable, and bite you. Badly.
  • Frameworks that show all of their internal implementations suck big time. Castle Windsor (at least RC3) throws exceptions in all the wrong places, and make dealing with registration more painful than it needs to be (when it works at all).
  • Designers and UE people *need* to be involved throughout the process, and work on the same stuff as the rest of the team. The way people think they can go off and work on the UE or the design on their own schedule, with only validation from tech (when they don't send the work done the day before a release) is driving me absolutely insane. This doesn't work for them (we can tell them how much more flexibility they can have in their own design), it doesn't work for us (they provide diagrams of stuff we've already delivered, or stuff that is completely limiting the capacities of the platform). It's the typical waterfall model, and fall and fail it usually does.
  • Someone needs to wake up and realize that the technology is not there to support the design, and the design is not there to put a nice face on technology. They're two sides of the same silver coin, they need to work together to deliver. That's what Apple does and it works great.
  • I'm always amazed at how little is still invested in most of my clients companies around supporting other development teams. With a core team of a couple of peoples working to support other teams and evangelize the company's infrastructure, any company would save *so much time* on all other projects, from enforcing good standards, deployment procedures, automation etc. Think a few weeks per project.

Overall, a very good project, a great team and a freedom that I don't have very often with clients. I think it'll be difficult to move to my next project, the comparison will suffer!

alt.net drinks moved, only slightly

Got a message from Catriona, and the original location for our alt.net beers event was fully booked, so it's now around the corner from the previous location. See the original post for the details.

Wednesday, 7 May 2008

Implementing INotifyPropertyChanged with DynamicProxy2

22:30 and still working on various bits and bobs, so I thought I'd take a well deserved break to tell you about one nice way to implement INotifyPropertyChanged, the one and only interface any class that will be bound in WPF should be implemented.

I used to (circa .net 2) not see a bit issue in this kind of code.

public class MyClass : INotifyPropertyChanged

{

    private string _myValue;

    public event PropertyChangedEventHandler PropertyChanged;

    public string MyValue

    {

        get

        {

            return _myValue;

        }

        set

        {

            _myValue = value;

            RaisePropertyChanged("MyValue");

        }

    }

    protected void RaisePropertyChanged(string propertyName)

    {

        if (PropertyChanged != null)

            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));

    }

}

But I've been badly spoiled by automatic properties in C# 3.0, and this all sounds like a lot of noise. How great would it be if we could instead simply have the following.

public class MyDreamClass : INotifyPropertyChanged

{

    public event PropertyChangedEventHandler PropertyChanged;

    public string MyValue { get; set; }

}

Definitly much cleaner.  We're going to use DynamicProxy2, which is part of the Castle framework, and is used amongst other things in nhibernate.

The process is quite simple. You ask a ProxyGenerator to create a type for you, and pass it an interceptor object that will... Intercept any call!

First, let's clear up our class. Because the object generated by DP2 inherits from the original type, it needs to have a virtual modifier on the property. Furthermore, I wanted to add an attribute to specify which properties were to trigger the notification.

public class MyBetterClass : INotifyPropertyChanged

{

    public event PropertyChangedEventHandler PropertyChanged;

    [Notify]

    public virtual string MyValue { get; private set; }

}

Now, let's see how we create the object.

static void Main(string[] args)

{

    var proxy = new ProxyGenerator();

 

    MyBetterClass myClass = proxy.CreateClassProxy<MyBetterClass>(new NotifyPropertyChangedInterceptor());

 

    myClass.PropertyChanged += (src,prop) => Console.WriteLine(prop.PropertyName);

 

    myClass.MyValue = "testValue";

}

Fairly simple so far. Now let's see the meat of the code, the interceptor.

public class NotifyAttribute : Attribute { }

public class NotifyPropertyChangedInterceptor : IInterceptor

{

    public void Intercept(IInvocation invocation)

    {

        // let the original call go through first, so we can notify *after*

        invocation.Proceed();

 

        if (invocation.Method.Name.StartsWith("set_"))

        {

            string propertyName = invocation.Method.Name.Substring(4);

            var pi = invocation.TargetType.GetProperty(propertyName);

 

            // check that we have the attribute defined

            if (Attribute.GetCustomAttribute(pi, typeof(NotifyAttribute)) == null)

                return;

 

            // get the field storing the delegate list that are stored by the event.

            FieldInfo info = invocation.TargetType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic)

                .Where(f => f.FieldType == typeof(PropertyChangedEventHandler))

                .FirstOrDefault();

 

            if (info != null)

            {

                // get the value of the field

                PropertyChangedEventHandler evHandler = info.GetValue(invocation.InvocationTarget) as PropertyChangedEventHandler;

                // invoke the delegate if it's not null (aka empty)

                if (evHandler != null)

                    evHandler.Invoke(invocation.TargetType, new PropertyChangedEventArgs(propertyName));

            }

        }

    }

}

And that's it. Get the field in which the event is stored and invoke it whenever a property has been modified.

Sunday, 4 May 2008

Thought of the evening

MSBuild + SqlCompare + DataContext == FluidDatabaseDesign

The tale of the 6.4 Megapixel desktop

Just upgraded my development environment, here's the picture.

013

The laptop looks tiny next to the screen, but it is in fact a high res MacBook Pro, 1920x1200, driving as a secondary screen an Apple Cinema Display 30" for an added 2560 x 1600.

That's freakin' 6.4 megapixels of vista goodness! Surprisingly enough, Aero runs without a hitch.

Couple of other interesting points: new apple keyboard as I fell in love with the feel of the MBA keyboard, the mouse is not the one i usually have (but ran out of batteries). And Prada sunglasses for the one day of sun we've had in London so far.

As for drinks, the coffee mug is the property of the client at which I keep this equipment, and the can of Redbull kinda explains the name behind my company name: caffeine IT :)

Saturday, 3 May 2008

IIS and asp.net URL validation weirdness and links

In my Migrating to IIS7 post, I highlighted that building REST frameworks that do meaningful things with Urls is hard on microsoft's platforms.

I encourage you to go and read the comments left by Mike Volodarsky on the issue. He's a Program Manager at Microsoft. Having people from the team building IIS7 responding to people like me highlighting issues shows how some teams really engage proactively with their customers. Kudos!

The other team at Microsoft that understand REST a bit (and IMO the most out of all the teams working on this), is the Astoria team. And of course, because they do funky stuff with their URLs, they hit the same issues as me. So here's a link on how to deactivate some of the checks asp.net does. Nasty registry editing...

I really wish asp.net could recognize when an IHttpHandler does not want validation and let it handle the request, its validation and etc.

Alt.net London Beers #1

[Update: new location, see below]

Here's the latest development. The alt.net London Beers event is being moved!

Skills Matter is organizing a talk by Gojko Adzic on the Castle Framework on the day we originally planned for the drinks. As everybody has shown strong interest in attending both events, Skills Matter has been kind enough to help us organize the drinks in the Crown Pub in front of their office, so you can now attend both events.

Not only that, but they have also opened the possibility for another presentation on an alt.net subject, so if you feel like presenting, drop me a mail!

I have to thank Catriona at Skills Matter for sponsoring the alt.net London Beers event and inviting all the alt.netters to attend the Castle presentation, as well as Gojko for suggesting the merge of the two events.

So here's the recap:

We'll probably move back to the planned Tottenham Court Road location for our second meet, on the 16th of June. Keep your calendars open!