{"id":232,"date":"2006-04-14T04:40:54","date_gmt":"2006-04-14T08:40:54","guid":{"rendered":"http:\/\/weblog.soulhuntre.com\/items\/date\/2006\/04\/14\/implementing-delayed-class-type-selection-via-interfaces-in-net\/"},"modified":"2006-04-14T04:40:54","modified_gmt":"2006-04-14T08:40:54","slug":"implementing-delayed-class-type-selection-via-interfaces-in-net","status":"publish","type":"post","link":"http:\/\/legacyiamsenseiken.local\/2006\/04\/14\/implementing-delayed-class-type-selection-via-interfaces-in-net\/","title":{"rendered":"Schr\u00c3\u00b6dinger's box: Implementing delayed class type selection via Interfaces in .NET"},"content":{"rendered":"

Some geek speak here. This are really the notes for a more complete article, but it might help some folks out so I want to put it up before I forget what I learned when I go to sleep!<\/p>\n

The Problem<\/h3>\n

In a Asp.Net<\/a> development project I need to be able to call the methods and properties of an object in order to extract data from it. The problem is that I will not know until runtime which of several competing implementations I might need to call. It will depend on a number of factors. <\/p>\n

How then can I make calls to an object without knowing what object type it is in advance? The solution in this case is what .Net calls “interfaces”.<\/p>\n

Go ahead, read more.<\/p>\n

ed note: I code in C#, but these features are available under VB.net. <\/em><\/p>\n

<\/p>\n

Problem Scenario<\/h3>\n

We are going to re-implement Schr\u00c3\u00b6dinger’s box. Basically, we will write some code that can query something about whether it is alive or dead without knowing in advance what type of animal it is.<\/p>\n

Basically what we want to be able to do is only<\/i><\/b> care that whatever type of object we have, it will implement the bare minimum of what we need to do the experiment.  It needs to do two things…<\/p>\n