Design Patterns

There are three basic classification of patterns Creational, Structural, Behavioral patterns.


Creational Patterns
==============

Abstract Factory:- Creates an instance of several families of classes
Builder :- Separates object construction from its representation
Factory Method:- Creates an instance of several derived classes
Prototype:- A fully initialized instance to be copied or cloned
Singleton:- A class in which only a single instance can exist

Structural Patterns
==============

Adapter:-Match interfaces of different classes.
Bridge:-Separates an object’s interface from its implementation.
Composite:-A tree structure of simple and composite objects.
Decorator :-Add responsibilities to objects dynamically.
Façade:-A single class that represents an entire subsystem.
Flyweight:-A fine-grained instance used for efficient sharing.
Proxy:-An object representing another object.

Behavioral Patterns
===============

Mediator:-Defines simplified communication between classes.
Memento:-Capture and restore an object's internal state.
Interpreter:-A way to include language elements in a program.
Iterator:-Sequentially access the elements of a collection.
Chain of Resp:-A way of passing a request between a chain of objects.
Command:-Encapsulate a command request as an object.
State:-Alter an object's behavior when its state changes.
Strategy:-Encapsulates an algorithm inside a class.
Observer:-A way of notifying change to a number of classes.
Template Method:-Defer the exact steps of an algorithm to a subclass.
Visitor:-Defines a new operation to a class without change.




Read Users' Comments (0)

TSQL: Concatenate Multiple Rows into String

use Northwind

declare @CategoryList varchar(1000)
select @CategoryList = coalesce(@CategoryList + ‘, ‘, ”) + CategoryName from Categories

select ‘Results = ‘ + @CategoryList

Read Users' Comments (0)

datatable grouping

Ex : var masterGroups = (from row in dtRetCls.AsEnumerable()
group row by row["GroupDescription"] into groupedTable
select new
{
x = groupedTable.Key
}
).ToList();

Select data rows

DataRow[] drx = dtRetCls.Select("GroupDescription= '" + item.x + "' ");

Read Users' Comments (0)

Computed Column Specification

Ex :

(((isnull([AuthorizedQtyU1],isnull([InvoiceQtyU1],(0)))-isnull([ReceivedQtyU1],(0)))-isnull([DamagedQtyU1],(0)))-isnull([MissingQtyU1],(0)))

Is Persisted = no

(datediff(minute,[StartTime],[EndTime]))

Is Persisted = no

Read Users' Comments (0)

filter generic list items

BatchExeProduct batchExeProductObject = batchExeProducts.Find(delegate(BatchExeProduct ep) {return ep.ExecutiveCode == exeCode; });

Read Users' Comments (0)

Remove cache in asp.net page

So far I've tried the page directive:

@ OutputCache Duration="1" Location="None"

The Meta tags:

<meta http-equiv="Expires" CONTENT="0">

<meta http-equiv="Cache-Control" CONTENT="no-cache">

<meta http-equiv="Pragma" CONTENT="no-cache">

And the code:

Response.ExpiresAbsolute = DateTime.Now

Response.Expires = -1441

Response.CacheControl = "no-cache"

Response.AddHeader("Pragma", "no-cache")

Response.AddHeader("Pragma", "no-store")

Response.AddHeader("cache-control", "no-cache")

Response.Cache.SetCacheability(HttpCacheability.NoCache)

Response.Cache.SetNoServerCaching()

Read Users' Comments (0)

filter sql

WHERE convert (datetime, convert (varchar, datecol, 101), 101) = @yourdate

Read Users' Comments (0)