Calendar

<<  mars 2010  >>
lumamejevesadi
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

(mars 22, 2009 21:06)

Hello,

Again for this day, I exclusively followed the Developper and Solution Architect track, but switched between the sessions related to Client & Web, Tools & Languages and Servers and Services. Definitely good sessions ans goof speakers. So many lessons to learn ! 


Session 1 : The Daily Scrum (by Joel Semeniuk and Stephen Forte)

I am now working for 3 years and a half, and so I try to follow all the agile related sessions to learn a maximum of things and compare other practitionners method implementation with mine. Some key points of this session:

  • The daily stand up meeting
    • The daily stand up meeting is not a status meeting
    • The scrum faster is a facilitater
    • Three questions to answer during the meeting :
      • What did you do yesterday ?
      • What will you do today ?
      • Is anything in your way ?
    • You should not attack anyone during the meeting --> See him after the meeting
  • An important question to answer : What is "done" meaning ?
  • Some book references :
  • The duration of sprint is fixed in advance, but all the sprint may not have the same length (we can plan in advance that the next spring will be longer or shorter, but once it has started, we do not re-schedule it)
  • There are three key parts in a project (Functionality, Cost and Schedule), and only two of them can be fixed

Session 2 : ASP.NET MVC for Smart People (By Scott Galloway)

I was already knowing quite well the model of ASP.NET MVC so this session didn't show lots of things new. However, some key information :

  • When creating a new MVC solution, the template will create among all:
    • a "Content" folder that will hold images, ...
    • a "Scripts" folder including JQuery 1.3.1
  • The template will create the controller and the associated views (on demand)
  • We can use the [OutputCache] attribute on a view
  • When doing some POST to the server, the controller works by default with the FormCollection. However, we can use the ModelBinding to replace this FormCollection by the currently typed object we are managing
  • The Model is a partial class and so we can "extend it" (creating another partial class) to add some validation. For that purpose, we can use the IDataErrorInfo interface
  • Two goals of the MVC framework
    • to have a tight control on the HTML markup
    • to have user and SEO (Search Engine Optimization) friendly URLs 

In my view, this framework is interesting, but I'm not totally convinced by its added value. More specifically if we note that

  • in ASP.NET 4.0 we'll be more free to manage the HTML markup (by avoiding to have long generated IDs)
  • we can already use the Routing namespace to get friendly URLs

I think it's currently generating extra work for limited added value. Well let's see and try !


Session 3 : Fastest to Market : RAD Web Applications with ASP.NET Dynamic Data and Entity Framework (By Ingo Rammer)

One of my favorite speaker for an interesting session even if Dynamci Data is not really new for me.

  • Some new templates are available, among them we can note "Dynamic Data Entities Web Site" to have a web site using Dynamic Data and entity Framework. Another template will use LINQ to SQL.
  • You will need to install the latest hot fixes of Entity Framework
  • In configuration : ScaffoldAllTables means that some CRUD (Create, Read, Update, Delete) interface will be generated for all the tables of database we are targeting. But we can decide to scaffold only the tables we want
  • Dynamic Data will fo automatic form generation
  • We can use Routing
    • Be careful, if the routing you specify creates URLs not finishing with .aspx, IIS Will not redirect to ASP.NET We need to change the HttpMapping to redirect all the URLs to aspnet_isapi.dll
  • We can use the [MetadataType] attribute to specify wich class will contain the definition of the attributes. This will be usefull if we want to add some extra attributes on the generated members of the entity framework model
    • Ingo has published on his blog a small tool to generate al the metadata type class based on a model. It is available here
    • We can use a [DataType] attribute to interecept the formatting of a column thru the Format method
    • It is not possible currently to reorder the columns, except if we use the IAutoFieldGenerator interface of classical ASP.NET 

The conclusion of Ingo ? Dynamic Data will never get used to generate a business web site where high performance is needed as everything is done here at runtime. Moreover, managing business rules thru this model could be tricky. However this could be very usefull to generate some maintenance pages very quickly.


Session 4 : ASP.NET 4.0 what is coming? How do I prepare my app? (By Scott Galloway)

No so many information to remember here. Let's just say that:

  • Lot's of snippets will now be available in the HTML code
  • Some web.config transformation files have been added. This will allow to change osme attributes dependent of the configuration we are using (development database versus production database for instance)
  • An OutputCacheProvider has been added, targeting "On Disk", "In Memory", or even "Azure"
  • We can now control more the client ids that will generated : a new ClientIdMode property is available on the controls:
    • static: the ids will "forget" the naming containers part and will restart to this point
    • predictable: we can use a pattern to generate the Ids as for instance the identity of a data row in a grid
  • Visual Studio 2010 will be shipped with JQuery and Ajax Control Toolkit

