Tuesday, 28 October 2008

I am a ToolWindow

For anyone that attended Glenn’s talk.

black_tshirt_girls_FF

Monday, 27 October 2008

Alt.net OpenConf session at PDC!

For all of you alt.netters and interested parties, I just came back from the OpenConf style area next to the exhibit floor, and there’s an alt.net track being proposed.

It’s at 15:30 on Tuesday. Be there or be square! (how tacky…)

Alt.net London Beers #4 – 25th of November

If you plan to attend, please leave a comment on this entry.

I should have the time in the next few days to publish the result of the third edition of the alt.net beers. Thanks for everyone who came and made it a very successful event.

So let’s plan the date for the next one. From now on, I’ll organize the event on the last Tuesday of each month. To make sure we don’t step on each others toes, most of the UK community events now share their dates in a central location, so hopefully you won’t ever have to make a choice between all the amazing events that happen in the UK.

Following on the success of the previous events,I am happy to announce the next alt.net London Beers event. Tequilla\ has been nice enough to let us use their downstairs lounge bar, to continue with the tradition of beer-oriented conferencing.

The format is a mini openconf-style session. Here are the rules, slightly changed to learn from the previous event.

  • Arrivals, discussion and socializing between 18:00 and 19:15, with one necessity: find the topic of the day and find the questions that we will try to answer.
  • Between 19:15 and 19:30 we will vote on the subject we want to talk about, in two rounds, by raising hands.
  • At 19:30 the big clock will start ticking for a time-boxed 60 minutes workshop on the subject. The goal is simple: can we as a group get insight and progress our understanding of the problem.
  • At 20:30 the clock will ring and that will be it of the conversation. Everyone will be invited to fill-in a wiki with a one or two line answer to two questions: what did you want to get out of the session, what did you get. The goal is to capture a snapshot of the state of mind at the event, and to be able to compare those with the result of our reflections that, I’m sure, will be extensively shared on blogs, mailing lists, twitter, etc.
  • Once this is all written down, everybody will be able to continue the discussion in the pub or wherever they see fit.

The location:

TEQUILA\ London Limited
82 Dean Street
London, UK
W1D 3HA


View Larger Map

We’re always looking for new locations and one or several sponsors. If you or your company is interested, pop me an email seb@serialseb.com.

Sunday, 26 October 2008

PDC tomorrow, WeHo tonight

Anyone wanting to come for dinner / drinks in WeHo (gaying PDC up a bit), or meet from tomorrow, phone number is +44 7789 00 8282 :)

Friday, 10 October 2008

Being in a printed program again

I just got confirmation that you voted for one of my sessions for DDD. I’m thrilled! It’s going to be an absolute pain to write the material needed to get what I want out of it, but the community and the people attending will choose the content, which I am very excited about.

And on the same level of excitement, the VBUG annual conference will be receiving yet another game of Bingo with me delivering a more polished version of the MVC talk I gave in London and Brighton.

The interesting bit about the VBUG conference is the printed agenda. I need to get a proper speaker picture, because the one I gave looks dreadful. Actually, the picture is alright, but I look dreadful :)

Seeing my face on that leaflet reminded me of the leaflets I received for various conferences I attended and spoke to, on peer-to-peer networks, back in 2000.

Interesting how life can seem like a rollercoaster sometimes, but is all but cyclic. You raise, you fall, you learn. I’ve been truly blessed in 2008 to meet fantastic people and go back in the speaking circuit, meeting countless amazing people and working on exciting things.

All this just to thank the people that listen to my rants when I give talks, the London .net User Group for getting me back in the speaking mood and giving everyone the opportunity to do it, the absolutely brilliant community we have in the UK, to the alt.net crowd, to the non alt.net crowd, and even to the Entity Frameworks proponents :)

Monday, 6 October 2008

While I’m in a ranting mood…

Seen in the wild.

        /// <summary>

        /// This is only for Unit Test Use

        /// </summary>

Code is not shown to protect the guilty, but it’s a method to set a property on an entity class.

Multiplying project files…

I was going to have yet another rant on separating everything in a ridiculous amount of project files, to ensure separation, and started venting to one of my colleague, at which point he mentioned Jeremy just posted on the issue: Separate Assemblies != Loose Coupling. Amen.

Thanks Jeremy, that saves me a post.

Sunday, 5 October 2008

HttpResponse.Flush forces Chunked transfer…

That one took me quite a while to understand. I’ve been building the integration tests for OpenRasta, a bunch of classes that configure a full web-server and run a real request-response scenario. This should hopefully help in limiting regressions, and may also be used in the future to ensure continuous compatibility with IIS6 on plain .net 2.0.

I’m leveraging the kernel http support present since Windows XP SP2 to create an http listener dynamically and initializing the asp.net runtime inside it, though the very useful HttpListener class.

After a lot of debugging, I discovered that my test was failing because of an encoding issue. Instead of returning the content that was sent to it by OpenRasta, an 18 bytes string, I ended up with much more than that, with line breaks in the middle. A quick look at the returned headers and it became very obvious that the system was sending me back chunked-encoding, a process by which the data is sent in blocks, each prefixed with the size, and suffixed with entity headers. The thing is, there is no support at all yet in OpenRasta for chunked encoding.

Here is the block of code causing all thesetroubles.

        public void ProcessRequest(HttpContext context)

        {

            IRastaContext rastaContext = RastaConfiguration.GetService<IRastaContext>();

            rastaContext.SetContext(context);

 

            _pipeline.Run(rastaContext);

 

            context.Response.Flush(); // <!-- see that one?

        }

As you can see, I was calling Flush on the HttpResponse object in the IHttpHandler that runs the OpenRasta pipeline. I quite understand the reasoning behind switching transparently to chunked encoding when requesting a data flush, you want to clear the data queue by sending it to the client, but you do not know yet how much data you will send later. At that point, using Content-Length is not possible, and chunked encoding is the only way to achieve the desired result.

Looking at the msdn documentation for HttpResponse.Flush you will notice there is no mention of that behavior. But not to worry, other developers thought it may come handy to document, and you will find the following on the mono documentation.

HttpResponse by default will buffer all of the output before it is sent to the client. To control the delivery of the data developers can use this method (or alternatively set the HttpResponse.Buffer property to false).

If chunked transfers are enabled for this response, this will try to use the chunked transfer.

Elementary, my dear Watson.

Once upon a time, code I wrote…

  After installing Windows Live Photo Gallery Beta, I noticed that it automatically indexed files shared on my big tera-server. And below is a nugget from code I’ve lost a long time ago, back when I was helping write a failed emulator for Dark Age of Camelot. A C# OpenGL reader that could render models of the game.

CamelotSharp Nif Viewer

Saturday, 4 October 2008

Track me down!

Added to the site, the calendar of which events I’m attending. That way, anyone wanting to give me a million pound, or punch me in the face, and everything in-between, will know where to find me :)

Thursday, 2 October 2008

OpenRasta status update

This entry may be outdated. For the latest updates on openrasta, see www.openrasta.com.

A couple of people have access to the code and have been kind enough to give reviews. I’m always open to more people helping out in the very early design phase before I go all public with the framework I’ve been nagging everybody about for months and months, so pop me an email to seb@serialseb.com and I’ll give you access. OpenRasta will be under an MIT license and I’ll publish it all to the world. I need to ensure what needs refactoring before release is refactored and that it is a fully functional beta first.

So here is what can be done with OpenRasta now and what I’m currently working on. See it as both an announcement and my task-list to the runner-up to the official release. You can refer back to the previous version of OpenRasta I already introduced. For various reasons the original Rasta never made it to open-source and its code has now died, and as far as I know no one will maintain it. OpenRasta is a fresh take on it, but keeps the same configuration API and the same concepts in a fresh new format with fresh new codes (and fresh juicy unit tests).

