Interesuje me koliko je ovo dobar/los nacin za implementiranje datalayer-a u web aplikaciji.
Znaci postojala bi jedna instanca klase (na nivou aplikacije) koja sadrzi sve metode za pristup bazi, a koju bi koristio business layer.
DataLayer:
Code:
public class Singleton
{
private static Singleton instance = new Singleton();
private Singleton() {}
public static Singleton Instance
{
get
{
return instance;
}
}
// metode za pristup bazi...
}
public class Singleton
{
private static Singleton instance = new Singleton();
private Singleton() {}
public static Singleton Instance
{
get
{
return instance;
}
}
// metode za pristup bazi...
}
BusinessLayer:
Code:
public class User
{
Singleton data = Singleton.Instance;
public User()
{
}
public void DoSomethingWithUser()
{
data.DoSomethingWithUser(this);
}
}
public class User
{
Singleton data = Singleton.Instance;
public User()
{
}
public void DoSomethingWithUser()
{
data.DoSomethingWithUser(this);
}
}
[Ovu poruku je menjao vanhulio dana 21.03.2006. u 20:52 GMT+1]
Two items walk into a ToolBar.
The bartender says, “Can I get you a menu?”
“No thanks, we're looking for a little action.”
The bartender says, “Can I get you a menu?”
“No thanks, we're looking for a little action.”