Need help in Design

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am developing an application which need to support various data sources
like SQL Server, Access, Oracle etc

I am in search of a design pattern which will best suit my requirement.

Can somebody help me in that ..
 
Rahul,

A bit more information on what you want to do would help, but assuming you
are performing the same operations on different types of databases you could
use Template Method. This has an abstract base class that defines the steps
with the derived classes providing the implementation for those steps:

abstract class DataSource
{
abstract public void Open();
abstract public void Process();
abstract public void Close();

public void Run()
{
Open();
Process();
Close();
}
}

class SqlDataSource : DataSource
{
public override void Open()
{
// SQL specific implementation
}

...
}

--Liam.
 
You may be interested in one of the talks presented at OOPSLA a couple of
months ago... this one by Joe Hummel, a CS Professor. He was discribing how
the use of the factory method pattern can be useful in not only teaching OO,
but creating a good structure for encapsulating database access... in .NET
of all things.

Here's a link. Sounds right down your alley:
http://campus.lakeforest.edu/~hummel/_talks.htm

--- Nick
 
Back
Top