Session 5 : ASP.NET AJAX 4.0 (By Jurgen Postelmans)

Jurgen has posted the slides of his session on his blog on http://www.u2u.be/res/articles.aspx.

  • Jurgen has reinsisted on the fact that the UpdatePanel is doing an asynchronous POST to the server, sending all the data of the pages (view state included), and that the server will thus process all the page (running all the events Page_Load, ...) to send back the HTML of the parts to update (ie the panel itself AND the view state)
  • POX : Plain Old XML
  • If we want to use WCF from Javascript, we must declare our service using webHttpBinding and adding a behavior declaring enableWebScript
  • To view the WCF service proxy that can be used in the javascript, we can use the WCF service URL and adding at the end /js or /jsdebug. This URL can be simply referenced on the page where we wantr to use the service
  • In javascript, the OnSuccess and OnFailure method take three parameters : The data received (or the error), the context and the method name
  • To do some binding in our HTML, we must use the syntax:
    • {{expression}}
    • where "expression" can contain method call, variables, ...
  • A new client class DataView has been added
    • One method set_data to fill the dataview
    • The method render has been replaced by updated
  • ASP.NET AJAX recognize tthe CSS class sys_template and will remove it when rendering an object. This class should be reponsible of hiding one element (typically visibility=hidden and display=none)
  • The prerogative sys:activate="*" is used to define the elements (here all of them) where we allow the creation of a control we have referenced in an xml namespace
  • A class Sys.Observer has been added. The method remove must be used to inform a grid that we have removed an element. This class is similar to the .NET classes ObservableCollection and INotifyPropertyChanged

 Session 6 : Azure - A lap around cloud-hosted Services (By Ingo Rammer)

Last session of the TechDays, and last one about Azure. Some more information to get:

  • SQL Services is a high scalable database available in the cloud, that should support up to a peta bytes of data
  • A Web Role can be seen as equivalent of an ASP.NET application that has medium trust
  • The Development Fabric allow to debug a cloug computing project locally
  • Azure provides us with a Zero Downtime Environment
    • Two platform are available online : Production and Staging
    • A simple click will swith between these two platforms
  • A new SessionStateProvider has been provided to target Azure
  • A WebRole is done to perform Synchronous Operations, while a WorkerRole will be in charge of Asynchronous Operations
  • The WorkerRole is based on a queue
    • It's important to (explicitely) delete a message from the queue once it is processed. Otherwise, it could be treated by another worker role later
    • This process (without implicit deletion) has been done to counter a potential message loss if a server has a problem while processing it
  •  
(mars 15, 2009 17:35)

Hello,

For this day, I exclusively followed the Developper and Solution Architect track, but switched between the sessions related to Client & Web, Tools & Languages and Servers and Services. It was globally a very good day, very interesting. So let's face the impossible challenge to summarize 8h of trainings in a few words.


Keynote (by Hans Verbeeck, Gil Cleeren, Peter Himschoot, Katrien de Graeve and Gregory Renard)

I really liked the keynote. Hans Werbeeck orchestrated it and the idea was to took a single application and to quickly show how we could pass it from Silverlight to WPF, to publish it in the cloud or to extend it to Surface.

  • Hans started by showing the evolution of applications :
    • Monolithic applications
    • Client / Server applications
    • Multi-Tier applications (using COM components)
    • Multi-Tier applications (using Web Services)
    • Distributed applications and SOA
  • Gil Cleeren started the demo by building the Silverlight application, using a wrapper around Virtual Eearth to use it directly
  • Peter Himshoot continued in WPF
    • Has used a web browser control in his application to use Virtual Earth
    • Has shown quicly the ValueConverters in WPF
    • He used  the WPF toolkit and the Office's Ribbon Control
    • Note that the demo he has done is already available on his blog here 
  • Note that there is a "Composite Client Application Guidance" available for building applications targeting both WPF and Silverlight
  • Note also that Silverlight 3 shall be announced in the MIX
  • Katrien de Graeve then showed the Touch Experience in Windows 7
  • The Touch support is not available currently in WPF but shall be supported in the next version
  • Gregory Renard shows after Windows Surface that can support up to 50 points of pressure
    • Note by the way that Gregory just published a whitebook about Microsoft Azure. Find it here
  • He also showed a Mesh application, hosted in the cloud
  • Finally Hans Verbeeck concluded while explaining the hosting of solutions in the Microsoft DataCenters using Windows Azure.

