ASP.NET Hosting

Archives

Archives / 2004 / January
  • Coding unit tests is even harder than you think

    Jamie Cansdale has put a nice application online he calls Code Blog. This application expects you to write an implementation based on a set of unit tests.

    This app shows how difficult Test-Driven Development (TDD) is.
    Just look at the submissions for sorting a list (first challenge). They all work, but one was coded specifically for the test and won't work with something else but an ArrayList, and the other two depend on what you really want: a copy of the list or the list itself being sorted?
    Jamie discussed about this.

    If you look at the current challenge, for the TestToPlain8220() method, you'll realize that it's possible to code for that specific value "“", but the resulting method would not work with "‛" or "”"...

    Just simple examples that TDD is hard, very hard. You have to accept that your unit tests will never be 100% complete. Code passing your tests cannot be considered bullet proof. It's just code that works with your tests.

    Read more...

  • 389

    There have been a lot of additions and updates lately at the SharpToolbox. The counter is now at 389 tools and libraries. Many additions are still in the pipe. Maybe it's time you subscribe to the RSS feeds to know when new tools are added or old ones are updated...

    Note: The data on the SharpToolbox doesn't change many times a day. If you use some RSS reader software, setting the refresh interval to 1 day should be enough.

    Read more...

  • Web browser market: is the battle over for everyone?

    I don't like seeing "web browser" and "market share" in the same sentence. This is typical. This is why there is no new release of Internet Explorer. Microsoft was there to take Netscape down, but there is no Microsoft when standards compliance and user friendliness are concerned.

    Is the web browser dead? It is dead as a product. From a user perspective you should see things differently. How much do you use your browser? Think about it.
    I guess Microsoft is working on something big secretly to keep their mouth shut and take no action regarding the web browser. And don't tell me I have to wait until 2006 and Windows Longhorn!
    Other players such as Mozilla are doing a great job on standards, user friendliness, extensibility and efficiency. You should support them for that reason.
    I don't really count players such MyIE2 or AvantBrowser in as they rely on IE and so have the same problems regarding standards.

    Firebird is my web browser of choice since 2002. It works well, there is no reason for sticking to Internet Explorer... except laziness/inertia. Microsoft's biggest advantage in many markets.

    Read more...

  • Mike Woodring's .NET Sample Page

    While searching for a particular code sample, I found back Mike Woodrings great .NET sample page. This web page contains many very technical code samples which are very useful one day or another.

    This page should be in your bookmarks and you should mine the samples if you're a geek. I won't go into the details of what you'll find there, go see by yourself! You can start with a look at the AssemblySettings class for example which is the counterpart of AppSettings but per assembly.

    Read more...

  • A case where interface versioning works

    In some situations, interface versioning is not a problem. I'll expose a scenario in order to show you a case where it works fine and it's simple.

    Here is the scenario: we have an application that uses plug-ins. The plug-ins, when loaded by the application, use an interface the application hands to them.

    App+plugin

    Let's call the interface IHost.

    App+plugin+IHost

    Step 1

    When the application is created, a first plug-in is written. This plug-in (Plugin1) is then using the only method of the IHost interface.
    The IHost interface is defined in an assembly we name Interfaces.

    namespace Interfaces
    {
      public interface IHost
      {
        void Method1();
      }
    }

    The Plugin1 class using the IHost interface is defined in an assembly named Plugin1. The Plugin1 assembly references the Interfaces assembly.

    namespace Plugins
    {
      public class Plugin1
      {
        static public void Calcul(Interfaces.IHost host)
        {
          host.Method1();
        }
      }
    }

    Step 2

    The application uses the Plugin1 class, handing it an object implementing the IHost interface.
    The application references the Interfaces and Plugin1 assemblies.

    class Host : Interfaces.IHost
    {
      public void Method1()
      {
        Console.WriteLine("Host.Method1");
      }
    }

    ...

    Interfaces.IHost host = new Host(); Plugins.Plugin1.Load(host);

    Step 3

    The IHost is enriched with a new method. A new version of the Interfaces assembly is generated.

    namespace Interfaces
    {
      public interface IHost
      {
        void Method1();
        void Method2();
      }
    }

    A new plugin named Plugin2 using the new version of the IHost interface is created.

    The Plugin2 assembly references the Interfaces assembly.

    namespace Plugins
    {
      public class Plugin2
      {
        static public void Calcul(Interfaces.IHost host)
        {
          host.Method1();
          host.Method2();
        }
      }
    }

    Step 4

    The application is updated to load Plugin2 as well as Plugin1. The object implementing the IHost interface must implement the new method.
    The application then references Interfaces, Plugin1, Plugin2.
    The Plugin1 assembly is not recompiled. In Visual Studio, you can for example remove the Plugin1 project from the solution.

    class Host : Interfaces.IHost
    {
      public void Method1()
      {
        Console.WriteLine("Host.Method1");
      }
      public void Method2()
      {
        Console.WriteLine("Host.Method2");
      }
    }

    ...

    Interfaces.IHost host = new Host(); Plugins.Plugin1.Load(host); Plugins.Plugin2.Load(host);

    Conclusion

    We managed to use different versions of an interface, without having to recompile the code that uses previous versions of this interface. The name of the interface has not changed (no IHost2 or IHostEx…).

    Final notes

    • This works because the interface is in its own assembly. This would not work if the interface was compiled within the Plugin1 and Plugin2 assemblies. Each plug-in sees the IHost interface as it was when it was compiled.
      Plugin1 only uses Method1, Plugin2 can use both Method1 and Method2.

    • Of course, this only works if we add things to the interface. If we remove Method1 in the new version, we'd get a MissingMethodException when Plugin1 is loaded.

    • The compiler generates a warning stating that the first version of the Interfaces assembly is ignored and that the latest version is used. This is exactly what we want.

    • Instead of statically referencing the plug-ins' assemblies, the application could load them dynamically. In this case, there would be no warning.

    Read more...

  • Power of blogs / CSV files

    I'm still amazed by the power of weblogs when I see that this post (Manipulating CSV files) is number two or three on search engines when you search for CSV files. What do you know, maybe my small experience with CSV files can actually help someone out. Well, I just added two links to the post for more information about the Schema.ini file since this is where people are landing when they are in need for that kind of information.

    Read more...

  • Webloggers haven't got a mind

    It's funny to notice that some are starting to realize that geeks are humans too... The strange part is that they seem to be disappointed about that.

    Let's take Chris Sells as an example. For a while, there were only posts about Winforms or Longhorn on his weblog. Then comes a political post, and all of a sudden Chris Sells is not an honorable man any more.
    Apparently some people forgot that weblogs are personal and that their author can think outside of .NET and even outside of the computer space. Seeing the negative response by some, Chris Sells reminds these people that this is his weblog and that he writes about what he wishes.
    This is just an example, it can happen to you too.

    Some have a bad reaction when they see something not technological on a weblog they categorized by themselves as "technological". Some weblog authors label non technological posts as being "Off-Topic" (or OT). There are categories on weblogs, they can be used to tag posts more efficiently. What does off-topic mean for a personal weblog? Nothing!
    Side note to ScottW: .Text doesn't display the categories a post belong too. That would be a nice and easy improvement.

    I'd also add that I don't read weblogs according to their author's political opinions. Some replied to Chris Sells' post with a puerile "unsubscribing now" comment. Go on, unsubscribe, that's why RSS is great. You can unsubscribe whenever you want. No one forces you to read a weblog. But think twice. Do you "unsubscribe" a friend because he said something you disagree with? Personally, I think I'd subscribe twice if that was possible. It's more interesting to read about differing opinions that make you think as opposed to consensual ones.

    Read more...

  • Microsoft: X#? X what?

    Apparently Microsoft does not want you to hear and speak about X# anymore. Seems to confirm the "there is no X#" stance.

    Why try to hide what everybody already knows? This project may be canceled as such, but what is said is said. There used to be such a project.
    Now, Microsoft has no obligation of telling us what they'll be doing with the results of this research.

    Read more...

  • One-two, one-two, sound check...

    The voice recordings are available in french for this presentation about the Aggregation Application Block.


    Brainsonic a mis en ligne l'enregistrement sonore synchronisé avec la présentation Powerpoint sur le bloc d'agrégation de services enregistré lors de ce séminaire Microsoft auquel j'ai participé le 2 décembre. La présentation sur le bloc d'invocation asynchrone de services arrive prochainement.
    Les autres présentations sont également disponibles sur le site de Brainsonic.

    Merci à Brainsonic !

    Read more...

  • ILMerge - merge assemblies into one (one to rule them all?)

    Michael Barnett from Microsoft Research created a tool that can be used to merge assemblies.

    You know, you have all those files composing your application (.exe and .dll) and you wish you could have only one... For example, you could package your own framework (Madgeek.Collections.dll + Madgeek.Data.dll + Madgeek.Web.dll + Madgeek.Xml.dll + ...) into only one assembly (Madgeek.dll), which makes it easier to distribute.

    ILMerge is a utility for merging multiple .NET assemblies into a single .NET assembly. It works on executables and DLLs alike. It comes with several options for controlling the processing and format of the output, see the accompanying documentation for details.

    This tool is delivered as a command-line app, but there is also a documented object model you can use to automate the operations.
    ILMerge is freely available from the MSR Downloads page.

    Oh, by the way, Bonne Année !

    Update: forgot to say that you should review the other downloads at the MSR Downloads page. There are a lot of interesting things there...

    Read more...