Questions tagged [business-logic]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
2k views

In MVC + SOA Architecture, What is the Rationale for Placing Business Logic in Models?

When writing web applications I place business logic in controllers. This has worked well for my small App Dev team- our applications run reliably, perform well, and the code is easy to maintain. ...
3 votes
1 answer
3k views

Where should I place more complex business logic related to what a Web API does but consumed by a single client?

I have been debating with my colleagues about the following and we still did not reach consensus. The architecture is as follows: medium size monolith application for intranet usage a small ...
1 vote
3 answers
370 views

How do you record and track your business logic for software projects?

In my work, which is a UK university, we currently have no specific way of recording and tracking business logic and rules as they arise from stakeholders for our in-house software projects. We use ...
0 votes
0 answers
30 views

Balancing logic placement in the domain and general perfomance of the system

I am writing my first application using DDD (in Node with TS) and I started writing all the domain first -- before starting the repositories/DB and then the application, while writing unit tests for ...
0 votes
1 answer
58 views

Validating data and logic outside the domain

I have a budget entity in my domain which can be closed by the user if the budget is open. This means if the budget opens today and closes in seven days, in between this time I can close it, not ...
54 votes
6 answers
13k views

Business logic: Database vs code [duplicate]

I'm a student of systems engineering, and all my teachers and friends (that actually work in the area) say that it is better to have as much logic as possible implemented in the database (queries, ...
1 vote
2 answers
172 views

Placing business logic on a not so small/big project

I am having a bit of problem trying to find the correct place for business logic. The project I am working on isn't huge, but is not small either and has a very considerable importance in my company. ...
3 votes
1 answer
504 views

How would you implement a promotion/discount system?

Two recent failed projects in my career involved trying to implement a discount/promotional offer system for retail. For example, a retailer may want to offer discount codes in emails or newsletters, ...
0 votes
2 answers
131 views

Services: Which structure is a better idea?

I'm designing my service layer for a GraphQL API and there are many situations in which I can't decide if code relating to a table should belong in it's own class, or the class that 'owns' the data. ...
32 votes
2 answers
11k views

What does "business logic" actually mean if not "all non-3rd party code"?

I've heard people talk about business logic a lot at work, and online, and I've read several questions on this site about it, but the term still doesn't make a lot of sense to me. For example, here ...
1 vote
2 answers
151 views

Strategies to abstract away technical details when dealing with transactions

I like programming in such a way that every component/injectable of the applications I build, has a clearly defined scope, and it's easily tested. With years working as a Developer I've come to ensure ...
2 votes
3 answers
3k views

Where should "query" business logic be placed in Domain-driven design?

System description This is a simple eCommerce application containing a Products inventory managed by an Admin. The Products in inventory/repository will show in the User App. Admin has the ability to ...
19 votes
4 answers
29k views

What is the difference between business and application logic? [closed]

Please note that I asked the same question on stackoverflow but they directed me to ask here. While I am trying to discerne the difference between the application logic and business logic I have found ...
1 vote
5 answers
16k views

Business Logic Layer in MVC Application

In my ASP MVC application I decided to add another Business Layer and made the model only to have properties. All other functionality like save to db, get from db is done on this new Business layer. ...
1 vote
0 answers
185 views

Business rule or repository implementation rule in Clean Architecture

I'm studying Clean Architecture with python and got into this "problem" of choosing where to implement a rule (that I considered a Business Rule, maybe I'm wrong) I have 2 Entities @...
-1 votes
2 answers
138 views

How to make domain objects accessible to MVC controllers and views?

Summary of my question in a short form: How to propagate changes of domain objects upwards without introducing application logic into them? Following 'facts' are based on prescriptions from respected ...
0 votes
1 answer
75 views

Good approach to design Business interface for versioned API?

I am designing an API using .NET core 6 C# which has 2 versions. For v1 I have something like the following for the business logic interface (fictional names and simple fields just to facilitate ...
14 votes
6 answers
5k views