Session 1 : The future of C#: a first look at C# 4.0 (by Bart De Smet)

I really like the sessions of Bart de Smet and how he explains. This session just follow the same rule !

  • He explains the trends of C# going towards declarative, dynamic and conccurent.
  • The trend towards "declarative language" offer the possibility for the compiler (or the CLR) to optimize the behvaior like parallelizing the execution
  • C# 4.0 will include
    • Dynamically typed objects
    • Optional and Named parameters
    • Improved COM interop
    • Generic co-variance and contra-variance
  • Some information about the dynamically typed objects
    • The DLR (Dynamic Language Runtime)
      • is the equivalent of the CLR but for the dynamic part
      • already available now : used for IronPython and IronRuby
    • The "dynamic lookup price" (ie looking dynamically which member we should call and on which object) will be paid only once as there will be some "call site caching"
    • Currently the dynamic call today are done thru reflection but there is no unification. For instance in Silverlight, we'll call a method in this way:
      • ScriptObject calc = GetCalculator();
      • calc.Invoke("Add", 10, 20);
      • In "classic reflection", we would call the Invoke method only with two parameters as we would have had a reference to the "add" method before
    • The framework will epxose a new class DynamicObject, which is an abstract class that allows us to control what gonna be done when we call a method on a dynamic instance. He shows us how we could store all the values of properties in a dictionary instead of using "standard private variables"
  • Some information about the optional and named parameters
    • Nothing really surprising here as it is exactly the same behavior as in VB.NET : same syntax, same limitations
    • Extra information : using this type of parameters involves the same constraints as we have with const variables. Indeed, all the missing values will be set at compile time in all the calls. Consequence ? Impossible to change the defaut value without recompiling all the clients.
    • Bart concluded these explanations saying that this syntax shall be used for consumption only
  • Some information about the improved COM interop
    • First the notion of optional and named parameters will greatly simplify the call to COM interop (Excel and Word API for instance) that require many arguments
    • All calls will now return dynamic objects and so we can avoid casting the result
    • As a result, the mysterious property "value2" of Excel API can be let aside to use simply "value"
    • We can also edit the properties of the reference we are using to select "Embed Type Declaration". As a consequence, the declaration of the types we are using (and only those ones) will be included in our own DLL
  • Some information about the co-variance and the contra-variance
    • When creating generic classes we will be able to specify in or out when declaring the generic type. For instance MyClass<in X> {}
    • The in keyword will define contra-variance and the out one will be used to define co-variance
  • Finally Bart De Smet concluded by giving a quick insight of C# 5.0:
    • The C# compiler has been totally rewritten in C#, and is now open
    • We can see it now as "Compiler as a Service"
    • A new class has been created CSharpEvaluator that will allow compiling some dynamically generated code. This compiled code can then be very easliy use as "normal code" in our program, in a delegate for instance

Session 2 : Silverlight 2 CoreCLR : Bringing the power of .NET to the net (by Andrew Pardoe)

  • Andrew Pardoe explained his work of creating the CoreCLR : a subset of the CLR that can be embedded in Silverlight
  • What has been removed ? Among all we can note :
    • All code related to COM interop
    • All non generic collections
  • Some other information ?
    • Silverlight 3 will include 3D support and GPU acceleration
    • One AppDomain will be created (and only one) per any .xap file
    • JIT compiler now focus on startup time
    • He finally showed us the IsolatedFileStorage use, that can be seen as a "super cookie" class

Session 3 : Code Contracts, Pex, CHESS, 3 tools for 1 talk (by Jonathan "Peli" de Halleux)

Another great session! Peli showed us three tools coming from the Microsoft Research laboratory.

    • Will be part of .NET 4.0. Can be currently downloaded from the devlab website
    • A new namespace is now available : System.Diagnostics.Contracts
    • Allow to define Pre and Post Conditions to our methods like
      • Contract.Requires(target != null)
      • Contract.Ensures(Contract.Result<string>() != null)
      • Contract.Ensures(Contract.OldValues(this.Count) == this.Count - 1)
    • A new property page will be added in the project allowing to
      • activate a new static code analysis to ensure the contracts are respected
      • activate a runtime check
    • We can add contracts on an interface
      • On an interface, we can add the attribute [ContractClass(xxx)] to define the class that will hold the contracts of our interface
      • On the class that will hold the contracts we need to add [ContractClassFor(xxx)]
      • We can also add a method tagged with [ContractInvariantMethod] : this will get executed after each call and it must success
    • It can generate a separated DLL that will contain only the contracts (can be considered as a documentation DLL)
  • Pex
    • This tool will generate a suite of test cases to check a specific method
    • Will analyse the IL code of the method to see all the branches and thus exploring all the branches
    • It can create complex objects based on a given factory. If a factory is not present, it will suggest the one to create
    • This tool seem to be great to be able to reproduce a blocking scenario in a multithreaded application
    • To do so, it will "simply" change the schedule of the different threads in action to arrive to the blocking scneario
    • To be used on a test, we must add the attribute [HostType("Chess")]

