Click here to Skip to main content
15,885,244 members
Articles / Programming Languages / C#

Design Patterns Part 2 - The Factory Pattern

Rate me:
Please Sign up or sign in to vote.
4.80/5 (74 votes)
8 Feb 2010CPOL10 min read 129.6K   1.2K   153  
The second part in WebBiscuit's design pattern series, this one examining the factory pattern. We look at an example of coping with ever-changing requirements by programming to interfaces and allowing the factory pattern to decide on the implementation.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Original.aspx.cs" Inherits="FactoryPattern.Original" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
      <asp:Label ID="lblTitle" runat="server" Text="Title"></asp:Label>
    
    </div>
    <asp:ListBox ID="lstProducts" runat="server" Height="277px" Width="339px">
    </asp:ListBox>
    <asp:ListBox ID="lstShipping" runat="server" Height="277px" Width="339px">
    </asp:ListBox>
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Web Biscuit
United Kingdom United Kingdom
At Web Biscuit, you can find software, articles, a good dollop of quality and an unhealthy obsession over biscuits.
Website: http://www.webbiscuit.co.uk
Twitter Watch: http://twitter.com/WebBiscuitCoUk

Comments and Discussions