I am studying about how to use an interface for decoupling, and I wrote a program. Does it actually implemented decoupling? Are there any possible modifications to make it better?
public partial class MainPage
{
// Constructor
public MainPage()
{
InitializeComponent();
IDBInterface idbInterface = new SQL();
CommunicationChannel com = new CommunicationChannel();
com.Update(idbInterface);
}
}
interface IDBInterface
{
void Update();
}
class SQL:IDBInterface
{
public void Update()
{
MessageBox.Show("Please wait.. We are updating SQL Server...");
}
}
class Oracle : IDBInterface
{
public void Update()
{
MessageBox.Show("Please wait.. We are updating Oracle Server...");
}
}
class CommunicationChannel
{
public void Update(IDBInterface idb)
{
idb.Update();
}
}
}
IDBInterface
. Make itIDb
or even betterDbInterface
.. \$\endgroup\$ – nawfal Feb 25 '13 at 10:07