Home > Microsoft .Net Development Tips > .NET Developer > Explore the utility of .NET coding patterns
Win Development Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

.NET DEVELOPER

Explore the utility of .NET coding patterns


Ed Tittel, Contributor
02.14.2006
Rating: --- (out of 5)


Office Development Channel
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


In the old-fashioned variety of architecture -- the kind that applies to buildings, houses and other physical structures -- Christoper Alexander's famous books The Timeless Way of Building (1979) and A Pattern Language (1977) helped to revolutionize that field. Their fundamental insight was that certain kinds of structural usages or arrangement recur repeatedly in the most workable and successful structural designs. These are known as "design patterns" and represent a compressed type of best design practice that all wise architects incorporate into their own work.

Erich Gamma, Richard Helm, Ralph Johnson, and John Vissides took this idea and ran it deep into the software realm with the publication of their own seminal work Design Patterns: Elements of Reusable Object-Oriented Software in 1995. In the intervening 11 years since its publication, design patterns books for programs have proliferated wildly -- a quick search at Amazon on software titles that include "Design Patterns" in their names produces 61 hits, of which more than 40 are unique.

Suffice it to say that design patterns is an idea whose time has come, and whose application serves developers well in all kinds of object-oriented environments, including .NET and its related programming languages. That probably explains why six titles from the aforementioned list target .NET specifically (visit Amazon and search on ".NET design patterns" to see them for yourself). It's probably no accident that three of these books tackle VB.NET, two deal with general .NET design patterns, and the last with C#.

There's another online resource that fits into this picture as well. It's the Code Project's Commonly Used .NET Coding Patterns pages. Free to anyone who cares to stop by and inspect its contents, this site makes an interesting and convincing demonstration of the power and utility of the design pattern concept. It works with the .NET Code Document Object Model, aka CodeDom, which is of particular interest to those working with C# and ASP.NET.

There, you'll find the following patterns described and exemplified (with links to each one for easy reference or access):

  • The BeginProcess/EndProcess pattern: This is used to start and stop, or to begin and end, process initialization in the .NET environment.
  • The Cursor Lock pattern: This is used to lock the Cursor property within a Windows Form.
  • The Delegate pattern: This is used to work with event handlers in the Common Language Runtime (CLR) where delegates are created using object and EventArgs, including a custom-crafted EventArgs class.
  • The Event pattern: This is a pattern from System.Windows.Forms where events require special invocation methods.
  • The Flags pattern: This recurs throughout the CLR, where enum is flagged using FlagsAttribute, especially to allocate values.
  • The For Each pattern: Built into C#, but not native, this pattern iterates over any collection that implements the System.IEnumberable interface.
  • The Get Property/Field pattern: This recurs throughout the CLR, whenever a private field is exposed using a property with a get accessor.
  • The Is Instance Of pattern: Though this is built into C# as the is keyword, it's not implemented in CodeDom. The pattern determines if an object's type implements, inherits, or matches the queried type.
  • The Lock pattern: Another pattern built into C#; this locks a resource using the System.Threading.Monitor class.
  • The Observer pattern: This often-used code pattern lets subscribers receive notification of any change to a monitored value, using an event to announce the change.
  • The Singleton pattern: This permits a class to have only a single instance in an application. It's thread-safe, and can follow a lazy- or pre-loading implementation.
  • The Using pattern: Also one built into C#; this uses a resource that implements the System.IDisposable interface, and releases it when finished using it.
  • Binary Operator patterns: This extends normal CodeBinaryOperatorExpression to add the additional operator BooleanExlusiveOr.
  • Unary Operator patterns: This extends normal CodeBinaryOperatorExpression to add unary operators BooleanNot and BooleanIs.
  • Compound Assignment patterns: This extends normal CodeAssignStatement to add the following operators: Add, Subtract, Multiply, Divide, Modulus, BitwiseAnd, and BitwiseOr.

    Those interested in learning more about design patterns are advised to check out the general Design Patterns software book cited earlier here, or perhaps to dig into the general or C# .NET books that are easy to find on Amazon. Those ready to dig in will find useful ammunition at the Code Project's Web site.


    Ed Tittel is a writer and trainer whose interests include XML and development topics, along with IT Certification and information security. E-mail etittel@techtarget.com with comments, questions, or suggested topics or tools to review. Cool tools rule!

    Rate this Tip
    To rate tips, you must be a member of SearchWinDevelopment.com.
    Register now to start rating these tips. Log in if you are already a member.




    Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



    RELATED CONTENT
    .NET Developer
    How to speed up Visual Studio 2008's slow WPF designer
    How to list fonts in WPF using markup extensions and data templates
    How to convince management to buy Microsoft Visual Studio 2008
    Microsoft webcast series previews new Visual Studio 2010 features
    New features in Windows 7 bring new UI considerations for developers
    User Account Control (UAC): How to develop code for standard users
    Introduction to Vista's user account control (UAC) for developers
    Visual Studio 2008 code metrics tools will help keep code clean
    Downloadable MSDN library released for VS 2008 SP 1
    Widgetbox provides good example of how to use Facebook Developer Toolkit

    .NET Architecture Best Practices
    Introduction to ASP.NET's Model View Controller (MVC) Design Pattern
    Free book from Microsoft brings patterns and practices to .NET
    Java application frameworks come to .NET
    The faces of .NET/Java interoperability
    .NET Development coming to a Cloud near you
    Distributed caching goes mainstream
    A look at concurrency constructs and primitives in .NET
    Designing Windows Communication Foundation service contracts
    Scaling WCF applications can challenge development teams
    Microsoft touts rich Internet app development at Mix08
    .NET Architecture Best Practices Research

    RELATED GLOSSARY TERMS
    Terms from Whatis.com − the technology online dictionary
    .NET  (SearchWinDevelopment.com)
    C#  (SearchWinDevelopment.com)

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary

    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



  • Database Programming Solutions - .NET XML, Visual Studio LINQ, ORM .NET
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Site Map




    All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts