Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Blogs | E-Books | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article 
 Login Close
User Id:
Password:
 
Forgot Password
Forgot Username
Why Register
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » Design & Architecture » Software Design Guidelines for .NET

Software Design Guidelines for .NET

Through this article I will attempt to break down this fire breathing dragon. And hopefully at the end of it, you would feel confident of riding this dragon towards glory and respect.

Technologies: .NET 2.0, .NET 3.0 and 3.5,Visual C# .NET
Total downloads : 114
Total page views :  5620
Rating :
 0/5
This article has been rated :  0 times
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
Download Files:
FxCop Demo.zip
 
ArticleAd
Become a Sponsor




Prerequisite:

Anyone who is related to the software development cycle can benefit from this article. However prior knowledge of Object Oriented Programming will help you understand many parts of the article as well as the programming samples.

Introduction

What is Good Software Design? Are there written Guidelines which clearly mention what is 'Good' design and 'Bad' design? Are there any tools which can analyse your source code or assembly, and highlight code which do not follow Good Design Guidelines?

Before we answer these questions, let us understand what Software Design means.
When computer software students do their college projects, the software development life cycle is usually as follows.

  1. The students team up in a group of 2-4 and select a project.

  2. The students do a bit of brainstorming and then start the public static void Main () followed by all the coding.

  3. Once the project is complete, flowcharts are drawn, comments are added to code and the source code printouts are collated to create a project manual.

It's so simple. As they say "If it ain't broke don't fix it". These students enter the software industry with the same mindset and approach each project in the same. Many of these students will be working on small to medium level project and may use the techniques they employed as students all through their working life.

However some will join large organizations, where software development teams are usually large. A typical project, I've worked on included 15 developers, 2 project leaders, 1 project manager and 3 testers. But teams as large as a 100 are not unheard of.

Types of Projects


With huge enterprise projects, only the foolish will follow the same college student approach. Well, you may ask, why not?

Consider a project scenario at home. If you are to build a dog house for your pet, you would most probably just go the local hardware store and purchase a few planks and nails. Get to work with a hammer and you have a dog house ready. As long as the client (your pet) is happy with it, and it doesn't have any obvious bugs (leaking roof), you would have done a good job.
Now suppose you are building a house for your family. Unless you have a very good divorce attorney, heaven help you if you approach the problem like you did with the dog house. You would more than likely discuss the needs of your wife and kids in detail. Identify the number of rooms along with the size and shape. Draw a software blueprint, not only for yourself but also the local fire department and housing authorities, who may have specific requirements. Then you decide on the budget and timelines, in consultation with the other stake holders (wife and kids). Only then will you attempt to build your house
And finally consider the And finally consider the building of a 50 storey sky scraper. You will be possibly working with a large team of professionals. You will review hundreds of architectural designs. Structural engineers would be involved in integrating earthquake resistant technologies and fire proofing materials into the design.


When every other industry places so much emphasis on design, the software industry woke up pretty late to the benefits of Good Software Design.

The Software Industry wakes up

With the creation of an Object Oriented Programming language like C++, developers and designers were suddenly given this great tool for designing and writing code which was encapsulated, reusable and maintainable.

Object-Oriented techniques typically show relationships and interactions between classes and objects. However C++ does not describe the best way for two classes to interact with each other. Also they do not specify the final application classes or objects. Given a problem statement what's the best solution for it.

In October 1994, the book Design Patterns: Elements of Reusable Object-Oriented Software, by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (Gang of Four) was published. This book brought software design out into the open, and companies began adopting them in the software development life cycle.

What are the Design Pattern?

A software project module can be broken down into many smaller modules until each module do not need more than 10 classes to make it work. Now if you come across one of these problem statements, how will you approach it? Brainstorm, create class diagrams and come up with a design which you think will get the job done. However do you think you have created the world's best design or could there be a better design to the same problem? Possibly, there could be unless you yourself have 10+ years of software designing experience.

There are many such problem statements which have been solved before using different designs by many different programmers/designers. Over the years, some of these designs were found to be better than others.

Design Patterns documents these commonly occurring problem statements and describes a general solution to the problem. The key thing to remember here is general solution to the problem. This means Design Patterns is not a readymade design which can be directly transformed to code. It is just a description or template of the solution. The Gang of Four defined Design Patterns as follows.

A design pattern is a general reusable solution to a commonly occurring problem in software design.

You can read more about design patterns at
http://en.wikipedia.org/wiki/Design_pattern_(computer_science)

