<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Bruce Zhang</title><link>http://dotnetjunkies.com/WebLog/wayfarer/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 1.0 (Build: 1.0.1.50214)</generator><item><title>Handling Distributed Transactions In Visual Studio 2005</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2006/02/15/135295.aspx</link><pubDate>Wed, 15 Feb 2006 06:44:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:135295</guid><dc:creator>wayfarer</dc:creator><slash:comments>0</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/135295.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=135295</wfw:commentRss><description>&lt;P&gt;It provides the System.Transaction namespace in Visual Studio 2005. So it is very convenient to handle distributed transactions. In Visual Studio 2003 .Net, distributed transactions are handled by Enterprise Service and require COM+ registration. We&amp;nbsp;may compare the&amp;nbsp;methods of inserting the order between Pet Shop 3.0 and Pet Shop 4.0. In Pet Shop 3.0, the OrderInsert class must be derived from a Serviced Component in order to handle the transaction, as shown as below:&lt;/P&gt;&lt;PRE&gt;using System;
using System.Collections;
using System.EnterpriseServices;
using System.Runtime.InteropServices;
...
namespace PetShop.BLL {
   /// &amp;lt;summary&amp;gt;
   /// A business component to manage the creation of orders
   /// Creation of an order requires a distributed transaction
   /// so the Order class derives from ServicedComponents
   /// &amp;lt;/summary&amp;gt;
   [Transaction(System.EnterpriseServices.TransactionOption.Required)]
   [ClassInterface(ClassInterfaceType.AutoDispatch)]
   [ObjectPooling(MinPoolSize=4, MaxPoolSize=4)]
   [Guid("14E3573D-78C8-4220-9649-BA490DB7B78D")]
   public class OrderInsert : ServicedComponent {
      ...
      /// &amp;lt;summary&amp;gt;
      /// A method to insert a new order into the system
      /// The orderId will be generated within the method and should not
      /// be supplied as part of the order creation the inventory will be 
      /// reduced by the quantity ordered.
      /// &amp;lt;/summary&amp;gt;
      /// &amp;lt;param name="order"&amp;gt;All the information about the order&amp;lt;/param&amp;gt;
      /// &amp;lt;returns&amp;gt;
      /// The new orderId is returned in the order object
      /// &amp;lt;/returns&amp;gt;
      [AutoComplete]
      public int Insert(OrderInfo order) {

         // Get an instance of the Order DAL using the DALFactory
         IOrder dal = PetShop.DALFactory.Order.Create();

         // Call the insert method in the DAL to insert the header
         int orderId = dal.Insert(order);

         // Get an instance of the Inventory business component
         Inventory inventory = new Inventory();
         inventory.TakeStock( order.LineItems);
         ...

         // Set the orderId so that it can be returned to the caller
         return orderId;
      }
   }
}
&lt;/PRE&gt;
&lt;P&gt;But in Pet Shop 4.0, we can use System.Transaction to insert an order and update the inventory stock. It has implemented the Order.Insert() method by adding a reference to the System.Transaction namespace and wrapping the order insertion and inventory stock reduction methods inside of a TranscationScope, as shown as below:&lt;/P&gt;&lt;PRE&gt;using System;
using System.Transactions;
using PetShop.IBLLStrategy;

