by smakazmi
9. October 2010 01:46
Recently in the workplace I got into a little fun argument regarding whether we should access 'Session State' in the business layer or not. I said we should because it makes life easier. The other guy said it was a bad practice to do so. Going against a best practice ???!!! What was I thinking. Let me tell you just that. First lets put the argument in context.
The pros and cons of dragging your session in your BLL are basically as follows:
Pros:
It makes your life easier
Cons:
It makes unit testing a pain
It can't work if your BLL is hosted as a separate tier
The cons don't apply as the application under discussion is a web application that has the BLL tied to it as a direct reference. Its not a separate web service. Secondly we don't unit test our code and we don't intend on starting anytime soon. Unit testing IS a best practice but we at our company don't use it because we made an informed decision that its an overhead for us and we can do without it.
Best practice is whats best in most cases NOT all. That's where your brain should kick in.
I feel that we are forgetting that (good) programming is a creative process. Its not done based on an algorithm. You have to think pragmatically about the current best practices and if they apply to your situation. We've to make informed decisions not based on gut feeling or blindly accept a best practice.
There are no holy commandments in software development. That is what makes it exciting and we should not take the fun out of it by blindly following best practices.