One Language to rule them all (About business rules)
-
Here's a question I ask myself for a while every time I start a new web project. I explain Architecturally all software on which I worked are more or less designed the same way. roughly: • A database (transactional) • A data layer (generated from database) • A business layer (Web Services) • A GUI layer (Web application) • And business rules (without rules) My question is about the business rules. By business rules I mean all rules that design the software given by your business, workflow or technical limitation. (I'm not talking of rules you put in your business only). In the application on which I worked I found implemented: • in the transactional database in the form of constraint or trigger, • in the layer data often generated from the database, • in the business layer when it comes to more complex business rules, • In the GUI layer to alert the user as soon as possible and before triggering a request unnecessarily. I understand the usefulness of business rules in each of these layers of a program. But the technologies that I have used forced us to rewrite or generate business rules in each of these layers because the languages are different: • In database trigger and constraint are in SQL • In data layer business rules are in C# • In business layer business rules are in C# • In GUI layer business rules are in JavaScript My question: Is there a language that can accommodate all business rules in a single place or language? Something that prevents me to rewrite several times in different languages my business rules? I know I cannot check all business rules in one place but some yes. for instance the minimum and maximum character of a password can be check in all layer. Right now I write this rule in 3 different languages in 3 different places (Gui/Javascript, Layers/C# and database constraint). Sub-question: In case of Web Application what if I use JavaScript with nodejs and Mango database?
B413
-
Here's a question I ask myself for a while every time I start a new web project. I explain Architecturally all software on which I worked are more or less designed the same way. roughly: • A database (transactional) • A data layer (generated from database) • A business layer (Web Services) • A GUI layer (Web application) • And business rules (without rules) My question is about the business rules. By business rules I mean all rules that design the software given by your business, workflow or technical limitation. (I'm not talking of rules you put in your business only). In the application on which I worked I found implemented: • in the transactional database in the form of constraint or trigger, • in the layer data often generated from the database, • in the business layer when it comes to more complex business rules, • In the GUI layer to alert the user as soon as possible and before triggering a request unnecessarily. I understand the usefulness of business rules in each of these layers of a program. But the technologies that I have used forced us to rewrite or generate business rules in each of these layers because the languages are different: • In database trigger and constraint are in SQL • In data layer business rules are in C# • In business layer business rules are in C# • In GUI layer business rules are in JavaScript My question: Is there a language that can accommodate all business rules in a single place or language? Something that prevents me to rewrite several times in different languages my business rules? I know I cannot check all business rules in one place but some yes. for instance the minimum and maximum character of a password can be check in all layer. Right now I write this rule in 3 different languages in 3 different places (Gui/Javascript, Layers/C# and database constraint). Sub-question: In case of Web Application what if I use JavaScript with nodejs and Mango database?
B413
B413 wrote:
Is there a language that can accommodate all business rules in a single place or language?
No. Even if there were a language that does all[^], there'll still be a difference between validation on the clients' side, and validation on the database-layer.
B413 wrote:
My question is about the business rules. By business rules I mean all rules that design the software given by your business, workflow or technical limitation. (I'm not talking of rules you put in your business only).
Your question seems to apply to the database-validation, and all derived checks. BR should be constrained to it's layer.
B413 wrote:
Right now I write this rule in 3 different languages in 3 different places (Gui/Javascript, Layers/C# and database constraint).
The stringlength-constraint is an easy one; the datalayer in C# could be generated based on the database-schema, and the GUI could use the StringLengthAttribute[^] information to do it's check - that'd mean that there'd be three languages performing the same check in three different places, but with the declaration only in a single place (in this example, the database). There's an abundance of variations on the above.
B413 wrote:
• A database (transactional) • A data layer (generated from database) • A business layer (Web Services) • A GUI layer (Web application) • And business rules(without rules)
That doesn't mean that they're all built that way. A few years ago we considered the database the DAL. It abstracted away a file-system, made data-validation easy, and gave us a uniform way of accessing the data we store. I've also seen quite some code where the BL is a DLL containing classes derived from POCO-classes based on the DB-schema. If you want a "single language", you'd be looking at the languages that the most restricted environments (in
-
Here's a question I ask myself for a while every time I start a new web project. I explain Architecturally all software on which I worked are more or less designed the same way. roughly: • A database (transactional) • A data layer (generated from database) • A business layer (Web Services) • A GUI layer (Web application) • And business rules (without rules) My question is about the business rules. By business rules I mean all rules that design the software given by your business, workflow or technical limitation. (I'm not talking of rules you put in your business only). In the application on which I worked I found implemented: • in the transactional database in the form of constraint or trigger, • in the layer data often generated from the database, • in the business layer when it comes to more complex business rules, • In the GUI layer to alert the user as soon as possible and before triggering a request unnecessarily. I understand the usefulness of business rules in each of these layers of a program. But the technologies that I have used forced us to rewrite or generate business rules in each of these layers because the languages are different: • In database trigger and constraint are in SQL • In data layer business rules are in C# • In business layer business rules are in C# • In GUI layer business rules are in JavaScript My question: Is there a language that can accommodate all business rules in a single place or language? Something that prevents me to rewrite several times in different languages my business rules? I know I cannot check all business rules in one place but some yes. for instance the minimum and maximum character of a password can be check in all layer. Right now I write this rule in 3 different languages in 3 different places (Gui/Javascript, Layers/C# and database constraint). Sub-question: In case of Web Application what if I use JavaScript with nodejs and Mango database?
B413
B413 wrote:
I understand the usefulness of business rules in each of these layers of a program. But the technologies that I have used forced us to rewrite or generate business rules in each of these layers because the languages are different:
If you have the same set of business rules in all the layers then something is suspect. But other than that you already mentioned code generation so why not just do that for the common functionality.
B413 wrote:
Is there a language that can accommodate all business rules in a single place or language
Attempting to generate all rules ends up being a mess because the exceptions add so much complexity that maintaining the generation itself becomes very difficult. Generating the easy stuff is easy and removes much of the rote work. If you fail to properly design the different layers to support insertion of generated rules then that will also become a mess.
-
B413 wrote:
Is there a language that can accommodate all business rules in a single place or language?
No. Even if there were a language that does all[^], there'll still be a difference between validation on the clients' side, and validation on the database-layer.
B413 wrote:
My question is about the business rules. By business rules I mean all rules that design the software given by your business, workflow or technical limitation. (I'm not talking of rules you put in your business only).
Your question seems to apply to the database-validation, and all derived checks. BR should be constrained to it's layer.
B413 wrote:
Right now I write this rule in 3 different languages in 3 different places (Gui/Javascript, Layers/C# and database constraint).
The stringlength-constraint is an easy one; the datalayer in C# could be generated based on the database-schema, and the GUI could use the StringLengthAttribute[^] information to do it's check - that'd mean that there'd be three languages performing the same check in three different places, but with the declaration only in a single place (in this example, the database). There's an abundance of variations on the above.
B413 wrote:
• A database (transactional) • A data layer (generated from database) • A business layer (Web Services) • A GUI layer (Web application) • And business rules(without rules)
That doesn't mean that they're all built that way. A few years ago we considered the database the DAL. It abstracted away a file-system, made data-validation easy, and gave us a uniform way of accessing the data we store. I've also seen quite some code where the BL is a DLL containing classes derived from POCO-classes based on the DB-schema. If you want a "single language", you'd be looking at the languages that the most restricted environments (in
Eddy Vluggen wrote:
that'd mean that there'd be three languages performing the same check in three different places, but with the declaration only in a single place (in this example, the database).
The declaration only in a single place because you assume that the code is generated from the database. You generate entities with attributes. But what if 1. You are not working with a SQL server 2. You have business rules you cannot implement in your database 3. You are not working with ASP.NET MVC or WPF My point of view is that all business rules must be with my model, my entities. partial classes, inheritance, separate check classes, I don't know. What happens in my database is not my problem. As C# developer I don't want to know if my DBA has created constraint or not. I call my check from my GUI. I don't want to write them or generate (writing or generating is the same) them twice. I can do that when I write my GUI with C# classic form. I cannot do that with HTML or ASP.NET MVC.
-
B413 wrote:
Is there a language that can accommodate all business rules in a single place or language?
No. Even if there were a language that does all[^], there'll still be a difference between validation on the clients' side, and validation on the database-layer.
B413 wrote:
My question is about the business rules. By business rules I mean all rules that design the software given by your business, workflow or technical limitation. (I'm not talking of rules you put in your business only).
Your question seems to apply to the database-validation, and all derived checks. BR should be constrained to it's layer.
B413 wrote:
Right now I write this rule in 3 different languages in 3 different places (Gui/Javascript, Layers/C# and database constraint).
The stringlength-constraint is an easy one; the datalayer in C# could be generated based on the database-schema, and the GUI could use the StringLengthAttribute[^] information to do it's check - that'd mean that there'd be three languages performing the same check in three different places, but with the declaration only in a single place (in this example, the database). There's an abundance of variations on the above.
B413 wrote:
• A database (transactional) • A data layer (generated from database) • A business layer (Web Services) • A GUI layer (Web application) • And business rules(without rules)
That doesn't mean that they're all built that way. A few years ago we considered the database the DAL. It abstracted away a file-system, made data-validation easy, and gave us a uniform way of accessing the data we store. I've also seen quite some code where the BL is a DLL containing classes derived from POCO-classes based on the DB-schema. If you want a "single language", you'd be looking at the languages that the most restricted environments (in
I agree with you except that 1. Generating tools to generate from database to business is bad. You give to much power to your database and you repeat the mistakes. I know many developers do that so I expect to argue on this point. 2. As developer a database is just a way to persist my data. It's not my job to create constraint or triggers. (for performance reason I'll perhaps create indexes but that all) 3. It seems increasingly clear that all my BR are a part of the business layer or the entities. If my GUI use the same language than my business layer I can reuse my BR and entities for validation in my GUI. I still don't understand developers that use HTML/JavaScript as GUI with C# as business layer (web service) because cannot reuse their C# code in their HTML/JavaScript GUI. They don't respect the Don't Repeat Yourself rule.
-
Here's a question I ask myself for a while every time I start a new web project. I explain Architecturally all software on which I worked are more or less designed the same way. roughly: • A database (transactional) • A data layer (generated from database) • A business layer (Web Services) • A GUI layer (Web application) • And business rules (without rules) My question is about the business rules. By business rules I mean all rules that design the software given by your business, workflow or technical limitation. (I'm not talking of rules you put in your business only). In the application on which I worked I found implemented: • in the transactional database in the form of constraint or trigger, • in the layer data often generated from the database, • in the business layer when it comes to more complex business rules, • In the GUI layer to alert the user as soon as possible and before triggering a request unnecessarily. I understand the usefulness of business rules in each of these layers of a program. But the technologies that I have used forced us to rewrite or generate business rules in each of these layers because the languages are different: • In database trigger and constraint are in SQL • In data layer business rules are in C# • In business layer business rules are in C# • In GUI layer business rules are in JavaScript My question: Is there a language that can accommodate all business rules in a single place or language? Something that prevents me to rewrite several times in different languages my business rules? I know I cannot check all business rules in one place but some yes. for instance the minimum and maximum character of a password can be check in all layer. Right now I write this rule in 3 different languages in 3 different places (Gui/Javascript, Layers/C# and database constraint). Sub-question: In case of Web Application what if I use JavaScript with nodejs and Mango database?
B413
I can now confirm it's possible to choose C# to build a Winform application and reuse entities and business rules code from business layer to data and UI layers. I can also confirm this is possible with the solution (mongoDB, Node, JavaScript)