So by now you know there are essential components in OpenRasta: URIs, Resources, Handlers, Codecs and the pipeline.

The framework

  • OpenRasta.dll contains the bulk of the implementation, and compiles successfully on the .net framework 2.0 and on Silverlight. Great for embedding OpenRasta in your traditional asp.net application and start migrating your code over. And why not provide a REST-friendly server from the .net Compact Framework? (starting to sound like a marketing drone there)
  • The silverlight support will eventually provide for duplex http so you can architect your RAI test-first and REST-friendly, reduce coupling, and enjoy your life more. IN PROGRESS.
  • Most of the features are implemented straight into OpenRasta, such as dealing with form content-types browser send you. That means no reliance on some of the asp.net limitations on file uploads.
  • OpenRasta.Server.dll is your asp.net integration point, with support for traditional IIS6 and Integrated IIS7 modes.
  • Did I mention OpenRasta runs on asp.net 2.0? Alongside your webforms?

The pipeline

  • The pipeline is a series of pipeline contributors. They all act upon a small area of functionality, change a couple of things and give control back. The good news is that you have full power to change any of the existing contributors, add your own, etc. The default pipeline has 17 components which support the execution of the whole system.
  • Each contributor registers when it wants to be executed, and it is always relative to another contributor. The pipeline, once initialized, builds a chain of calls and execute them sequentially. And there is a small type that will let you register for multiple steps in the pipeline and be called only when you are ready.
  • You can add and remove contributors at configuration time to replace or modify existing behavior. IN PROGRESS.

URIs and URI decorators

  • You define your resource Uris using the common http template syntax. It’s a clean-room implementation of the .net 3.0 UriTemplate and UriTemplateTable classes to run on 2.0. It will support both the 3.5 modifications and some extra features sometime in the future. May donate the code to mono if their implementation hasn’t progressed much.
  • Several Uris can identify the same resource, but in different languages. /home and /accueil will automatically set-up everything you need to override the default client’s language.
  • Of course, in any real-world scenarios, your URI doesn’t only describe an abstract resource that is easy to name. There are plenty of little tidbits of things you may want to include, such as the document type (.html anyone?), the language (/en/mydocument), maybe even the version (/en/mydocument(v1)). Most frameworks would have you declare all the combinations of those urls to design your resources. In OpenRasta you simply define a Uri decorator that will change the way the request is processed and clean-up the Uri before passing it on for processing. Out of the box, you’ll have document types, language, http method overrides (for those nasty PUT you want to do from your html forms) and view selection (for when one resource have several views applied to it).

Handlers

  • Once your Uri is matched to a resource, a handler is going to be selected and one of its methods called.
  • You don’t have to inherit from anything, or implement any interface.
  • You name your method using the name of the http method the client sent you. Want to send data? Implement a Get(). Want to append data? Implement a Post().
  • Sometimes you want more meaningful names. Just declare a small attribute to map the correct http method to the correct clr method.
  • Parameters are declared naturally, without multitudes of hacks, strings or attributes. The codec will be responsible for mapping whatever the client sent to whatever CLR types you are expecting. The framework will map your url templates to your parameters too.
  • Want optional parameters? Add an [Optional] attribute. Want a default value? Enter [DefaultValue]. And any CLR language implementing default values will support those too. I think that includes the VB guys :)
  • You can even have parameters that map to http headers.
  • Your handler method returns what makes sense to you. Don’t want to return any resource to your client? Discover the joy of the void return type! Always return a type? Just declare that type as the return type. And when you want to return RESTful information, simply return an OperationResult.
  • Your handler only select objects, not views or other things that doesn’t concern it. You return an object and a Codec will render it to the client.
  • And of course, you can add plenty of filters that execute before and after the method calls. A logging filter (IN PROGRESS) and a Principal security filter come out of the box, so you can get people to authenticate.

