Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Business Rules - best way to code

Posted on 2014-04-28
3
Medium Priority
?
237 Views
Last Modified: 2014-05-14
I have a  lot of business rules that need to be apply developing in .NET and SQL Server.  What is the best way to capture the business rules to apply to the criteria when coding?
0
Comment
Question by:leezac
3 Comments
 
LVL 25

Assisted Solution

by:Luis Pérez
Luis Pérez earned 664 total points
ID: 40029014
Well, the best way to handle this is a N-Tier architecture.

http://en.wikipedia.org/wiki/Multitier_architecture

Usually I create a Visual Studio solution with these projects:

1 Project (class library) for the objects repository (classes defining my data model).
1 Project (class library) with the Business Rules.
1 Project (class library) with the Data Layer.
1 Project (windows or web) for the graphical UI.

The repository contains classes defining the objects used in the data model. This project has no reference to other projects.

The data layer references the repository, and connects directly to the SQL Server instance to get/modify the data using the repository objects and lists of them.

The business layer references both the repository and the data layer, and make transformations to the objects.

The Graphical UI references both the repository and the business layer.

One example of all this would be: From the graphical UI, I need to get a list of customers. In the repository project I have a Customer class, than involves data from 2 distinct tables of the database. The UI makes a call to the Business layer ("get list of customers"). The Business layer makes a call to the Data Layer, which executes 2 stored procedures in the database to get the data and store this data into a list of Customer objects, returning this list to the Business Layer. If some more transformation is needed, the Business layer does it. Finally, the Business layer returns the list to the UI, which displays it.

Hope that helps.
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 668 total points
ID: 40029128
are you aware of the Validation Application block from the MS Enterprise library?

more details at http://emoreau.com/Entries/Articles/2009/06/The-Validation-Application-Block.aspx
0
 
LVL 40

Accepted Solution

by:
Vadim Rapp earned 668 total points
ID: 40033797
The best place to implement business rules is at the place all applications talk to. If you follow previous two comments from other experts, this means that all your application will need to talk to those layers; for example, if you need to fetch an employee, you will always fetch him from the layer and will never go directly to the database. Which means that all your applications will have to be compatible with your layers - a serious limitation, especially if 3rd party applications are a possibility.

Depending on the complexity of your rules, maybe you can implement them in the database as triggers and constraints.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question