in

ljusberg.se

Smöråkning

  • Windows Server 2008 as development platform

    Well, this is going to be interesting. I've spent the day installing Windows Server 2008 on my brand new laptop at work. I was inspired by Mikael Deurell's post about using Hyper-V etc.

    So far it's been much easier than I expected. Pretty much all device drivers for my Compaq 8510w installed without any problems even though I'm using a 64-bit system.

       

    I also found two great blog posts that describe how to make the Windows Server 2008 experience a little more "Desktoppy". Check out:

     

    Also, this is an attempt at posting using Word 2007.. Let's see how that works out..!

  • Scrum Dashboard

    If you're a fan of Scrum and Team Foundation Server you'll probably want to have a look at the Scrum Dashboard recently published on CodePlex by EPiServer. It looks very cool but unfortunately for us it uses the Scrum for Team System templates by Conchango instead of the "vanilla" MSF Agile templates that we're using. Too bad for us, but I applaud EPiServer for making this thing available to the community. Thank's guys!

    BTW, I actually met the guy listed as Coordinator of the project (Per Bjurström) on my trip to Redmond last October - that has to be a good sign, right?

     

    Posted Feb 28 2008, 11:16 PM by anders with no comments
    Filed under: ,
  • What's up?

    I know, I know.. I've been extremely lazy lately, at least when it comes to sharing knowledge with you guys. I guess the main reason for that is that I'm currently on parental leave which means that my days are not really spent researching, architecting and developing as much as they are spent entertaining Miranda...

    Anyway, as you may have realized by my previous posts on the subject, I've been diving into the big swamp of ASP.NET once again. Somtime mid-last year I was tasked with creating a new plattform for the web sites at Thomas Cook Northern Europe (like ving.se, spies.dk, tjaereborg.dk and ving.no). The platform that is currently running all our sites is quite powerful but was designed with .NET Framework 1.1 in mind which makes it a bit clumsier than it has to be.

    At the time, the only web site framework on offer from Microsoft was the Web Client Software Factory. I really liked the ideas and patterns that drive the architecture of the WCSF (in pattern-talk I guess you would describe it as Model-View-Presenter combined with Application Controllers). However, it simply wasn't enough for our needs. The major problem was that the Views/Presenters are to coarse. They are designed with entire pages in mind instead of being designed for User Controls (which is what we need). I also didn't like the fact that the flow engine they used couldn't handle multiple flows and states per session/user. A quite common scenario for us is that a user opens up several browser windows to compare different alternative trips - something that often leads to corrupt state.

    In the end I decided to create a framework from scratch with much of the ideas from the WCSF intact, but extended to fit our needs. Some notable features:

    • Based on the Model-View-Presenter and Application Controller patterns.
    • Independent modules for each area of the web site which makes it possible to develop and deploy parts of the web site without affecting the other parts.
    • No .aspx files - pages are built up dynamically.
    • Multiple flows per user
    • Fully integrated URL Rewriting

    Well, if you're interested I'll blog some more about this. But at least now I've given you an update on what I'm doing..

    Update (2008-02-28)

    Funny, the day after I wrote this entry, Microsoft Sweden published a "success story" about the project (although the story focuses more on the way we are using TFS and VS 2008 rather than the framework itself). I had no idea this article was being written, but I guess that's what happens when you're on parental leave.. :-)

    Also, you might be asking yourself "How on earth do you make sure that things are going in the right direction if your not in the office?". Well, luckily I've been able to hand over the framework in the very good hands of my colleague Håkan (who also gave me a lot of great advice during the first stages of the project). If you've read this far, you'll certainly find his blog even more interesting, and as a bonus it's available in English and Swedish.

  • How cool is this?

    I'm currently writing this post on the express bus to Redmond using my iPod touch and the free WiFi provided on the bus. In my book it doesn't get much cooler than that!
    Posted Oct 27 2007, 01:44 AM by anders with no comments
    Filed under:
  • T4 editor available

    It seems Clarius Consulting have released a beta version of a pretty nice addition to Visual Studio, at least if you're working with the Guidance Automation Toolkit. The T4 Editor will give you IntelliSense, nice colorization etc when working with your T4 templates.

    I'm now just waiting for them to release a version of the Software Factories Toolkit that works with VS2008 Beta 2..!

  • VS2008 RTM any day now?

    According to the Microsoft guys in building 20, the RTM of Visual Studio 2008 and .NET Framework 3.5 is coming "very, Very, VERY soon" - whatever that means...

  • Going to Redmond!

    Well, in a couple of days I'm off to the Microsoft Campus in Redmond! I'm attending an Orcas Adoption Workshop next week which will take me through all the new stuff in Visual Studio 2008 and .NET Framework 3.5. So far, I haven't got the agenda so I have more or less no idea who I'll meet and what kind of workshops to expect but I'm sure it'll be great.

    I'm really, really looking forward to it. Actually visiting the Campus is something I've been dreaming about for quite some time (yes, I know.. maybe I should try to reprioritize my dreams... but still!) 

    So, is anyone else going to be in the Redmond area next week?

  • Caching dynamic controls in ASP.NET - solution

    In my last post, I asked for help with a problem we've been having with caching of dynamic controls - and I got some from Dave Reed. Dave works for the ASP.NET team and if his blog isn't on your roll yet, add it ASAP - it's simply brilliant.

    Dave explained the problem:


    Apparently, the stack trace involved with loading the control is taken into account when deciding how to cache the controls output. So for example, if you load the control twice like so:
    LoadControl("foo.ascx"); // once 
    LoadControl("foo.ascx"); // twice
    Then they will be cached separately. But if you load them like this:
    MethodThatLoadsFoo(); // once 
    MethodThatLoadsFoo(); // twice
     
    Where MethodThatLoadsFoo contains:
    LoadControl("foo.ascx"); 
    They are cached together because it will appear that they were loaded via the same code line.
     
    Since you are loading them dynamically based on data you probably have a single method that loads whatever control it is to be. But depending on the details of your implementation perhaps you can find a way to have a different LoadControl reference load each one?


    Ok.. So where does that leave us? Remember, the implementation that calls LoadControl in my last example looks like this:

    foreach (ControlInfo controlInfo in controlList)
    {
       // Load the control and add it to the page
       HttpContext.Current.Items["uniqueId"] = controlInfo.UniqueControlId;
       Control ctrl = LoadControl(controlInfo.ControlUrl);
       PlaceHolder1.Controls.Add(ctrl);
    }

    It is the same physical line of code that loads all controls, which makes the caching mechanism believe that it is the very same control that is being loaded. In order for it to cache multiple versions, I'd need to add a new LoadControl line for each control. So I guess I could "unwrap" the foreach-loop and do something like:

    if (controlList.Count > 0)
    {
       HttpContext.Current.Items["uniqueId"] = controlList[0].UniqueControlId;
       PlaceHolder1.Controls.Add(LoadControl(controlList[0].ControlUrl));
    }
    if (controlList.Count > 1)
    {
       HttpContext.Current.Items["uniqueId"] = controlList[1].UniqueControlId;
       PlaceHolder1.Controls.Add(LoadControl(controlList[1].ControlUrl));
    }
    if (controlList.Count > 2)
    {
       HttpContext.Current.Items["uniqueId"] = controlList[2].UniqueControlId;
       PlaceHolder1.Controls.Add(LoadControl(controlList[2].ControlUrl));
    }

    Ehh.. Nope.. Not gonna happen...

    The only other alternative I could think of was to dynamically generate and compile the code that is used to render a page. This is (a crude version of) what I came up with:

    private void CompileAndInitializePage(Page page, List controlList)
    {
      Assembly compiledAssembly;
    
      // Has this page been built before? If so, there should already be an existing assembly
      // compiled for it.
      if (compiledAssemblies.ContainsKey(page.AppRelativeVirtualPath))
      {
        compiledAssembly = compiledAssemblies[page.AppRelativeVirtualPath];
      }
      else
      {
        // If not, compile a new one.
        string mainHeader =
          "using System.Web;\n" +
          "using System.Web.UI;\n" +
    
          "namespace DynamicCacheTest\n" +
          "{\n" +
          " public class TempPageBuilder\n" +
          " {\n" +
          " public void BuildPage(Page page)\n" +
          " {\n" +
          " Control holder;\n" +
          " holder = page.FindControl(\"PlaceHolder1\");\n";
    
        string mainFooter =
          " }\n" +
          " }\n" +
          "}\n";
        StringBuilder sb = new StringBuilder(mainHeader);
        foreach (ControlInfo ctrl in controlList)
        {
          sb.AppendFormat("HttpContext.Current.Items[\"uniqueId\"] = {0};\n", ctrl.UniqueControlId);
          sb.AppendFormat("holder.Controls.Add(page.LoadControl(\"{0}\"));\n", ctrl.ControlUrl);
        }
        sb.Append(mainFooter);
    
        ICodeCompiler compiler = new CSharpCodeProvider().CreateCompiler();
    
        CompilerParameters parameters = new CompilerParameters(new string[] { "System.dll", "System.Web.dll" });
        CompilerResults res = compiler.CompileAssemblyFromSource(parameters, sb.ToString());
        compiledAssembly = res.CompiledAssembly;
        compiledAssemblies[page.AppRelativeVirtualPath] = compiledAssembly;
      }
    
      // Build the page builder object
      object builder = Activator.CreateInstance(compiledAssembly.GetType("DynamicCacheTest.TempPageBuilder"));
    
      // Invoke the BuildPage method
      builder.GetType().InvokeMember("BuildPage", BindingFlags.InvokeMethod, null, builder, new object[] { this });
    }

    And it works beautifully! I'm not too worried about performance since I'm only compiling the page once, and running the compiled code shouldn't be slower than the foreach-loop is today. The only thing I'm thinking is that with many pages on a site I'd have a lot of very small assemblies loaded. Probably it would be a better idea to precompile all pages on startup and put them in a single assembly.

    Anyway, in the end we've decided that we won't actually put this in production since the problem probably is better worked around by educating our webmasters, but it was nice to finally find a solution.

    Update: I've attached the updated source code to this post.

    Update 2: And now I'm trying out a Live Writer Plugin to format the source code

    Posted Oct 17 2007, 09:39 AM by anders with 6 comment(s)
    Filed under: ,
  • Caching dynamic controls in ASP.NET

    Since the invention of partial caching in ASP.NET, we have been trying our best to implement it on our web pages. But without much luck. This post is a request, or I guess you could call it a "cry", for help!

    The problem is that we create all our controls dynamically, and each page can contain more than one instance of the same control (.ascx) but with different content.

    Simply put, a page load is currently done like this:

    1. Retrieve a list of which controls to put on the page and the unique id of the content each control should display.
    2. For each control that should be created, call LoadControl and let the control know its unique id.
    3. Each control retrieves its data by using the unique id

    Now, when trying to add partial caching to this control, the problem is that the controls are cached according to which page they're on (or the query string used to get the page) and I just cannot figure out a way of caching two different instances of the same control. I mean, at the time of creation (LoadControl) I know which one I want, so it really should be theoretically possible, but I simply cannot find support for it in the API.

    I've attached a simple test project that illustrates the problem. If you can find a nice solution, please, PLEASE let me know. I'd be in your debt!

  • The new SOA

    This is going to be confusing for me.. There's a new SOA in town: Lord of the Rings Online: Shadows of Angmar (or SoA). Let's just hope they'll continue to use the abbreviation LOTRO instead..

    Posted May 30 2007, 10:15 AM by anders with no comments
    Filed under: ,
  • Online course from 2xSundblad

    I've just looked through a part of the preview of the coming online course from 2xSundblad called Architecting Service Oriented Systems – Overview. It's Flash-based with a mix of video, audio and slides. Looks very promising and it will be available for a very reasonable $399 (if you register your interest early you'll even get a 25% discount).

    I guess you'll have to get used to the Swedish accent of Sten and Per, but knowing them I can promise you it'll be worth it!

    Three other courses will be available within the next year or so:

    • The Infrastructure of Shareable Information Pattern – Planning, Architecting, Designing, and Implementing.
    • The Entity Services and User Application Pattern – Planning, Architecting, Designing, and Implementing.
    • The Business Process and Use Case Services Pattern – Planning, Architecting, Designing, and Implementing.

     I'll post a link to the free preview once I get an OK from Sten or Per to do so!

    Update

    Here's the link to the preview of 2xSundblad's new online course.

  • The Agile pyramid

    One of my favorite developer sites, Worse Than Failure (used to be called The Daily WTF), just published an article about Agile methodologies and why they suck. While I don't agree with Alex it's always fun when an analogy is turned upside down... The problem here is that the Pyramid analogy is flawed in the first place since an extremely important part of agile methodologies, Refactoring, is missing. Instead, building a pyramid using agile methodologies would rather be done this way:

    1. Get some initial input from the Pharaoh. It will be something like "I'd like it to look like all the other pyramids, only bigger and better".
    2. Start building something that may or may not look much like a pyramid.
    3. Find some flaws in your design. Show the Pharaoh and ask him what he thinks of it so far.
    4. Tear down everything you or the Pharaoh don't like.
    5. Add some more components to the pyramid.
    6. Realize that the foundation of the pyramid isn't solid enough.
    7. Rebuild the foundation
    8. Repeat steps 3, 4 and maybe 5 and 6 until you and the Pharaoh are happy with the result.

    And this is why agile methodologies are better suited for software development than for construction work...
     

  • Code beauty

    It's pretty clear that there are two basic kinds of developers; those that write code only to get the job done, and those that write code which in addition to getting the job done also looks good. I'm definitely part of the latter group and I have to say that sometimes I get frustrated when working with developers of the former conviction.

    I was just reviewing some code written in a project I haven't been involved in much, and found a set of very commonly used classes that lie in a namespace that is misspelled. I realize this doesn't matter. I mean, the code does exactly what it's supposed to do and the misspelling is so simple that everyone understands what it was meant to be called. But c'mon! Correcting the mistake would take about 2 minutes thanks to the refactoring functionality in Visual Studio.

    Now to the difficult question... Should I mention it in my review?

  • Enterprise Library 3.0 available

    Can't believe I almost missed this completely! Turns out the P&P team released Enterprise Library 3.0 the other day. For me, the two most interesting new features have to be Environmental overrides and the new Validation Application Block. I'm also very happy to see a rolling trace file listener included in the Logging Application Block - I checked our production servers the other day, and some of the logfiles where a couple of gigabytes each.. not good.. not good at all..

  • Community Server 2007

    The guys over at Telligent released the much longed for new version of Community Server. And they did it right on schedule! Very impressive!

    I spent a couple of hours yesterday upgrading my 2.1 installation and it all went pretty smoothly. Haven't checked out the new theme engine yet, but maybe I'll get around to that.

More Posts Next page »
Powered by Community Server (Non-Commercial Edition), by Telligent Systems