You can also read about the book by the Gang of Four at
http://en.wikipedia.org/wiki/Design_Patterns


Microsoft .NET Framework design guidelines

Another small but significant aspect to designing and writing good software programs, is the adherence to standards and naming conventions.

In the good old days, large software companies had their own standards for software programming including variable naming conventions.

Why have these standards and naming conventions at all?

  1. They reduce the effort needed to read and understand source code. All stake holders who follow the same standard can easily understand code written by another programmer.
  2. They enhance source code appearance.
  3. Many certifications (for example Microsoft Certified Software), requires your code to follow certain standards.

Microsoft introduced the .NET Framework design guidelines to help companies converge to one standard, rather than maintain their own proprietary standards. This not only helps reduce the burden on programmers, but companies find it easier to move people between projects and also integrate new employees faster into a project team.

You can read about all the .NET Framework design guidelines at
http://msdn.microsoft.com/en-us/library/ms229042.aspx
. I love reading all this stuff but then, being lazy programmers, I know most of us would rather automate this.

Microsoft has released, FxCop which is a free static code analysis tool for .NET. It checks managed code assemblies for adherence to the Microsoft .NET Framework Design Guidelines. Since FxCop analysis the compiled assemblies (dll), i.e. MSIL, it works with any of the .NET languages includes C# and Vb.Net.

 

Installing and Configuring FxCop

  1. After installing it, start FxCop from the Start Menu or the Desktop icon to see the following screen.



  2. I am using a C# Console Application project called ConsoleApplication1 and a C# Class Library project called ClassLibrary1 to demonstrate FxCop. In the ConsoleApplication1 project, add reference to the ClassLibrary1 Project.

    ConsoleApplication1 has a single class Program.cs with the following code.

    using ClassLibrary1;

    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                Class1 obj = new Class1(28, 9500, "John");
                obj.Show();
            }
        }
    }

    ClassLibrary1 has a single class Class1.cs with the following code.

    using System;
    namespace ClassLibrary1
    {
        public class Class1
        {
            private int Age, _sal;
            public string Name;
            //Constructor
            public Class1(int Age, int Salary, string Name)
            {
                this.Age = Age;
                this._sal = Salary;
                this.Name = Name;
            }
            public void Show()
            {
                Console.WriteLine("Name={0}, Age={1}, Sal={2}", Name, Age, sal);
            }
        }
    }

  3. Create a new FxCop Project and save it in the same folder as the solution whose assemblies you want to analyse. Also name the project file as follows. In our example the solution is ConsoleApplication1.sln so I named the FxCop project ConsoleApplication1.sln.FxCop. (Note: This step is not a requirement but doing this will help you integrate FxCop with Visual Studio 2008.)

  4. Right click on the Targets section and select the menu option [Add Targets]. Select ClassLibrary1.dll from either the debug or release folders inside ClassLibrary1\bin. The FxCop window will look as follows.



  5. Press F5 or Click on the Analyse Tool Button to display the analysis report as follows. Clicking on the analysis entry to the right, will display details in the properties section at the bottom of the window. Click on the location link to open the offending line within visual studio.

Conclusion

Developers who implement 'Good Software Design' in their day to day programming activities:

  • Earn better ratings during appraisals
  • Get bigger bonuses, and,
  • Their resume looks so much more impressive.
Something which entry level developers should understand is that it takes many projects to understand and appreciate the need and benefits of Good Software Design. And it may take years for developers to create great Software Design solutions.

So hang in there. Every day is a learning experience. 


Login to add your contents and source code to this article
 [Top] Rate this article
 About the author
 
Avinash Tauro
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Boost the performance of your .NET applications
“ANTS Profiler took us straight to the specific areas of our code which were the cause of our performance issues." Terry Phillips, Sr. Developer, Harley-Davidson Dealer Systems. Download your free trial of ANTS Profiler.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
 
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
Download Files:
FxCop Demo.zip
 
 Post a Feedback, Comment, or Question about this article
Subject:  
Comment:  
ArticleAd
Become a Sponsor
Latest Comments:
Subject Posted By Posted On
This was neededMamta11/5/2008
Lack of design guidelines is one of the major problems in s/w development. This article has brought out very well how and why guidelines are necessary. Good work!
Reply | Email | Delete | Modify | 
 
 
Re: This was neededAvinash11/5/2008
Thanks.

I totally agree with you that good design can make or break a s/w project.
Reply | Email | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2009.6.2
 © 1999 - 2009  Mindcracker LLC. All Rights Reserved