Session 4 : Lean Principles, Agile Techniques, and Team System (by Joel Semeniuk)

I really like the session given by agile practitionners as they are automatically more dynamic than the average.

Joel dealt in this session with the sevent principles of Lean Software Development and the associated myths:  

  • Myth 1 : Early Specs reduce Waste
    • Principle 1 : Eliminate Waste
  • Myth 2 : Tester Job is to find defect
    • Principle 2 : Build Quality In
  • Myth 3 : Prediction creates Predictability
    • Principle 3 : Create Knowledge
  • Myth 4 : Planning is comitment
    • Principle 4 : Defer Commitment
  • Myth 5 : Haste makes Waste
    • Principle 5 : Deliver Fast
  • Myth 6 : There is one best way
    • Principle 6 : Respect People
  • Myth 7 : Optimize by decomposition
    • Principle 7 : Optimize the Whole 

Some other key information that was shared during the session :

  • What is waste ? Partially done work, defects, relearning, hand off, ...
  • We must be bias against adding new features : Why do we need this ? How is this helping the client job ?
  • Case of Team System : We should edit our process templates (via the TFS power tools) to be able to change the work items and add the notions of "Triage" to all items
  • The TFS power tools allow to add more policies to the same folder
  • Always assign a piece of work to a team (and not to a single person)
  • A system never need 100% flexibility
  • Defer the decisions until you have most of the infos

To learn more about Lean Sofware Development, just go to the web site of Mary and Tom Poppendieck


Session 5 : .NET Services: Infrastructure building blocks in the cloud (by Christian Weyer)

It was an interesting session but as I have followed many session about this subject, including one given bu Juval Löwy, I won't give much details here. I will just say that :

  • .NET Services is the new name of "Biztalk Services"
  • Sql Services will allow to access a real Sql Server in the cloud
  • .NET Service bus will also target Ruby, PHP and JAVA, either via Microsoft or 3rd party vendors
(mars 14, 2009 19:35)

Hello,

I have followed the 3 days of the Tech Days 2009 in Antwerpen so time to do a little résumé of the sessions I have seen ! 

For the pre-conference day, I have followed the architect track, focused on Software + Services: the convergence of SOA, SaaS, Cloud Computing and Web 2.0. Cloud Computing was by the way one of the reccuring subject of the techdays with a few presentations dedicated to the subject.


Session 1 : Architectures: the Good, the Bad and the Ugly (by Miha Kralj)

This session was dedicated on fighting against some architectural ideas. Some key ideas about this talk :

  • The Pattern and Practices group has released the v2.0 of the Architect guidelines.
  • Requirements can be both your shield and your sword
  • Some Anti-Patterns:
    • Measure Abuse
    • Start Small, Grow fast : we cannot add scalability later on
    • YAGNI : You ain't gonna need it : dealing with things very low on priority list
    • YAFL : Yet Another Fine Layer
  • He also took the example of Sharepoing where developpers must use the API as the DB expose something like 500 stored procedures and 50 unrelated tables : high too hard to maintain

One of his conclusion was "It's much better to be approximatively right, than precisely wrong" 


Session 2 : Identity & Cloud Services (by Vittorio Bertocci)

Very nice training of Vottorio which is part of the Windows Azure team. The objectif of that session ? Presenting Azure, but more precisely the security part and the security claims.

  • What is a claim ?
    • It is a statement about an entity (a subject) made by an entity (an issuer)
    • Said differently, it is the base of systems where you will trust someone that will check the identity of a subject
  • The security is based on tokens (signed XML fragments that transport the credential and claims)
  • You will define some policies, meaning that to be able to do some business with someone (a client), he needs to provide me with a claim
  • The Microsoft .NET Services are composed of:
    • The .NET Service Bus
    • The Workflow Services
    • The .NET Access Control Service ("Geneva")
  • The "Geneva" framework has been designed to consume claims
  • The "Geneva" server is built on the "Geneva" framework
  • You will edit the authorization rules via a web portal or thru a MMC
  • The Active Directory can be used as an identity provider using the "Geneva" Server

