search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsFAQs
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Operating SystemsArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

Design Patterns for all – Chapter I (Introduction to Design)


By Sakshi a
Printer Friendly Version
View My Articles
45 Views
    

In this chapter we will see the basics of Design patterns and OOPs which will give the foundation for understanding Design patterns better. In the coming chapters we will see the Design patterns in detail with practical examples and code.


Design Patterns for all – Chapter I (Introduction to Design patterns and OOPs)

In this chapter we will see the basics of Design patterns and OOPs which will give the foundation for understanding Design patterns better. In the coming chapters we will see the Design patterns in detail with practical examples and code.

Definition:

Design Patterns are best proven techniques for a common design problem.  

It is only a design technique and not code. Though code is available for almost all design patterns in all popular languages, design patterns mean the design technique alone.

Each design pattern explains a repeated problem, gives standard solution to the problem.

History:

GoF Gang of four, a four member team (Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides) are said to be people who brought up this idea. They wrote some patterns which are considered the base for all other patterns.

Types of Patterns:

Design Patterns are generally classified into three categories, they are:

1.      Creational

2.      Structural

3.      Behavioral

1. Creational

They deal with object creation. They provide you the best way to create objects based on the current situation.

Example:

Singleton, Factory method, Abstract factory, Builder

2. Structural

They deal with relationship between entities. They provide you the best way to relate entities on various scenarios.

Example:

 Adapter, Aggregate, Bridge

3. Behavioral

They deal with communication between objects. They provide you the best way to communicate between objects.

Example: 

Chain of responsibility, Command, Interpreter

Further Classification:

            Though the above three are the major classification, one more category also exists which may be considered as a sub part of the above. It is:

Concurrency

They deal with multi-threaded programs. They provide solutions for multi-thread design problems.

Example:

Balking, Double checked locking, guarded suspension

OOP Techniques and Design Patterns:

Before going into design patterns, we need to know some of the OOP (Object Oriented Programming) features, which will in turn lead to a better understanding of Design patterns.

Let us now see the OOPs features one by one,

Class:

            It defines characteristics of a thing and its behavior. It is blueprint from based on which objects are created.

Example: Employee (which will have all the details about the employee like name, id, salary, etc and the methods which describes his behavior like calcSalary(),displaydetails(),etc.

Object:

            Is an instance of a class. It will be exactly the same as a class but can be assigned values and used whereas a class can’t be used without creating objects.

Inheritance:

            A feature in which the base class’s characteristics and behavior are derived to the child class also.

Types:

Single

Multiple

 

Single:

            A class inherits from a single class.

Multiple:

            A class inherits from more than 1 class.

Abstraction:

            “Abstraction is simplifying complex reality by modeling classes appropriate to the problem, and working at the most appropriate level of inheritance for a given aspect of the problem.” Is what the Wikipedia says.

Encapsulation:

            It is a feature which hides data and functions from others classes.

Polymorphism:

            A feature using which more than one definition is given to a single name. It can either be function polymorphism or operator overloading.

Association:

            Association defines a relationship between classes of objects which allows one object to cause another to perform an action on its behalf.

Composition:

            Composition is a way to combine simple objects or data types into more complex ones.

Aggregation:

            Aggregation is a form of composition where one looks at the system as a whole rather than as parts.

 



button
Article Discussion: Design Patterns for all – Chapter I (Introduction to Design
Sakshi a posted at Friday, June 19, 2009 6:11 AM
Original Article