Separating business logic from data tempts me to use instanceof

class Foo { abstract doStuff() {} } class Bar extends Foo { doStuff() { ... } } class Baz extends Foo { doStuff() { ... } } From a functional perspective doStuff does exactly the same ...
0 votes
1 answer
2k views

Decoupled architecture between business and data layers in Spring JPA / Hibernate

I'm using Spring Boot with JPA / Hibernate and I'm trying to decouple the business layer from the data layer. I would like to be able to (relatively easily) switch from a relational database to a rdf ...
-3 votes
1 answer
596 views

How to document business processes/rules inside Python code and export them?

I'm in a project that computes a lot of metrics with Python code. We need to document how each metric is computed, inside the code, for readability, and outside, in some Wiki, for non-technical people....
1 vote
1 answer
1k views

Should transactions be placed in the business layer?

I need transactions in my service to ensure data consistency. I don't know what the best layer is for transactions to be created in. The goal is to have all business logic in a single layer. First, ...
3 votes
2 answers
208 views

Getting the UI to know about Business Rules for Form Controls

Situation: VB.NET WinForms application, using the WinForms as a presentation layer project. Another class library project containing the business layer, in the form of CQS and Service classes, plus a ...
148 votes
10 answers
76k views

How much business logic should the database implement?

I've worked in some projects where most of the business logic was implemented on the database (mostly through stored procedures). On the other side, I've heard from some fellow programmers that this ...
0 votes
1 answer
142 views

Storing Sort Order in Database: match the business logic or the application logic? [closed]

Take a profile page for a job applicant with a list of names in a form with typical CRUD: Resume Name: Altenrate Name 1: Alternate Name 2: Alternate Name 3: Assuming we have some sort of Names table ...
1 vote
3 answers
948 views

Keeping business logic separate from data access

Let's say I have few entity classes: class EntityA { LocalDate date1; LocalDate date2; } class EntityB { } class EntityC { LocalDate date1; } and I want to pass them through some logic containing ...
3 votes
1 answer
175 views

How to make a business case for incremental product development

I don't work for an development company, but we have been working in partnership with one to develop an application for use internally within our business. The application is somewhat "niche&...
2 votes
3 answers
495 views

domain model logic behavior (ddd)