The best explanations here were related to the claims "workflow" and the transformation of claims in the relay service.

Just read his post about his sessions of the TechDays.


Session 3 : Software + Services: The convergence of SaaS, SOA and Web 2.0 (by Beat Schwegler)

Beat used this session to speak a bit about SaaS, Web 2.0 and to provide us with some examples of web sites / application currently leveraging Web 2.0.

  • Some Definitions
    • SaaS
      • Software as a service
      • You consume a software provided by a "Service Provider" (like eMail, CRM, ...)
    • Web 2.0
      • An internet application that explicitely leverage network effects
      • Data is the next "Intel Inside
      • Software above the level of a device
  • Some Demos
      • The biggest online game (for the number of players connected at the same time in the same virtual world)
      • Built on Sql Server 64 bits
      • Allow the users to upload photos
      • The software will then give a 3D presentation of a scene based on the different photos uploaded
      • The library is currently scanning the most rare and precious book they hold and give a free access on the Web to consult these volumes
      • A composition of high resolution photographies of the Yosemite Mountain, allowing the use of the DeepZoom technology
      • The greatest online database of space information and photography
      • Also allow the DeepZoom technology
  • He finished the talk with a quick presentation of BPOS (Microsoft Business Productivity Online Suite) which is composed of Sharepoint Online, Exchange Online, ...

Session 4 : Lap around Oslo (by Shy Cohen)

Olso is currently for me the most obscure upcoming technology. I was first introduced to it in Amsterdam during the First International SOA Symposium. But OSLO is continuing moving, and it's still very unsure to know when it will be delivered and what will really be inside. Some more information in the upcoming MIX 2009 ?

