Solved

Business Rules - best way to code

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

830 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