简体   繁体   English

应用逻辑与业务逻辑

[英]application logic vs business logic

While I am trying to discerned the difference between the application logic and business logic I have found set of articles but unfortunately there is a contradiction between them.虽然我试图辨别应用程序逻辑和业务逻辑之间的区别,但我发现了一组文章,但不幸的是它们之间存在矛盾。

Here they say that they are the same but the answer here is totally different.他们在这里说它们是相同的,但这里的答案完全不同。

For me I understand it in the following way:对我来说,我是这样理解的:

If we look up for the definition of the Logic word in Google we will get如果我们在 Google 中查找Logic词的定义,我们会得到

system or set of principles underlying the arrangements of elements in a computer or electronic device so as to perform a specified task.计算机或电子设备中元件排列的基础系统或一组原理,以执行特定任务。

So if the logic is set of principles underlying the arrangements of elements then the business logic should be set of principles underlying the arrangements of the business rules , in other words it means the rules the should be followed to get a system reflects your business needs.因此,如果逻辑是set of principles underlying the arrangements of elements那么业务逻辑应该是set of principles underlying the arrangements of the business rules换句话说,这意味着应该遵循的规则才能使系统反映您的业务需求。

And for me the application logic is the principles that the application based on , in other words, how to apply these rules to get a system reflects your business needs, for example should I use MVC or should not I use?, should I use SQL or MSSQL?, should I handle errors using exception handling or if statment?.而对我来说,应用逻辑就是the principles that the application based on换句话说,如何应用这些规则来得到一个系统反映了你的业务需求,例如我应该使用MVC还是不应该使用?,我应该使用SQL或 MSSQL?,我应该使用异常处理还是 if 语句来处理错误?。

So please could anybody help me to get rid of confusion.所以请任何人都可以帮助我摆脱混乱。

Well there's going to be a few interpretations of this one, but here's mine.好吧,对此会有一些解释,但这是我的。

Business logic is the rules that are in place whether your business is computerized or not.业务逻辑是适用于您的业务是否计算机化的规则。

Application logic is how a particular slice of that business is realised.应用程序逻辑是如何实现该业务的特定部分。

Take for example an insurance business offering multiple and complex policies.以提供多种复杂政策的保险业务为例。 All the conditions, calculations, payment schemes, conditions of offer etc. are 'business rules'.所有条件、计算、支付方案、报价条件等都是“商业规则”。 A website that says "enter dob and income to get an instant estimate on our most popular products" would contain application logic as would a back office report for "top 500 earners that didn't buy".一个网站说“输入 dob 和收入以获得我们最受欢迎的产品的即时估计”将包含应用程序逻辑以及“没有购买的前 500 名收入者”的后台报告。 Each is an example of a specific use.每个都是特定用途的示例。 Business rules apply but they are constrained and supplemented by other rules (like just these policies).业务规则适用,但它们受到其他规则(例如这些策略)的约束和补充。

So typically business rules are rules, application rules are a subset selected and packaged for a purpose.因此,通常业务规则是规则,应用程序规则是为特定目的选择和打包的子集。

Application Logic tells how an application is designed and developed.应用程序逻辑说明应用程序是如何设计和开发的。 How you have maintained the standards through out the application.您如何在整个应用程序中保持标准。 Usability, UI, Functionality etc are maintained throughout the application.在整个应用程序中维护可用性、UI、功能等。

Business Logic is how a business is designed and implemented.业务逻辑是设计和实施业务的方式。 What are the Business rules, Business Workflows.什么是业务规则,业务工作流。

Now a days, sometimes Business logic is adjusted as per application logic.现在,有时业务逻辑会根据应用程序逻辑进行调整。 And sometimes application logic is injected in Business logic to streamline each other.并且有时将应用逻辑注入到业务逻辑中以相互简化。

SalesForce is an example.销售队伍就是一个例子。

"Application logic" (sometimes referred to as "work logic" in older literature), is the abstract of your source. “应用程序逻辑”(在较早的文献中有时称为“工作逻辑”)是源的摘要。 It's closely tied to the implementation, and not necessarily to the real world problem it solves.它与实现密切相关,不一定与它解决的现实世界问题相关。

Example 1示例 1

You have a deck of cards.你有一副纸牌。 Your business logic may contain a step like "sort the cards", focusing on the desired outcome, as in, "whatever you do at this point, the cards need to end up sorted".您的业务逻辑可能包含“对卡片进行排序”之类的步骤,重点关注所需的结果,例如“此时无论您做什么,卡片最终都需要进行排序”。 This makes sense from a business point of view.从商业的角度来看,这是有道理的。

Your application logic , on the other hand, will contain something like "use a distribution sort here", which is completely off topic for the business side (it only cares about the output), OR, your code may even do no sorting at all, for example because you store your cards with a bitfield where it's "already sorted".另一方面,您的应用程序逻辑将包含诸如“在此处使用分布排序”之类的内容,这与业务方面完全无关(它只关心输出),或者,您的代码甚至可能根本不进行排序,例如,因为您将卡片存储在“已排序”的位域中。 So the point is, a step on the business side don't necessarily correspond to a step in the app logic.所以关键是,业务方面的步骤不一定对应于应用程序逻辑中的步骤。

Example 2示例 2

You have an elevator.你有电梯。 Business rules are like "if we're going downwards and someone below us presses the down button, we stop there".业务规则就像“如果我们向下走,而我们下面的人按下向下按钮,我们就停在那里”。 This is an algorithmic step, but from a human perspective.这是一个算法步骤,但从人类的角度来看。 Your application gets this need as a requirement, and... well, in the case of an elevator, you'll need to know the speed, maximum deceleration, distance from caller floor, priorities, other elevator cars' position and a bunch of other factors, and you get a pretty complex app logic just to deliver that simple requirement .您的应用程序将这种需求作为一项要求,而且……嗯,就电梯而言,您需要知道速度、最大减速度、与呼叫者楼层的距离、优先级、其他电梯轿厢的位置以及一堆其他因素,你会得到一个非常复杂的应用程序逻辑来满足这个简单的需求 And still, both are algorithms.而且,两者都是算法。 One for the purpose of elevators, and another for the horrible mess beneath.一个用于电梯,另一个用于下面可怕的混乱。 (I'm absolutely amazed by elevators and their software, btw.) (顺便说一句,我对电梯及其软件感到非常惊讶。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM