My perception is that separating the concepts of business rule and application becomes simpler as more agents are added to the scenario. During the software requirements survey stage, it is natural for the analyst to opt for the use of an API/Backend to, in addition to persisting information, coordinate the data flow. Access control, for example, is a business rule defined once and imposed on all customers. If you are modeling a monolithic service that does not provide reusability of rules between modules or applications, the boundaries between application and business characteristics tend to be less defined.
some say they cannot have things of persistence in this object because it is an application mechanism and is not part of the business model.
Naturally, the business rules are inherent to the domain in which it is working and are related to the processes of the business model - a "customer registration" operation is to business rule as "browse to customer registration" is to an application operation.
My understanding of the concept of business rules takes such rules away from the technological means to implement them. This answer for a question similar to yours, but in English, speaks something with which I agree a lot: "Business Logic is Logic, that is created with Collaboration and Agreement with business experts". Well, the expert in question does not care about (and probably does not even know) specific implementation problems related to the application.
Another aspect is that the business rule is relevant and common to all applications that use it, so it could be shared between them - like if you develop two complementary applications (say a mobile app and a website) that depend on the same business rules. Sharing enforcement rules may not make as much sense in this case.
Why should the maximum number of characters be the rule? Why is it not a business rule? Or?
Imagine a system integration scenario, you’re building a client application of a government service, say the IRS. Your application needs to query a person’s data from a document number, either CPF. The rule of business says that the CPF has 11 numeric digits, and that is immutable. In the application rule, focusing on an interface context, a CPF can have 14 digits if we include the score/input mask.
To answer the question, it could be both. My criterion for separating the business rule from the application rule would be: would this character limit still exist if the rule were implemented in another scenario, such as on paper instead of computers? If yes, then I see it as a business rule.
Expanding my own question above: if the scenario were just another platform (replacing my Mysql database with Postgres, for example), would the character limitation change? If not, point to business rule. If so, I should probably have better modeled my implementation so that the functionality of the application did not depend so much on technical aspects.
Updating:
My main doubt is what is the limit of things and why it is preached to separate and all the time the codes join these things [...]
To be honest, I think this is another case of "do what I say but don’t do what I do" in the world of software development. We know the standards, the best practices, but we do not always apply them, either because of lack of time ("you have 2 months to develop this system, but it’s been 6 weeks"); or because of the amount of Boilerplate or complexity that these indicated implementations can cause.
What do you mean complexity? Boilerplate?
I refer to small applications, although the understanding of this term varies widely from dev to dev. Well, when adding a method to, citing your comment, "take an object hash" (and even do a validation on top of that) I wonder: this will be used somewhere else? Some possible answers in my projects:
- Not, is relevant only to this functionality and there is no provision to reuse any portion of it. So I implement right there.
- No, but this section/method does not belong to the scope I am working on (here comes the separation we are talking about). But it is overworking to create a layer/class/interface for a 5-line method... I will keep it here, or, with the simplest possible implementation, put it in another file/package.
- In the future, maybe. I am looking for an alternative that does not significantly increase the complexity of the project and implement the code in a way that can be reused.
- Yes/Yes, why. From that moment on, the only way to avoid copy-and-ola is by writing reusable code. There is now an implicit need to follow good practice, separating responsibilities more clearly.
The complexity I refer to is subjective and quite opinionated. Creating an application "layer" for some simple programming just to "follow the pattern" is indicated, but the programmer might wonder "I really need to create an interface here and I’ll probably only have one concrete class"? This is a recurring question when I’m, for example, limited to Java 7 while creating my Android app. How many lines of Boilerplate would be saved if you could use Lambdas instead of an anonymous class?! Maybe it’s a particular exaggeration of mine, but sometimes my search for "simplify architecture" ends up taking some shortcuts and discarding good practices that would be more verbose.
DRT;
My empirical understanding of why application and business rules end up mixed is that programmers have limitations (time, resources, knowledge) that require such measures, and software is often seen as something that will always require maintenance (therefore it could be improved in the future).
This is already in the link I posted, I asked something else. Do not limit to read the title of the question. But I’m going to use your example to help understand the question. I edited it, see.
– Maniero