One line business layer

A business layer method containing a object as parameter and just a single line of code with Data Layer call in method body is a BIG NO NO.

Some may find this very silly and have a question how is this possible. But recently I have seen code like that and it really caught me by surprise. The justification I heard was it’s a 3 Tier Architecture. I could just smile about such a deep problem in it, I too made such a mistake during my early days of programming. I was wondering how could someone make ignorance a friend. The incident was while using Asp.Net Web based application but can apply otherwise.

Even though the code file will separating Data Layer dependency from User Interface layer still it had below mentioned concerns :

  1. We have not created a good business class with specific single responsibility.
  2. We could not understood the business domain and thus not able to create related classes.
  3. There must be at least a validation check for the POCO objects that are been passed.
  4. In case of Dot Net class if the validation are done at User Interface using JavaScript then your business layer will break when browser has disabled scripting.
  5. This means that we have not understood object oriented programming. There may be instance where the methods will just call Data  Layer.
  6. There is no advantage of creating the method and its interface declaration, just to call Data Layer.
  7. Unit Test written for this method is actually calling the Data Layer method so it is redundant.

Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: