Pregunta

Good morning, i have a use-case in my project that says that If the user isn't logged in to the application display a warning message to him and what determines if the user is logged in or not is a managed bean called loginPageCode, a class in the business logic layer will be responsible to determine if the user is logged in or not in order to take a decision for displaying a message(that action will be taken when a specific action occurs in a JSF page called home.jsf), i thought of 2 approaches to do that as follows:

  1. Make the home page determine if the user is logged in or not and pass the final decision to the business logic class
  2. Make the business logic class be responsible for determining if the user is logged in or not and that will require it to deal directly with loginPageCode

i want to know the suitable way of doing that from the point of design.

¿Fue útil?

Solución

If the business logic layer needs to know if the user is logged in, you should just pass along that information as an argument.

The business layer should not need to know HOW the user is authenticated, if it needs to know if the user is logged in it should be given that information -- that's separation of concerns for you! :)

The main idea is that you can always reuse the same business rules even in an entirely different environment, e.g, using a different authentication mechanism.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top