Solved

Business Rules - best way to code

Posted on 2014-04-28
3
223 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 166 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 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 167 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 167 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now