How domain model capture business logic / domain logic since i cannot access repository? I see many posts saying that domain model = business objects But Business objects live in application layer (...
0 votes
2 answers
304 views

Does it make sense to inform SPA frontend about business rules from the backend?

Let's say you have a user registration form in your frontend. In both, backend and frontend, password is valited so it has to match a set of requirements: more than 6 characters, no symbols, etc... ...
6 votes
3 answers
771 views

Is it good practice to put service business logic based on audit trail?

Our application creates audit trails in response to system actions and user actions. Our business logic depends on these audit trails to find out which user performed what action. Is it good practice ...
0 votes
2 answers
2k views

Patterns for returning messages/results from business logic to UI

Cross-posting from SO. Is there a name for the patterns used send messages/errors and results through an application's layers from business logic/database to the UI? What is the modern way? For ...
1 vote
3 answers
382 views

Is creating an entity in a database considered to be business logic?

According to my (perhaps incorrect) understanding business logic includes saving/updating entities in the database, as well as connecting with any 3rd party API's or using services and should ...
2 votes
2 answers
131 views

How thoroughly should you document business flows for a product or system you are learning?

I work on applications that have user documentation but it is not organized or updated to the current release. Is it worth my time to create my own documentation with screenshots and notes on all the ...
11 votes
6 answers
13k views

Separation of retrieving data and business objects between DAL and BLL Layers

I did some research before posting this question. Among other questions or post, one of those is provided below. I could not get a clear mind how to determine.. Business Objects within a Data Access ...
1 vote
2 answers
142 views

Implement business logic as dictionaries of delegates

In my application I'm dealing with periods. A period is defined by it's end date. A period may shrink or grow, can restart and can have a priority. This is modeled using the following struct: public ...
2 votes
1 answer
801 views

Upholding business logic and invariants in an event sourced CQRS architecture

My understanding of a CQRS architecture is that a micro-service is split to two servers each with its own database such that the first server handles all the writes and the second server handles all ...
2 votes
1 answer
243 views

How to model Business Objects depending on use cases?

I'm having trouble modeling the Business Objects of my application. In my domain I have substantially a list of bills of orders, and for every bill I have the pallet that contains the materials to ...
6 votes
1 answer
431 views

Should data model logic live in database schema?

(Apologies if some of my terminology is off, I have not seen much on this subject and am using be best terms I could come up with) Should data model logic live in the database schema? I am making a ...
1 vote
1 answer
842 views

Where to place the business logic for an external application that is tightly coupled with an internal application and how to adapt the architecture?

I and a colleague had a rather strange discussion with our boss related to the architecture of the applications we are currently developing. The C4 (second level) diagram of the existing architecture ...
5 votes
1 answer
3k views

DDD and MediatR - where the Validation and Business Logic go

I'm trying to get to grips with Domain Driven Design and MediatR. A reaction to being involved with applications that favour Services for almost everything. I see so much value in DDD and I'm trying ...
0 votes
0 answers
288 views

How to handle various types of custom logic in multi-tenancy architecture

In a microservice based multi-tenant web application, there are some cases of tenant specific logic where I am unclear about the proper strategy to handle them. Thank you for pointers. These two ...
5 votes
2 answers
634 views

How to clean up a business logic class that does too many things without injecting a ton of classes into it?

Let's say we have business logic to perform in an MVC framework after a user submits a form: class BusinessLogic: def sendDataTo3rdPartyApi(self): # do stuff def validateResponse(self)...
45 votes
6 answers
16k views

Do stored procedures violate three-tier separation?

Some colleagues of mine have told me that having business logic in stored procedures in the database violates the three-tier separation architecture, since the database belongs to the data layer ...
3 votes
2 answers
560 views

DDD, Aggregate Root and entities in library application scenario

I'm building a library application. Let's assume that we have a requirement to let registered people in the library to borrow a book for some default period of time (4 weeks). I started to model my ...
25 votes
4 answers
25k views

What exactly is a business rule? [duplicate]

I'm trying to better organize my application architecture, so I've been doing some reading, but I keep running into references to "Business Logic" and "Business Rules". I've never really understood ...
5 votes
1 answer
820 views

Is My Data Access Layer Really My Domain?

I'm not an architect, but am trying to put together a diagram which represents the architecture of the application which I am maintaining. I have one question (but welcome any comments about the ...
3 votes
1 answer
342 views

What domain objects might I need to represent a user and users profile in a forum web application

I’ve been trying to get a firm understanding of the MVC design pattern so that I can write my own framework for implementing the back-end of a forum web application using Slim 3. In particular, after ...
10 votes
5 answers
1k views

Presentation Layer Accessing Business Logic

I've been reading a lot of material lately about DDD (business entity objects) and other common patterns in n-tiered(layered) architecture. One thing I have issue with is, most articles, blogs, ...
79 votes
5 answers
110k views

Why put the business logic in the model? What happens when I have multiple types of storage?

I always thought that the business logic has to be in the controller and that the controller, since it is the 'middle' part, stays static and that the model/view have to be capsuled via interfaces. ...
3 votes
3 answers
1k views

Aggregation of data from two Microservices

I have two Microservices A and B. B Microservice has a large set of an entity called User. A Microservice stores the User entity in its own DB if User is configured by an agent. There is no flag ...
-1 votes
1 answer
157 views

How to generalize this method for its duplicate/common logic?

I've a method that apparently has quite some duplicate logic, I'd like to generalize it so that their duplicate logic could be shared and reused, also make my code more extensible for future additions....