namespace PetShop.BLL {
    /// &amp;lt;summary&amp;gt;
    /// This is a synchronous implementation of IOrderStrategy 
    /// By implementing IOrderStrategy interface, the developer can 
    /// add a new order insert strategy without re-compiling the whole 
    /// BLL.
    /// &amp;lt;/summary&amp;gt;
    public class OrderSynchronous : IOrderStrategy {
      ...
        /// &amp;lt;summary&amp;gt;
        /// Inserts the order and updates the inventory stock within 
        /// a transaction.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="order"&amp;gt;All information about the order&amp;lt;/param&amp;gt;
        public void Insert(PetShop.Model.OrderInfo order) {

            using (TransactionScope ts = new                      
TransactionScope(TransactionScopeOption.Required)) {

                dal.Insert(order);

                // Update the inventory to reflect the current inventory 
                // after the order submission.
                Inventory inventory = new Inventory();
                inventory.TakeStock(order.LineItems);

                // Calling Complete commits the transaction.
                // Excluding this call by the end of TransactionScope's
                // scope will rollback the transaction.
                ts.Complete();
            }
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;Obviously, it is simpler by handling Distributed Transaction in Visual Studio 2005 than in Visual Studio 2003. Furthermore, it can improve the performance of program when handling transaction.&lt;/P&gt;&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=135295" width="1" height="1"&gt;</description></item><item><title>Encapsulation of Change (Part One)</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2006/01/19/134816.aspx</link><pubDate>Fri, 20 Jan 2006 02:59:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:134816</guid><dc:creator>wayfarer</dc:creator><slash:comments>0</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/134816.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=134816</wfw:commentRss><description>&lt;P&gt;&lt;SPAN&gt;The change of the requirement is an enemy we must fight against when we develop the software project. Sometimes, the change of the requirement is endless, so we have to delay our project. Of course, our customers have not been patient with our delay. They would rather believe the difficulty we meet because of the change of requirement is the foxy excuse. The change is like a sword of Damocles over our head. As brooks said, there is no silver bullet in the process of software engineering. It is same that we can't find the "silver bullet" to solve the problem of change. It's a mission impossible. But don't scare of it, we must face its difficulty actively. So Kent Beck, the leader of XP (Extreme Programming), announced that we must embrace the change. He provided the solution to solve it from the angle of Software Engineering Methodology. And now, this article will address issue how to solve the change in the process of developing the software project from the angle of Software Design Methodology. That is "Encapsulation of Change".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Design Patterns is the best interpretation of "Encapsulation of Change". No matter we use the Creational Pattern, Structural Pattern, or Behavioral Pattern, our objective is finding the change in Software, then encapsulating the change with abstraction and polymorphism. So, at the beginning of design, we not only implement the User Case, but also mark the existed change. Encapsulation of change means to discover the change or find the change. It is very important.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The objective of Creational Pattern is to encapsulate the change when creating an object. For example, it builds the specific abstract factory class when we use Factory Method Pattern or Abstract Factory Pattern. So this factory class encapsulates the creational change in the future.&amp;nbsp;Bridge Pattern encapsulates the change when creating the object inside the product, so that we can replace it with the new object to fit the change of requirement.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;As far as Structural Pattern, it focuses on the composite style between the object. When we change the structure of object, in fact the dependent relationship between the objects would be changed. Of course if you want to use the Structural Pattern, you will use not only encapsulation, but also inheritance and aggregation. For example, Decorate Pattern describes the dependent relationship between the decorator and the decorated object. The decorator is the abstract class so we can handle the change of the structure of the object. Similarly, Builder Pattern encapsulates the dependent relationship of an implementation of the object. Composite Pattern encapsulates the recursive relationship between the objects.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Behavioral Pattern mainly focuses on the behavior of the object. It abstracts the behavior of the object into the specific abstract class or interface, so that it becomes more extensible, because the behavior is the most unstable part in the architecture. For instance, Strategy Pattern abstracts the strategy or algorithm into a sole class or interface in order to encapsulate the strategy. Command Pattern encapsulates the request. State Pattern encapsulates the state. Visitor Pattern encapsulates the style of visiting. Iterator Pattern encapsulates the algorithm of iteration. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN&gt;By using the Design Patterns and encapsulating the change, it ensures the extensible of the architecture. Maybe we can’t drive off the nightmare which was brought by the change, however, if we can foresee some changes at the beginning of the design, it will avoid the trouble caused by the change in the future. So we can say Design Patterns should be a nice spear to fight against the change, although we can’t find out the “Silver Bullet”. &lt;/SPAN&gt;&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=134816" width="1" height="1"&gt;</description></item><item><title>My Workspaces</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2005/12/27/134478.aspx</link><pubDate>Wed, 28 Dec 2005 03:09:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:134478</guid><dc:creator>wayfarer</dc:creator><slash:comments>0</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/134478.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=134478</wfw:commentRss><description>&lt;P&gt;Today, I applied for the workspaces in &lt;A href="http://www.gotdotnet.com"&gt;http://www.gotdotnet.com&lt;/A&gt;. It is free and useful. Through it, you can upload your resources, for instance, your projects, your articles and some material you collected. It likes the storehouse so that you can backup your important stuff. At the same time you may share them with your friends who&amp;nbsp;are easy to get them by visiting your workspaces website. By the way, you can assign the catchy&amp;nbsp;alias to your workspaces in order to create the friendly URL at &lt;A href="http://workspaces.gotdotnet.com/[alias"&gt;http://workspaces.gotdotnet.com/[alias&lt;/A&gt;]. It's cool!&lt;/P&gt;
&lt;P&gt;More &amp;nbsp;exact definition is that "Workspaces is an online collaborative development enviroment where developer can create, host and manage projects throughout the project lifecycle". Yeah, so you can invite your partners to join it.&amp;nbsp;You can check in or check out your projects with teamwork.&lt;/P&gt;
&lt;P&gt;So, do you want to own your workspaces? Please visit &lt;A href="http://www.gotdotnet.com"&gt;http://www.gotdotnet.com&lt;/A&gt; and create the new workspaces. Of course, welcome to my workspaces which url is &lt;A href="http://workspaces.gotdotnet.com/wayfarer"&gt;http://workspaces.gotdotnet.com/wayfarer&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=134478" width="1" height="1"&gt;</description></item><item><title>Terrible Harddisk</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2005/12/22/134439.aspx</link><pubDate>Fri, 23 Dec 2005 02:14:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:134439</guid><dc:creator>wayfarer</dc:creator><slash:comments>0</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/134439.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=134439</wfw:commentRss><description>&lt;P&gt;A couple of days ago, the harddisk of my laptop met the fatal mistake, it couldn't work. So I had to send my laptop to the headquaters of Company. The result of examination&amp;nbsp;was to change the new&amp;nbsp;harddisk, and my total data stored in the harddisk&amp;nbsp;could not be restored. Terrible! But I must accept this fact. Fortunately, many important material had been backuped, otherwise my loss&amp;nbsp;would be&amp;nbsp;very serious. &lt;/P&gt;
&lt;P&gt;So, please remember backupping your important data at any moment!&lt;/P&gt;&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=134439" width="1" height="1"&gt;</description></item><item><title>My Plan</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2005/12/22/134438.aspx</link><pubDate>Fri, 23 Dec 2005 01:56:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:134438</guid><dc:creator>wayfarer</dc:creator><slash:comments>0</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/134438.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=134438</wfw:commentRss><description>&lt;P&gt;These days, I get the precious leisure time. This condition will go on for half year. I'd better making the best of&amp;nbsp; it. My plan to improve the technical skill is:&lt;/P&gt;
&lt;P&gt;1. Learning C++ Programming In the Unix Environment;&lt;BR&gt;2. Depth-Understanding .Net;&lt;BR&gt;3. Obtain the knowledge of Architecture Design, Especially SOA(Service Oriented Architecture);&lt;BR&gt;4. Master the Domain Knowledge of Semiconductor Industry.&lt;/P&gt;
&lt;P&gt;Very difficult, but I must try my best.&lt;/P&gt;&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=134438" width="1" height="1"&gt;</description></item><item><title>Switch Statement is the poison resulting in Stiff</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2005/12/16/134349.aspx</link><pubDate>Fri, 16 Dec 2005 05:38:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:134349</guid><dc:creator>wayfarer</dc:creator><slash:comments>0</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/134349.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=134349</wfw:commentRss><description>&lt;P&gt;&lt;A href="http://www.amazon.com/gp/product/0596007124/104-3655065-2765505?v=glance&amp;amp;n=283155"&gt;Head First Design Pattern&lt;/A&gt; is nice book that introduces the Design Pattern. There are&amp;nbsp; a great number of samples in the book. These samples were written with Java. But we can download the C# samples from &lt;A href="http://www.msquaredweb.com/DesignPatterns/HeadFirstDesignPatternsInCSharp.zip"&gt;HeadFirstDesignPatternCSharp&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.amazon.com/gp/product/images/0596007124/ref=dp_image_0/104-3655065-2765505?%5Fencoding=UTF8&amp;amp;n=283155&amp;amp;s=books"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In this book, it introduces the Abstract Factory Pattern with the case of PizzaStore. This example is very interesting and easy to understand. The class diagram of PizzaStore is as below:&lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;a href="http://dotnetjunkies.com/WebLog/photos/wayfarer/images/134350/original.aspx"&gt;Figure1.1 Class Diagram of PizzaStore&lt;/A&gt;&amp;gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Subclasses NYPizzaStore and ChicagoPizzaStore are derived from the Abstract Class PizzaStore. They are all override the CreatePizza() method. This method would create the specific pizza according to the value of string type. It would be invoked by OrderPizza() method which is contained in base class PizzaStore. The codes of OrderPizza()&amp;nbsp;are as below:&lt;BR&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/SPAN&gt;&lt;SPAN&gt; Pizza OrderPizza(&lt;SPAN&gt;string&lt;/SPAN&gt; type)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Pizza pizza;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza = CreatePizza(type);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza.Prepare();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza.Bake();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza.Cut();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza.Box();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; pizza;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;
&lt;P&gt;CreatePizza is the virtual method. It is overrided in subclass NYPizzaStore:&lt;BR&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected&lt;/SPAN&gt;&lt;SPAN&gt; &lt;SPAN&gt;override&lt;/SPAN&gt; Pizza CreatePizza(&lt;SPAN&gt;string&lt;/SPAN&gt; type)&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Pizza pizza = &lt;SPAN&gt;null&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;IPizzaIngredientFactory ingredientFactory = &lt;SPAN&gt;new&lt;/SPAN&gt; NYPizzaIngredientFactory();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;switch&lt;/SPAN&gt; (type)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;case&lt;/SPAN&gt; &lt;SPAN&gt;"cheese"&lt;/SPAN&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza = &lt;SPAN&gt;new&lt;/SPAN&gt; CheesePizza(ingredientFactory);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza.Name = &lt;SPAN&gt;"New York Style Cheese Pizza"&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;break&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;case&lt;/SPAN&gt; &lt;SPAN&gt;"clam"&lt;/SPAN&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza = &lt;SPAN&gt;new&lt;/SPAN&gt; ClamPizza(ingredientFactory);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza.Name = &lt;SPAN&gt;"New York Style Clam Pizza"&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;break&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;case&lt;/SPAN&gt; &lt;SPAN&gt;"pepperoni"&lt;/SPAN&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza = &lt;SPAN&gt;new&lt;/SPAN&gt; PepperoniPizza(ingredientFactory);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza.Name = &lt;SPAN&gt;"New York Style Pepperoni Pizza"&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;break&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; pizza;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;However it occurs the terrible &lt;STRONG&gt;switch&lt;/STRONG&gt; statement. The &lt;STRONG&gt;switch&lt;/STRONG&gt; statement is very important when we want to make a choice by the specific condition, but it will hurt the program's flexibility also. Imaging this case, if we want to add the new&amp;nbsp;kind of Pizza, we must modify all of the subclasses which are derived from PizzaStore. Absolutely, it is the poison resulting in the stiff of program structure. So how to eliminate it? &lt;/P&gt;
&lt;P&gt;In the CreatePizza() method, its responsibility for creating the Pizza. So we may introduce the special factory class which responsibility for producing the product, that is the specific Pizza Class, like CheesePizza, ClamPizza or PepperoniPizza. The class diagram like this:&lt;/P&gt;
&lt;P&gt;&lt;a href="http://dotnetjunkies.com/WebLog/photos/wayfarer/images/134351/original.aspx"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;&lt;a href="http://dotnetjunkies.com/WebLog/photos/wayfarer/images/134351/original.aspx"&gt;Figure1.2 Class Diagram of PizzaFactory&lt;/A&gt;&amp;gt;&lt;/P&gt;
&lt;P&gt;We must modify the CreatePizza() method in PizzaStore class. We should accept the parameter which type is IPizzaIngredientFactory. IPizzaIngredientFactory is the factory class. Its function is to make the Pizza which style is different. For instance, it is New York style or Chicago style. If you want to know more detail, please download the sample and refer to the source code. At last, the codes of our PizzaFactory and his subclasses are as below:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;abstract&lt;/SPAN&gt; &lt;SPAN&gt;class&lt;/SPAN&gt; &lt;SPAN&gt;PizzaFactory&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;abstract&lt;/SPAN&gt; &lt;SPAN&gt;Pizza&lt;/SPAN&gt; CreatePizza(&lt;SPAN&gt;IPizzaIngredientFactory&lt;/SPAN&gt; ingredientFactory);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;class&lt;/SPAN&gt; &lt;SPAN&gt;CheesePizzaFactory&lt;/SPAN&gt; : &lt;SPAN&gt;PizzaFactory&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;override&lt;/SPAN&gt; &lt;SPAN&gt;Pizza&lt;/SPAN&gt; CreatePizza(&lt;SPAN&gt;IPizzaIngredientFactory&lt;/SPAN&gt; ingredientFactory)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;CheesePizza&lt;/SPAN&gt;(ingredientFactory);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;}&lt;BR&gt;&lt;/SPAN&gt;ClarmPizzaStore and PepperoniPizzaStore are similar to CheesePizzaFactory.&lt;/P&gt;
&lt;P&gt;Then we must modify the CreatePizza() method in the PizzaStore family:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;class&lt;/SPAN&gt; &lt;SPAN&gt;NYPizzaStore&lt;/SPAN&gt; : &lt;SPAN&gt;PizzaStore&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;protected&lt;/SPAN&gt;&lt;SPAN&gt; &lt;SPAN&gt;override&lt;/SPAN&gt; &lt;SPAN&gt;Pizza&lt;/SPAN&gt; CreatePizza(&lt;SPAN&gt;PizzaFactory&lt;/SPAN&gt; pizzaFactory)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;IPizzaIngredientFactory&lt;/SPAN&gt; ingredientFactory = &lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;NYPizzaIngredientFactory&lt;/SPAN&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; pizzaFactory.CreatePizza(ingredientFactory);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;public&lt;/SPAN&gt; &lt;SPAN&gt;class&lt;/SPAN&gt; &lt;SPAN&gt;ChicagoPizzaStore&lt;/SPAN&gt; : &lt;SPAN&gt;PizzaStore&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{ &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;protected&lt;/SPAN&gt;&lt;SPAN&gt; &lt;SPAN&gt;override&lt;/SPAN&gt; &lt;SPAN&gt;Pizza&lt;/SPAN&gt; CreatePizza(&lt;SPAN&gt;PizzaFactory&lt;/SPAN&gt; pizzaFactory)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;IPizzaIngredientFactory&lt;/SPAN&gt; ingredientFactory = &lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;ChicagoPizzaIngredientFactory&lt;/SPAN&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; pizzaFactory.CreatePizza(ingredientFactory);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;FONT face="Times New Roman"&gt;Of course we should modify the OrderPizza() method in the base class of PizzaStore like this:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;public&lt;/SPAN&gt; Pizza OrderPizza(&lt;SPAN&gt;PizzaFactory&lt;/SPAN&gt; pizzaFactory)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Pizza pizza;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza = CreatePizza(pizzaFactory);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza.Prepare();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza.Bake();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza.Cut();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;pizza.Box();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; pizza;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT face="Times New Roman"&gt;Great! we have eliminated the terrible &lt;STRONG&gt;switch&lt;/STRONG&gt; statment in the CreatePizza() method. At the same time, it became to simple and clear. The most important thing is that the structure is more flexible than before. If we want to produce the new kind of Pizza, we only add the factory class for new Pizza. We don't need modify the existed class family of PizzaStore any more.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=134349" width="1" height="1"&gt;</description></item><item><title>Easier and more convenient</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2005/12/14/134328.aspx</link><pubDate>Thu, 15 Dec 2005 02:26:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:134328</guid><dc:creator>wayfarer</dc:creator><slash:comments>0</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/134328.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=134328</wfw:commentRss><description>&lt;P&gt;If you want to determine if string b is substring of string a, you must write the code line in C# 1.0 or 1.1 as below:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (a.IndexOf(b) != 0) {//...}&lt;/P&gt;
&lt;P&gt;But it is easier and more convenient in C#2.0, like this:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (a.Contains(b)) {//...}&lt;/P&gt;
&lt;P&gt;If you want to determine if string s is null or empty, the logic expression using C# 1.0 or 1.1 is very complex:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (s == null || s.Length == 0) {//...}&lt;/P&gt;
&lt;P&gt;But it is easier and more convenient in C#2.0, like this:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (String.IsNullOrEmpty(s)) {//...}&lt;/P&gt;
&lt;P&gt;Why is it static method of IsNullOrEmpty() method instead of dynamic method,? Otherwise we can invoke it like this:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (s.IsNullOrEmpty()) {//...}&lt;BR&gt;It is easier than what we invoke with static method, but in fact,&amp;nbsp;it will throw the NullReferenceException. So static method is the right choice.&lt;/P&gt;&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=134328" width="1" height="1"&gt;</description></item><item><title>C# Language Specification</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2005/12/14/134326.aspx</link><pubDate>Thu, 15 Dec 2005 01:16:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:134326</guid><dc:creator>wayfarer</dc:creator><slash:comments>0</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/134326.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=134326</wfw:commentRss><description>&lt;P&gt;If you want to learn about the new feature of C# 2.0, this document is the best choice: &lt;A href="http://download.microsoft.com/download/8/1/6/81682478-4018-48fe-9e5e-f87a44af3db9/CSharp%202.0%20Specification.doc"&gt;C# Language Specification 2.0, March 2005 Draft&lt;/A&gt;.&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;It introduces&amp;nbsp;all new feature of C# 2.0&amp;nbsp;including Generics, Anonymous Methods, Iterators, etc. It is very useful and free.&lt;/P&gt;
&lt;P&gt;If you are new guy for C#. Don't worry, there is&amp;nbsp;some free resources for you too. You&amp;nbsp;may refer to this document which link is &lt;A href="http://download.microsoft.com/download/5/e/5/5e58be0a-b02b-41ac-a4a3-7a22286214ff/csharp%20language%20specification%20v1.2.doc"&gt;C# Language Specification 1.2&lt;/A&gt;. It is a very excellent material and&amp;nbsp;an official C# guide book provided by Microsoft Corp. Don't need buy the technical book about C# if you own it.&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;Don't hesitate, download and read them.&lt;/P&gt;&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=134326" width="1" height="1"&gt;</description></item><item><title>Using AppDomain.CreateInstance() method</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2005/12/14/134316.aspx</link><pubDate>Wed, 14 Dec 2005 06:32:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:134316</guid><dc:creator>wayfarer</dc:creator><slash:comments>0</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/134316.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=134316</wfw:commentRss><description>&lt;P&gt;Suppose my assembly's full name is: MyModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, can we create the instance using AppDomain.CreateInstance() method like this:&lt;BR&gt;AppDomain domain = AppDomain.CurrentDomain;&lt;BR&gt;domain.CreateInstance("MyModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "MyType");&lt;/P&gt;
&lt;P&gt;Absolutely no, even this assemby is current assembly or is added be dependent assembly. If you have done, it would throw the exception which message is "Could not load file or assembly 'MyModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.". In this case, we must load it when AppDomain resolve the name of it. Suppose the assembly file is MyModule.dll, we may consume the AssemblyResolve Event:&lt;BR&gt;try&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AppDomain domain = AppDomain.CurrentDomain;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;domain.AssemblyResolve += new ResolveEventHandler(LoadAssemblyHandler);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Object obj = domain.CreateInstance("MyModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "MyType").Unwrap();&lt;BR&gt;}&lt;BR&gt;catch (Exception ex)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Console.WriteLine(ex.Message);&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;private Assembly LoadAssemblyHandler(object sender, ResolveEventArgs args)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return Assembly.LoadFrom("MyModule.dll");&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;If I develope the program using .Net Framework 2.0, We'd better replace the event binding with anonymous methods:&lt;BR&gt;domain.AssemblyResolve += new ResolveEventHandler(delegate()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return Assembly.LoadFrom("MyModule.dll");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;});&lt;BR&gt;Easier than before, isn't it?&lt;BR&gt;&lt;/P&gt;&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=134316" width="1" height="1"&gt;</description></item><item><title>Change the Schema and Restart My Blog</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2005/12/14/134315.aspx</link><pubDate>Wed, 14 Dec 2005 06:23:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:134315</guid><dc:creator>wayfarer</dc:creator><slash:comments>0</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/134315.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=134315</wfw:commentRss><description>I nearly dump my blog because of my lazy. Now I decide to restart my blog, so I changed my blog's schema as the start point. I will record my gain and experience during developing software project and learning programing.&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=134315" width="1" height="1"&gt;</description></item><item><title>Debug And Release in Visual Studio.Net 2003®</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2004/12/21/38023.aspx</link><pubDate>Tue, 21 Dec 2004 11:55:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:38023</guid><dc:creator>wayfarer</dc:creator><slash:comments>3</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/38023.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=38023</wfw:commentRss><description>&lt;P&gt;Don't forget to change the debug mode to the release in Visual Studio.Net 2003&lt;SUP&gt;&amp;#174;&lt;/SUP&gt;&amp;nbsp;before you compile and publish your project.&lt;/P&gt;
&lt;P&gt;I didn't realize the difference between these until I read the &lt;A title="More articles by this author" href="javascript:AuthorSearch('K. Scott Allen');" target=_self&gt;K. Scott Allen&lt;/A&gt;'s article which title was &lt;A href="http://msdn.microsoft.com/msdnmag/issues/05/01/StaticsinNET/default.aspx"&gt;Get a Charge From Statics with Seven Essential Programming Tips&lt;/A&gt;, published on the MSDN Magazine January. He intruduced some tips of the statics in .Net. One of these, if you want to initialize the static field, there are two scenarios: &amp;#8220;The first scenario is when a developer explicitly adds a type constructor using the Shared keyword on a New subroutine in Visual Basic, or by adding a static, parameterless method with the same name as the type in C#. The second scenario is when a type has a initializer for a static field, in which case the compiler adds a type constructor behind the scenes.&amp;#8221;[Scott]&lt;/P&gt;
&lt;P&gt;There&amp;nbsp;was an example in his article written by VB.Net, and I translated it into C#. The source code is following:&lt;/P&gt;
&lt;P&gt;using System;&lt;BR&gt;namespace Exceptions&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;class Class1&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp; private static int max = Int32.MaxValue - 1;&lt;BR&gt;&amp;nbsp; [STAThread]&lt;BR&gt;&amp;nbsp; static void Main(string[] args)&lt;BR&gt;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TestStaticPropertyAccess();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.ReadLine();&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; static void TestStaticPropertyAccess()&lt;BR&gt;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp; DateTime begin = DateTime.Now;&lt;BR&gt;&amp;nbsp;&amp;nbsp; for (int i=0;i&amp;lt;max;i++)&lt;BR&gt;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; string message = ExplicitConstructor.Message;&lt;BR&gt;&amp;nbsp;&amp;nbsp; } &lt;BR&gt;&amp;nbsp;&amp;nbsp; PrintResult(DateTime.Now.Subtract(begin),"ExplicitConstructor");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; begin = DateTime.Now;&lt;BR&gt;&amp;nbsp;&amp;nbsp; for (int i=0;i&amp;lt;max;i++)&lt;BR&gt;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; string message = ImplicitConstructor.Message;&lt;BR&gt;&amp;nbsp;&amp;nbsp; } &lt;BR&gt;&amp;nbsp;&amp;nbsp; PrintResult(DateTime.Now.Subtract(begin),"ImplicitConstructor");&lt;BR&gt;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; static void PrintResult(TimeSpan span,string result)&lt;BR&gt;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp; Console.WriteLine("{0} took {1} ms.",result,span.Milliseconds);&lt;BR&gt;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;class ExplicitConstructor&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp; private static string message;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; static ExplicitConstructor()&lt;BR&gt;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp; message = "Hello World";&lt;BR&gt;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; public static string Message&lt;BR&gt;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp; get { return message; }&lt;BR&gt;&amp;nbsp; }&amp;nbsp; &lt;BR&gt;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;class ImplicitConstructor&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp; private static string message = "Hello World";&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; public static string Message&lt;BR&gt;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp; get { return message; }&lt;BR&gt;&amp;nbsp; }&amp;nbsp; &lt;BR&gt;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;He told us: &amp;#8220;the first loop (with ExplicitConstructor) executes approximately eight times slower than the second loop (with ImplicitConstructor).&amp;#8221; So I tried it, but I got the opposite result. Why? What happen? I couldn't get the right answer, so&amp;nbsp;I had to mail Scott. Soon he answered my stupid question. The reason was the difference between Debug and Release mode in Visual Stuio.Net 2003&lt;SUP&gt;&amp;#174;&lt;/SUP&gt;.&lt;/P&gt;
&lt;P&gt;His mail script is :&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#006400&gt;Hi Bruce: &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#006400&gt;I'm glad you enjoyed the article. Thank you for the kind note. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#006400&gt;A couple thing to check: &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#006400&gt;1. Make sure you compile the program in release mode &lt;BR&gt;2. Make sure to run the program outside of the IDE. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#006400&gt;Those two steps make sure the program is in release and has full optimizations. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Oh, my god, I forget it can optimize the performance when your programs&amp;nbsp;are in the release mode. Thank Scott!&lt;/P&gt;&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=38023" width="1" height="1"&gt;</description></item><item><title>I got a mywallop account today</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2004/12/14/36803.aspx</link><pubDate>Tue, 14 Dec 2004 10:55:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:36803</guid><dc:creator>wayfarer</dc:creator><slash:comments>2</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/36803.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=36803</wfw:commentRss><description>&lt;P&gt;A couples of day ago, my friend gave me an invitation from &lt;A href="http://www.mywallop.com"&gt;http://www.mywallop.com&lt;/A&gt;. But I was very busy these days, I didn't forget it nearly until the wallop sent a mail to me and informed me that the invitation would be expired in 3 days. &lt;/P&gt;
&lt;P&gt;After I registered it and entered the homepage of wallop, I was very surprised by its very nice ang great features. Inconceivably, all these were disigned by Flash. Through it, you can share the photos and music with your friends, and communicated with them online. You can registered your blog also. In a word, the wallop is very nice. You should register it as fast as you can, and enjoy it by yourself.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Btw: I have five invitations now. So if you want, contact me please:)&lt;/P&gt;&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=36803" width="1" height="1"&gt;</description></item><item><title>I Quit my Job</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2004/11/11/31773.aspx</link><pubDate>Fri, 12 Nov 2004 01:54:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:31773</guid><dc:creator>wayfarer</dc:creator><slash:comments>0</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/31773.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=31773</wfw:commentRss><description>Today I quitted my job, and I will move another city and work in another corporation after a couple of days. I hope this decision can&amp;nbsp;turn my life into&amp;nbsp;better. &lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=31773" width="1" height="1"&gt;</description></item><item><title>Check Channel Before Registering the New Channel in .Net Remoting</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2004/11/02/30705.aspx</link><pubDate>Tue, 02 Nov 2004 08:39:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:30705</guid><dc:creator>wayfarer</dc:creator><slash:comments>3</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/30705.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=30705</wfw:commentRss><description>&lt;P&gt;I don't understand what happen when I was prepared to register the new channel. It always warned the Channel had been used. I am clear that we can't use the same channel repeatedly in .Net Remoting, however I didn't use any channel before registering it. Even I restarted my computer, ran my project then, it occurred also. Oops, it's so terrible, isn't it? I don't know the reason that the exception was thrown, but fortunately, I can solve it.&lt;/P&gt;
&lt;P&gt;That is, when you are going to register the new channel, you might check the channel:&lt;/P&gt;
&lt;P&gt;if (ChannelServices.RegisteredChannels.GetLength(0) &amp;gt; 0)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (IChannel channel in ChannelServices.RegisteredChannels)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ChannelServices.UnregisterChannel(channel);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;//registering the new channel now.&lt;BR&gt;TcpChannel newChannel = new TcpChannel(8080);&lt;/P&gt;
&lt;P&gt;//...&lt;/P&gt;
&lt;P&gt;So, if there are some channels have been used by some application, it can unregister them by ChannelServices.UnregisterChannel(). Maybe, you should remember checking it before registering the new channel, don't you think so?&lt;/P&gt;&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=30705" width="1" height="1"&gt;</description></item><item><title>There are some tips about C# Written By Andrew Troelsen</title><link>http://dotnetjunkies.com/WebLog/wayfarer/archive/2004/10/23/29491.aspx</link><pubDate>Sat, 23 Oct 2004 12:27:00 GMT</pubDate><guid isPermaLink="false">58df7014-fd75-437c-9641-150997716d1c:29491</guid><dc:creator>wayfarer</dc:creator><slash:comments>4</slash:comments><comments>http://dotnetjunkies.com/WebLog/wayfarer/comments/29491.aspx</comments><wfw:commentRss>http://dotnetjunkies.com/WebLog/wayfarer/commentrss.aspx?PostID=29491</wfw:commentRss><description>General Tips and Tricks for C# developers 
&lt;DIV class=post&gt;
&lt;H5&gt;&lt;A id=CategoryEntryList.ascx_EntryStoryList_Entries__ctl0_TitleUrl href="http://blogs.msdn.com/csharpfaq/archive/2004/10/20/245412.aspx"&gt;Preprocess Win32 Messages through Windows Forms&lt;/A&gt;&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV class=post&gt;
&lt;H5&gt;&lt;A id=CategoryEntryList.ascx_EntryStoryList_Entries__ctl1_TitleUrl href="http://blogs.msdn.com/csharpfaq/archive/2004/10/20/245411.aspx"&gt;Be Mindful of the References / 'using' / Manifest Relationship&lt;/A&gt;&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV class=post&gt;
&lt;H5&gt;&lt;A id=CategoryEntryList.ascx_EntryStoryList_Entries__ctl2_TitleUrl href="http://blogs.msdn.com/csharpfaq/archive/2004/10/20/245408.aspx"&gt;Activate 'Full Screen Mode' During your Source Code Editing&lt;/A&gt;&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV class=post&gt;
&lt;H5&gt;&lt;A id=CategoryEntryList.ascx_EntryStoryList_Entries__ctl3_TitleUrl href="http://blogs.msdn.com/csharpfaq/archive/2004/10/20/245316.aspx"&gt;Leverage the C# Preprocessor&lt;/A&gt;&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV class=post&gt;
&lt;H5&gt;&lt;A id=CategoryEntryList.ascx_EntryStoryList_Entries__ctl4_TitleUrl href="http://blogs.msdn.com/csharpfaq/archive/2004/10/20/245297.aspx"&gt;Avoiding Type Name-Clashes using 'using'&lt;/A&gt;&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV class=post&gt;
&lt;H5&gt;&lt;A id=CategoryEntryList.ascx_EntryStoryList_Entries__ctl5_TitleUrl href="http://blogs.msdn.com/csharpfaq/archive/2004/10/20/245295.aspx"&gt;Build 'Consistent' .NET assemblies with FxCop&lt;/A&gt;&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV class=post&gt;
&lt;H5&gt;&lt;A id=CategoryEntryList.ascx_EntryStoryList_Entries__ctl6_TitleUrl href="http://blogs.msdn.com/csharpfaq/archive/2004/10/20/245247.aspx"&gt;Simplified Interface Implementation a la VS .NET 2003&lt;/A&gt;&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV class=post&gt;
&lt;H5&gt;&lt;A id=CategoryEntryList.ascx_EntryStoryList_Entries__ctl7_TitleUrl href="http://blogs.msdn.com/csharpfaq/archive/2004/10/20/245245.aspx"&gt;Simplified Event Handling a la VS .NET 2003&lt;/A&gt;&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV class=post&gt;
&lt;H5&gt;&lt;A id=CategoryEntryList.ascx_EntryStoryList_Entries__ctl8_TitleUrl href="http://blogs.msdn.com/csharpfaq/archive/2004/10/20/245242.aspx"&gt;Integrate ildasm.exe into VS .NET 2002&lt;/A&gt;&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV class=post&gt;
&lt;H5&gt;&lt;A id=CategoryEntryList.ascx_EntryStoryList_Entries__ctl9_TitleUrl href="http://blogs.msdn.com/csharpfaq/archive/2004/10/20/245239.aspx"&gt;Add Custom .NET Assemblies to the Add Reference Dialog&lt;/A&gt;&lt;/H5&gt;
&lt;P&gt;Andrew Troelsen is a&amp;nbsp;Microsoft C# MVP and partner / Vice President of Training and Technology at Intertech Training, where he has worked for over&amp;nbsp;8 years. But I found these tips from the &lt;A href="http://blogs.duncanmackenzie.net/duncanma" target=_blank&gt;Duncan Mackenzie&lt;/A&gt;'s Blog:-)&lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://dotnetjunkies.com/WebLog/aggbug.aspx?PostID=29491" width="1" height="1"&gt;</description></item></channel></rss>