Codecs

  • A resource can be read and written from and to an http connection using Codecs. Some are provided in Rasta (json, xml, html, html form data), and writing one is brain-dead easy.
  • You can let the client decide which content-type it will receive by using well-established content-type negotiation semantics. It’s all done for you. And it even serves application/xhtml+xml to firefox without you having to touch a line of code.
  • When sending data from html forms, <input name=”customerName” value=”value” /> will call Post(string customerName);
  • Ok, everybody does that. When using <input name=”Customer.Name” value=”value” /> this will call Post(Customer customer) with the correct property done for you.
  • Ok, most MVC frameworks do that. When using <input name=”AddressOf(Customer).PostCode” value=”value” /> this will call Post(AddressOf<Customer> customer) with the postcode property set.
  • Ok, some MVC frameworks do that. When using immutable types, <input name=”Customer.DateOfBirth.Date” value=”12” /> the method Post(Customer c) will be called with the date set on a new date of birth. And you can set property chains as far as you want, and write to read-only properties. Convinced yet?
  • Ok, maybe some MVC frameworks may be able to do that. When using <input name=”Customer.DateOfBirth.Date” value=”12” /> the method Post(ChangeSet<Customer> c); will be called, and you can update your objects with whatever changes are being sent through.
  • Oh, and the same stuff can work with other content-types too. Implementing http patch has never been that easy.
  • Codecs also can use different views. Want to have one page to view and one page to edit your customers? Just declare a view using TranscodedBy<WebFormsCodec>(new { index = “~/CustomerView.aspx”, edit = “~/CustomerEdit.aspx” });
  • The return data depends on what the client requested. And that includes error pages, 404s, 401s, etc. IN PROGRESS.
  • You can stream data from the client rather than have asp.net download everything for you, for any multipart type. IN PROGRESS.

And the rest

  • Http Digest Authentication out of the box. IMPLEMENTED. With time-sliding security window and logoff functionality! IN PROGRESS
  • An error mechanism for your webforms to manage validation errors while still returning RESTful status codes, that still renders correctly when dealing with json, xml, etc. IN PROGRESS.
  • Everything, and I do mean everything, goes through an IoC container. If you don’t use one, OpenRasta use its internal one. If you use one, OpenRasta automatically registers all its dependencies in it. Comes with a Windsor Castle implementation.
  • All the configuration can be done without a single attribute anywhere, either by leveraging conventions or using the fluent configuration API.
  • Automatic cache management based on your resources (including Last-Modified and ETags). IN PROGRESS.

What to look forward to in beta 2

  • VB9 XML literals, NHAML and NVelocity view engines. NOT STARTED.
  • Full AtomPub support. NOT STARTED.
  • StructureMap support. NOT STARTED.
  • An additional configuration mode for the attribute junkies that will scan your assemblies and configure OpenRasta automatically. NOT STARTED.
  • Support for asynchronous operations (need to define the exact use-cases for this first). NOT STARTED.
  • An optional reverse cache for your handlers. NOT STARTED.

Way past my bed-time. That should give you a good idea of where I am at with OpenRasta and what kind of things it will enable you to do. Email me to peek at the code before anyone else!

Wednesday, 24 September 2008

Porting the Suteki Shop to OpenRasta

Mike Hadlow has just announced the commercial release of Jump the Gun, an online shop based on his Suteki Shop cms. Mike is an extremely bright guy that I’ve met quite a few times at various conferences, and he’s built it all on asp.net MVC.

Because OpenRasta doesn’t have much of a documentation at the moment, and because it would be nice to have a comparison between the two systems, I’ve offered Mike to start porting Suteki to OpenRasta sometime over the weekend. The good news is that it will live side-by-side with the existing Suteki Shop. I’m leaning towards calling it Sutekool :) . And then we’ll be able to compare the performance and flexibility of both frameworks. I’ll porbably learn a lot in the process,

Thanks Mike for the great work and for the opportunity of having the first side-by-side comparison of asp.net MVC and OpenRasta! Now if we had someone porting it to monorail, we could have a real overview of what the .net MVC world has to offer.

Sunday, 21 September 2008

