6 Replies - 1660 Views - Last Post: 19 October 2013 - 10:23 AM Rate Topic: -----

#1 tieugiang94  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 160
  • Joined: 07-December 11

Confusion about Business Logic Layer

Posted 18 October 2013 - 07:28 AM

In n-tier i haven't understand a bout BBL.
I will talk a bit about Data Access Layer ( DAL ). ASP.net MVC/webfroms/winforms,Windows Phone.v.v..v.. will use this DAL to manipulate with database ( This mean DAL can be reused on all software platform of MS).

But about BBL. We also build an BLL with methods, then we also reuse it on many sortware platform.
The problem, assume we make an Logout() method ( to logout some thing ). On ASP.net we need to destroy user Session but Winform haven't Session, we just close User Interface ( Forms ). That we have to write new Method => That is not reuse code ( and above thing very non-sense, a method interact with both Web form and win form ).

I'm very confusion about the uses of BBL. What will we do this BLL ? Is "Reuse BLL" a true statement ?

Is This A Good Question/Topic? 0
  • +

Replies To: Confusion about Business Logic Layer

#2 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1181
  • View blog
  • Posts: 1,675
  • Joined: 24-August 11

Re: Confusion about Business Logic Layer

Posted 18 October 2013 - 08:45 AM

LogOut() sounds like a UI method to me, not a Business Object method. You don't log in to an object, you log in to a system. If you want your business objects to dispose of themselves when the user logs out of the system, then the UI's LogOut() method can certainly notify those objects to do so. That's the reusable part: it doesn't matter what the UI's "end session" method looks like (whether a logout button or clicking the "X" in the top-right corner), as long as it makes the appropriate calls to the business objects.
Was This Post Helpful? 0
  • +
  • -

#3 tieugiang94  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 160
  • Joined: 07-December 11

Re: Confusion about Business Logic Layer

Posted 18 October 2013 - 09:27 AM

Is each Project have each BLL ?
Could you give me an best sample n-tier in MVC ( this is the best answer for me )
Was This Post Helpful? 0
  • +
  • -

#4 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1181
  • View blog
  • Posts: 1,675
  • Joined: 24-August 11

Re: Confusion about Business Logic Layer

Posted 18 October 2013 - 12:32 PM

Depends on whether or not you're referring to each Project (Class Library, MVC Site, etc.) in a solution, or if you're referring to a project in the more general sense, and it also depends on the size of the solution you're working on. A small MVC site can just have everything spread through the folders in the MVC project, without adding separate class libraries and such to the solution. When you get into larger solutions, that's when you might consider moving your business objects into their own Project. It sounds like you could stand to find a good MVC book to read and work through. This is a good book that I recommend.
Was This Post Helpful? 1
  • +
  • -

#5 tieugiang94  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 160
  • Joined: 07-December 11

Re: Confusion about Business Logic Layer

Posted 18 October 2013 - 07:41 PM

If I have a method it generate random number Rand(). Should we put it in BBL ?.
And methods relevant to GUI ( or something like session ( Web only )or form ( winform only ) will we put it in Controller ( of MVC ) or CodeBehind ( ASP.net Web Forms ) ?

Above question may solve my question :)
Was This Post Helpful? 0
  • +
  • -

#6 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1181
  • View blog
  • Posts: 1,675
  • Joined: 24-August 11

Re: Confusion about Business Logic Layer

Posted 19 October 2013 - 08:39 AM

Quote

If I have a method it generate random number Rand(). Should we put it in BBL ?.


Depends on who's using the random number. If a business object needs the random number for something that it does, then let the business object be responsible for creating that random number. If you design your application such that the UI is responsible for supplying it, then you've just created a constraint on what a new UI for the application would have to do (remember, the goal is reusability, so the more design constraints you generate from you business logic layer's design, the less reusable it becomes).

Quote

And methods relevant to GUI ( or something like session ( Web only )or form ( winform only ) will we put it in Controller ( of MVC ) or CodeBehind ( ASP.net Web Forms ) ?


The code that the UI needs to be run should be in the UI. Your model represents that data in your application. The view is where the users can interact with that data. The controllers are like security guard interpreters: they are responsible for allowing access to the data, but ONLY within the constraints that live in the controllers. The view doesn't know what it's allowed to show or let the user change, and the model doesn't know what functionality should be exposed in the application's context. If you were to say that based on all of this, it sounds like session is a UI thing and should therefore be managed by the view, I would agree with you.

This post has been edited by h4nnib4l: 19 October 2013 - 08:39 AM

Was This Post Helpful? 1
  • +
  • -

#7 tieugiang94  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 160
  • Joined: 07-December 11

Re: Confusion about Business Logic Layer

Posted 19 October 2013 - 10:23 AM

Thanks, Finally I understood n-tier :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1