In a layered architecture ,the business classes contains all the methods of the entities with business exceptions which communicates with data access layer.
After creating such business classes,when developers consume the methods normally they create the instance of the class either at top level or in each method.
But this can be more optimized to create a new class with static methods which instantiates the business classes only once and this can be used throughout the Presentation Layer.
Following is the code snippet.Create a class
public class BusinessInstanceCreator
{
public static Namespace.Business.BusinessClass.Class1 NewClass1
{
get { return new Namespace.Business.BusinessClass.Class1 NewClass1(); }
}
public static Namespace.Business.BusinessClass.Class2 NewClass2
{
get { return new Namespace.Business.BusinessClass.Class2 NewClass2; }
}
}
Following class can be used in your pages as
DataTable list = BusinessInstanceCreator.NewClass1.Method1();
No comments:
Post a Comment