Building a new server at RapidSwitch

I’ve been on the lookout for a windows server 2008 server for quite a while, and have now selected one. The thing that surprised me in my search has been the complete lack of professionalism exhibited by some hosts on their websites.

  • If you don’t tell me where your datacenters are, you probably don’t have datacenters and are just reselling.
  • If you don’t provide your company details on every single of your pages (hint: uk limited companies *must* provide their company number, vat registration number, registered office and full name, including “limited” or “ltd”. copyright midnight software is *not* enough), I don’t know who you are and for all I know you don’t actually have a company.
  • If you don’t provide an SLA, I do not trust you will apply it.

So with all those, 90% of the hosts I found selling Server 2008 hosting were out. RapidSwitch seems to have had good reviews, so I just created an account, and have had two tickets in the last few hours telling me my server was now racked and the OS is installing, from a gent called Kyle. Although I am pretty sure Kyle is a bot, it’s still very nice to know what is going on.

I’m going to keep this post open to give my feedback on their service as I use them. They are confident enough in their service to not tie you to a 12-month contract. Depending on how things go in the next couple of weeks, they'll probably sign me for 12 months or loose me. Kudos for leaving the customer in control.

Roll Server 2008!

Wednesday, 17 September 2008

The content of the presentation at VBUG Brighton tonight

As last time I got completely overloaded with work and forgot to post the content of the demo, this time I’m doing it the other way around. Code is available on my public mug (get it? caffeine-it, mug, public? Funny? No? Oh well). Point your favourite svn tool to

http://svn.caffeine-it.com/mug/bingo

From the command line

C:\> svn co http://svn.caffeine-it.com/mug/bingo bingo

Will add the updates I’ll tweak till then and the powerpoint slide sometimes tomorrow at the same place.

See you all tonight in Brighton, or over the next two days at Mix!

Monday, 15 September 2008

Alt.net London Beers #3 – 14th October 2008

Following on the success of the previous events,I am happy to announce the next alt.net London Beers event.

The format is going to be different from the previous event, as it will be a sort of mini openconf-style session. Here are the rules

  • Arrivals, discussion and socializing between 18:00 and 19:00, with one necessity: find the topic of the day and find the questions that we will try to answer. We may provide post-its, white boards or body painting equipment to help people focus.
  • At 19:00 the big clock will start ticking for a time-boxed 60 minutes workshop on the subject. The goal is simple: can we as a group get insight and progress our understanding of the problem. The specifics of the format will probably change when we get there, but I’d like us to focus on up to 4 questions.
  • At 20:00 the clock will ring and that will be it of the conversation. Everyone will be invited to fill-in a wiki with a one or two line answer for each of those questions. The goal is to capture a snapshot of the state of mind at the event, and to be able to compare those with the result of our reflections that, I’m sure, will be extensively shared on blogs, mailing lists, twitter, etc.
  • One this is all written down, everybody will be able to continue the discussion in the pub or wherever they see fit.

Please leave comments here and everywhere you feel relevant, or hit me on twitter, to suggest topic ideas or to provide criticism of the whole concept. Without feedback one cannot separate success from failure, and recognizing those are necessary to progress and improve.

If your company wants to invest a bit of money behind the bar for food and drinks, don’t hesitate to let me know.

And of course, the location is the same as the previous event, and I have been told the kitchen staff will stay a bit longer for us this time.

The Blue Posts
18, Kingly Street
London W1B 5PX


View Larger Map

Wednesday, 10 September 2008

Developing .net code since 2000?

Over the years, I’ve had a couple of people in interviews being surprised at my assertion that I started development on .net in 2000. As I go through yet another cleanup of my email archives (I’m an archival freak) that are reaching around 15GB of data, I found this email.

From: DeveloperStoreAdministrator@developerstore.com [mailto:DeveloperStoreAdministrator@developerstore.com]
Sent: 14 November 2000 03:09
To: …
Subject: Thank you for your recent Microsoft purchase

