I already have a layered data access design which works well. But i dont know if it is the most suitable implementation or not.
i simply want to know that BLL classes or methots should be static or they should be concreate classes which has only one instance?
In the mean time i dont need to serialize BLL classes to use it in such a SOA design. But i dont know what the feature will bring.
Look at the following options:
Which one is the most efficent mostly in performance and desing?
EDIT:
Option1
public static class BllCustomer
{
public static List<ModelCustomer> GetCustomers()
{
}
}
// usage
BllCustomer.GetCustomers();
Option2
public class BllCustomer
{
public static List<ModelCustomer> GetCustomers()
{
}
}
// usage
BllCustomer.GetCustomers();
Option3
public class BllCustomer
{
public List<ModelCustomer> GetCustomers()
{
}
}
// usage
BllCustomer bllCustomer = new BllCustomer();
bllCustomer.GetCustomers();
Option4
public class BllCustomer
{
public List<ModelCustomer> GetCustomer()
{
}
}
// usage
public static BllCustomer s_BllCustomer = new BllCustomer();
// whenever needed
s_BllCustomer.GetCustomer();
In Java programming, the main motivation for making a method static is convenience. You can call a static method without creating any object, just by using its class name. So if you need a method, which you want to call directly by class name, make that method static.
We can declare a class static by using the static keyword. A class can be declared static only if it is a nested class. It does not require any reference of the outer class. The property of the static class is that it does not allows us to access the non-static members of the outer class.
A static class can be used as a convenient container for sets of methods that just operate on input parameters and do not have to get or set any internal instance fields. For example, in the . NET Class Library, the static System.
A static class is similar to a class that is both abstract and sealed. The difference between a static class and a non-static class is that a static class cannot be instantiated or inherited and that all of the members of the class are static in nature.
Serializing your Domain / BusinessLogicLayer classes sounds a bit unusual as your Domain layer typically holds you business rules and complex processing logic. Typically you will want to serialize your DataTransformation / POCO classes.
There will be marginal performance
differences between static or concrete classes / methods. I would shy away from static classes and methods for you main business logic as they can be difficult to mock / unit test, plus don't work with IoC containers. So with this in mind I would recommend option 3 as you've explained it. There is also some extremely useful answers posted here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With