Solved

Business Rules - best way to code

Posted on 2014-04-28
3
224 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

867 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

18 Experts available now in Live!

Get 1:1 Help Now