Thank you for visiting our store, Sebastien P. Lambla.

Your order has been entered into our ordering system, and will be delivered to you soon. At that time, the charge of $15.99 will be charged to your credit card.

This is an unmonitored email alias. Please do not reply directly to this email alias as the messages will not be answered. If you have questions or would like to check on the status of your order, please email us at mstoolbox@interactservices.com.

Refer to order number MSDSTB129915 when contacting us.

Thank You,

Microsoft Developer Tools

This was the first beta of visual studio. 8 years of C#, how time flies!

Friday, 5 September 2008

Kaizenconf is open

For those that were waiting for the kaizenconf registration to be open, it now is. But it’s not really a registration, it’s a request for a registration. So if I understand that correctly, I still don’t know if I’ll be there or not.

If you come from good old Great Britain, I’d recommend booking anyway. With the sterling going down, cancellation fees will probably be cheaper than waiting and see your money be half what it was.

Tuesday, 2 September 2008

Work availability

If you’re looking for help with your project and need a consultant, I’m available for the first two weeks of October. And if you’re looking for a developer / lead developer, I’ll be available from mid-November!

So don’t hesitate to contact me at seb@serialseb.com and cut some of those agencies cost!

Monday, 1 September 2008

Vote now for DDD!

Quite many very interesting session proposed for the next DDD.

Go and vote now for your favorite sessions (and if you don’t like any, you can always vote for mine!)

Sunday, 31 August 2008

The case of global.asax not being executed in IIS7

Global.asax is used in both asp.net MVC and OpenRasta for implementing your configuration. In Rasta 1.x, the handling of request was done through a catchall http handler. This has a couple of adverse effects for the application: all requests went through rasta first, and got delegated to IIS when there was no match. This can cause a range of performance issues, from lack of caching to constant file access when the delegation ends up using DefaultHandler rather than StaticHandler, as in those instances the files will systematically be streamed from the disk.

Another struggle I had with this system was the various issues encountered when trying to host the system on IIS7, something I started doing a while ago. I remembered reading from a blog that asp.net MVC was using both a handler and an http module, and investigated using a similar configuration for OpenRasta. As I do not want to be influenced by other people’s coding abilities, I have stayed away from reading the asp.net MVC source-code and tried to come up with my own scheme.

One particular issue comes from the different framework versions supported by OpenRasta: I run on plain old asp.net 2, and this means that all the new APIs that let you change a handler on the fly during a request will not work, as they are added by .net 3.5 sp1. Instead I came up with a clever trick: Just before the handler is resolved, I rewrite the url to a fake url, properly called ignoreme.rastahook. The extension rastahook is always associated with a compatibility handler that then gets called by the asp.net infrastructure, at which point I rewrite the url to what it was before the change, and execute my own http handler from there. The solution is not entirely perfect yet, as there is no support for asynchronous handlers, but as with every other part of OpenRasta I’ll be able to change that without impacting any handler already in existence.

As soon as I implemented those changes, everything went much more smoothly on IIS6 and cassini (the visual studio web server), but broke completely on IIS7 integrated mode on my local box. After much debugging, I realized that my global.asax wasn’t being called. When I added back an http handler to my web.config, the global.asax code was called again.

The reason is a bit confusing to understand at first. In IIS7 integrated mode, http modules are treated as being part of IIS, be it that they are managed or not. This means that a module may or may not rely on asp.net. Your module will be executed but your web app won’t necessarily have been compiled. Handlers on the other hand, when they are managed, trigger the asp.net application, and your code will get executed.

So to conclude this issue that i’ve been chasing for two months now: if you don’t have a managed http handler for your request, your http module will be called but the asp.net part of your site will not have been compiled and / or won’t be called, including global.asax. The solution is to ensure you have a managed handler in place, or force a compilation of the root site using BuildManager.GetReferencedAssemblies.

P.S.: this is all based on empirical evidence, so I may be absolutely wrong, and would be glad for anyone to come up with an alternative explanation.