Windows > Software Development for Windows Client Forums > Windows Workflow Foundation > 3 layered architecture - Where to house rules?
Ask a questionAsk a question
 

Answer3 layered architecture - Where to house rules?

  • Friday, December 16, 2005 4:57 PMmsheridan69 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    In my business layer I have a business components (BC) assembly and a business workflows (BW) assembly. I plan to have validation rules such as mandoatory field, range validation etc. in the (BC) and business rules/poilicies such as 'calculate order discount' in the BW assembly. All CRUD operations are also implemented in the BC assembly. All services in both assemblies are exposed to the presentation layer through a Services Interface.

    (To help visualise http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ArcThreeLayeredSvcsApp.asp)

    1. When I call one of the crud opeartions (in the BC assembly) such as create or update on an order line for example, I would like to apply the 'calculate order discount' rule (in the BW assembly). Is this the correct way to do this?

    2. Should the crud operations also be sequential workflows in the BW assembly and not methods in the (BC)?

    3. Where should validation logic be? On the form or encapsulated in the BC?

     

    Thanks,

    Martin

Answers

  • Wednesday, February 22, 2006 8:49 PMPaul AndrewMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi Martin,

     msheridan wrote:

    In my business layer I have a business components (BC) assembly and a business workflows (BW) assembly. I plan to have validation rules such as mandoatory field, range validation etc. in the (BC) and business rules/poilicies such as 'calculate order discount' in the BW assembly. All CRUD operations are also implemented in the BC assembly. All services in both assemblies are exposed to the presentation layer through a Services Interface.

    (To help visualise http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ArcThreeLayeredSvcsApp.asp)

    1. When I call one of the crud opeartions (in the BC assembly) such as create or update on an order line for example, I would like to apply the 'calculate order discount' rule (in the BW assembly). Is this the correct way to do this?

    The workflow engine and rules engine in Windows Workflow Foundation can be considered as technologies for use in several places in the architecture diagram that you linked to. You could consider that all business rules evaluation and business workflow execution belongs in the BW section.

     msheridan wrote:

    2. Should the crud operations also be sequential workflows in the BW assembly and not methods in the (BC)?

    It would be possible to consider all CRUD and all UI action operations as workflows, however if you did this I would not follow on to say all of that is required to be in the BW section. After all CRUD operations are not Business Workflows even if they use technologies from Windows Workflow Foundation.

     msheridan wrote:

    3. Where should validation logic be? On the form or encapsulated in the BC?

    User interface validation is always considered separate from application business logic. Typically this means that data entered by a user is validated first on the form where the user enters it and then again in the business component which needs the data as input.

     msheridan wrote:

     

    Thanks,

    Martin

All Replies

  • Wednesday, February 22, 2006 8:49 PMPaul AndrewMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi Martin,

     msheridan wrote:

    In my business layer I have a business components (BC) assembly and a business workflows (BW) assembly. I plan to have validation rules such as mandoatory field, range validation etc. in the (BC) and business rules/poilicies such as 'calculate order discount' in the BW assembly. All CRUD operations are also implemented in the BC assembly. All services in both assemblies are exposed to the presentation layer through a Services Interface.

    (To help visualise http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ArcThreeLayeredSvcsApp.asp)

    1. When I call one of the crud opeartions (in the BC assembly) such as create or update on an order line for example, I would like to apply the 'calculate order discount' rule (in the BW assembly). Is this the correct way to do this?

    The workflow engine and rules engine in Windows Workflow Foundation can be considered as technologies for use in several places in the architecture diagram that you linked to. You could consider that all business rules evaluation and business workflow execution belongs in the BW section.

     msheridan wrote:

    2. Should the crud operations also be sequential workflows in the BW assembly and not methods in the (BC)?

    It would be possible to consider all CRUD and all UI action operations as workflows, however if you did this I would not follow on to say all of that is required to be in the BW section. After all CRUD operations are not Business Workflows even if they use technologies from Windows Workflow Foundation.

     msheridan wrote:

    3. Where should validation logic be? On the form or encapsulated in the BC?

    User interface validation is always considered separate from application business logic. Typically this means that data entered by a user is validated first on the form where the user enters it and then again in the business component which needs the data as input.

     msheridan wrote:

     

    Thanks,

    Martin