Let's try so summarize here some information I could catch during the talk.

  • Curently there is a clear trend towards data : we develop a generic software, and the specific parts (functionality specific to a client for instance) is getting moved in the data part to "configure" the behavior of the whole application
  • A CTP is currently available but "Quadrant" is not part of it
  • OSLO comes with "M" : a set a languages that will help manipulating the repository of OSLO
    • "M" is a textual modeling language
    • Allow to defines types
    • Allow to define constraints in a very easy way like "where value > 0" or "Text#30"
    • Generates Sql Code (including transaction management, (primary and foreign) keys, constraints

Session 5 : How IT will change in the next decade (by Miha Kralj)

This session was more a vision of the change of IT during the years and how it will evolve in the upcoming years. I will just note here some facts, in a time where "Green IT" is becoming more and more a fashion debate:

  • 50% of the global hardware is being bought by Microsoft, Google and Yahoo!
  • 6% of the carbon pollution is currently due to IT (meaning the same ratio as the aviation)
  • Cooling machines and servers is now the greatest energy consuming part of IT
(mai 10, 2008 13:32)

I have given here some clues about creating control adapters. A few days after I have started to use them, I have encountered some very special problems. In fact the adapters have the following hierarchy :  the .NET framework expose a ControlAdapter from which derives a WebControlAdapter and a PageAdapter. THe name of these classes being explicit enough to let you know in which cases you should use which one.

As a consequence, when you want to adapt a WebControl, you should use a WebControlAdapter or one of its derived classes. So far, so good, so simple.

But what you should know is that the framework expose in the WebControl class a method called Render. Never seen it or overriden it ? Normal it's a protected internal one. This method is responsible of the rendering of the control and so does : RenderBeginTag, RenderContent and RenderEndTag. And these are the three methods you will normally work with.

And so what does the WebControlAdapter : it will redefine the Render method to do the same work : RenderBeginTag, RenderContent and RenderEndTag. And each of these methods will either call the apdater's equivalent method, or the one of the control itself.

Pretty normal. No problem there.

Well... Almost... Let's imagine just one moment, that someone has defined some other code in the Render method ? Well... That would bring some troubles no ? Right it would break the .NET standard but let's imagine. Of course, in that case, using a WebControlAdapter would just bring a you a no-longer working control.

It's in fact what happens in the BaseValidator class (which inherits from WebControl of course). The Render method does a lot more, like rendering javascript, the "display" and "visibility" attribute.

Which conclusion, what can we say now ? Never use a WebControlAdapter when working with a BaseValidator (or any derived class). Prefer working with a ControlAdapter instead !

(avril 23, 2008 09:27)

Some explanation 

Depending of the browser, some control may need to be rendered differently. By default the .NET framework works with "Control Adapters", id est, some classes that will be plugged into the rendering process.

How does it works ? When the server receives a request, it will try to find which browser does the request, based on the user agent or on HTTP headers for example. To do it rely on some browser definition files (of extension .browser). To see them, please go on %windir%/Microsoft.NET/Framework/<version>/CONFIG/Browsers.

When the server has identified the browser (at worse, it would be identified as a "Default" browser), and that it needs to render a control, it will look if there is some control adapters plugged for this kind of control. If there are some, they will be in charge of the rendering. If not, the control will render himself. Note that an adapter can redirect / delegate some treatment to the control.

Creating a basic Adapter for TextBoxes

  • Let's create a solution with a website and a "Web Control Class Library" (named "MyControlLibrary")
  • Let's add a new class in the library for the adapter. Note that by convention, an adapter will always be named "ControlNameAdapter" where "ControlName" is the control we want to adapt. Here we'll so create the "TextBoxAdapter"

using System;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.Adapters;

 

namespace MyControlLibrary

{

   public class TextBoxAdapter : WebControlAdapter

   {

      /// <summary>

      /// If you need to access the adapted control, the framework advice to expose

      /// a private method encapsulating the Adapter's Control property.

      ///

      /// We can cast it without doing any test, as by naming convention,

      /// this adapter shall only be used for adapting Textboxes (or derived types)

      /// </summary>

      private TextBox Control

      {

         get { return (TextBox)base.Control; }

      }

 

      /// <summary>

      /// Let's add some extra attribute in our control's begin tag

      /// </summary>

      protected override void RenderBeginTag(HtmlTextWriter writer)

      {

         writer.AddAttribute("MyNewAttribute", "This has been set in the adapter");

         writer.AddAttribute("ControlType", this.Control.GetType().FullName);

 

         base.RenderBeginTag(writer);

      }

   }

}

How to use it in a website ?

The mapping between a control and its adapter is done at the website level, using the browser definitions.

  • In the website, add the special folder "App_Browsers"
  • In the folder add a new browser definition file

We have several solutions here. The simplest is to add some capabilities to an existing browser. We can either decide to do this for all browser, or for a specific browser.

<browsers>

<!--

   Here we extend the "Default" browser (ie the basis browser from which all other

   browser derive (see in %windir%/Microsoft.NET/Framework/<Version>/CONFIG/Browsers)

 

   To extend only a specific browser, replace the refID by another one eg :

      refID="IE" for all versions of IE

      or refID="IE50" for only the 5.0 version

   -->

   <browser refID="Default">

      <controlAdapters>

         <adapter adapterType="MyControlLibrary.TextBoxAdapter"

                  controlType="System.Web.UI.WebControls.TextBox" />

      </controlAdapters>

   </browser>

</browsers>

How to use this functionality for testing purposes ?

Let's explain my context : in a TDD environment all code (and so pages) are tested before being written. To do so, we can use for instance basic HTTP request that will call my page and then validate them using any HTML parsing. In order to facilitate the testing, we may want to base our research on some extra tags. That's where Control Adapters may enter in the game. As a consequence we want some control adapters to be used only for testing. The simplest way to do so is to consider that our testing framework will use a "special browser" by giving some clues in the HTTP Headers or in the user agent.

For example by using this code, we could make request by simulating a IE 5.0 browser, and sending an extra hint.

HttpWebRequest request = HttpWebRequest.Create("http://localhost/MyPage.aspx")

   as HttpWebRequest;

request.UserAgent

   = "Mozilla/4.0 (compatible; MSIE 5.0; Windows 95; MyTestSimulator)";

At the end, we could update our browser file to have this kind of definition :

<browsers>

   <!-- Let's create a new browser, extending another one,

   eg IE50, Mozilla, MozillaFirefox, Default, ... -->

   <browser id="MyTestSimulator" parentID="IE50">

      <!-- Let's here base our research on our user agent hint to match our

      "special test browser"

      -->

      <identification>

         <userAgent match="MyTestSimulator" />

      </identification>

 

      <controlAdapters>

         <adapter adapterType="MyControlLibrary.TextBoxAdapter"

                  controlType="System.Web.UI.WebControls.TextBox" />

      </controlAdapters>

   </browser>

</browsers>

Powered by BlogEngine.NET 1.2.0.0 | Theme by Pierre-Emmanuel Dautreppe