Friday, July 25, 2008

Solidify Your C# Application Architecture with Design Patterns



SUMMARY A design pattern can solve many problems by providing a framework for building an application. Design patterns, which make the design process cleaner and more efficient, are especially well-suited for use in C# development because it is an object-oriented language. Existing design patterns make good templates for your objects, allowing you to build software faster. This article describes several popular design patterns you can use in your own applications, including the singleton, the decorator, the composite, and the state classes, which can improve the extensibility of your applications and the reuse of your objects


C# and Design Patterns C# is a modern programming language that promotes object-oriented software development by offering syntactic constructs and semantic support for concepts that map directly to notions in object-oriented design. This is in contrast to C++, which supports procedural as well as object-oriented (and generic) programming. Nonetheless, if you are a C++ programmer, getting up to speed with C# should be a snap—the learning curve for C++ programmers is flat. Even if you haven't seen any C# code before, you should have no problem comprehending the example code in this article. In fact, I wouldn't be surprised if you find the C# implementation of the design patterns cleaner, especially if you have used or coded the patterns before. Books and articles that discuss design patterns typically explain the problem and the context in great detail, followed by a formal description of the solution. I will take a less rigorous approach in this article, focusing on the essence of the pattern instead, and illustrating an appropriate example with some sample code in C#
Let's start with the simplest design pattern: Singleton.

Singleton Anyone who has ever written an MFC application—no matter how small—knows what a singleton is. A singleton is the sole instance of some class. To use an MFC analogy, the global instance of the CWinApp-derived application class is the singleton. Of course, while it's imperative that no additional instances of the application class be created, there really is nothing preventing you from creating additional instances. In situations like these, when you need to enforce singleton behavior for a specific class, a better alternative is to make the class itself responsible for ensuring that one and only one instance of the class can be created. Back in the MFC analogy, you see that the responsibility for keeping track of the solitary instance of the application class rests with the developers of the application. They must not inadvertently instantiate another application object.

Thursday, July 24, 2008

On the Way to Mastering ASP.NET

Be Right at Home in the World's Most Powerful Web Development Environment



In recent years, creating dynamic, server-side web applications has become the most vital part of web development. Now, thanks to ASP.NET and Visual C#, you can build cleaner, more powerful web applications, and you can do it more quickly than ever before. Mastering ASP.NET with C# is an essential guide to harnessing the power of the .NET Framework to develop and consume Web Services of all kinds. This book is packed with the skills you need to get started creating ASP.NET applications, including using Web Forms, connecting to databases with ADO.NET, and working with XML. Coverage Includes: Using the ASP.NET intrinsic objects; Employing the ASP.NET Server controls; Using HTML controls; Saving state data with cookies; Uploading files; Sending email; Retrieving and displaying data from databases; Building User and Composite controls; Building custom controls; Managing multiple ASP.NET configuration files; Creating Web Services, Web Forms