Solved

Business Rules - best way to code

Posted on 2014-04-28
3
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 70

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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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 shrink a transaction log file down to a reasonable size.

734 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