Business Logic
Domain Logic
- Definition
- Business logic implements the entities and critical business rules of an organization.
Business logic is part of the Model in MVC, and Entity in ECB
How does it work?
This code expresses the entities and business rules of the organization. A business rule would be part of the organization whether it is implemented in the application or not. It would be the same in any application. The business rules can be part of the entity classes.
Business logic has no dependencies on other types of code, not even application logic.
Business logic can be modeled with a domain model
Examples of entities
- Customer (CustomerID, FirstName, LastName, Email, Address)
- Order (OrderID, CustomerID, OrderDate, TotalAmount)
- Product (ProductID, Name, Description, Price, StockQuantity)
- Employee (EmployeeID, FirstName, LastName, Position, HireDate)
- Invoice (InvoiceID, OrderID, IssueDate, DueDate, AmountDue)
- Patient (PatientID, FirstName, LastName, DateOfBirth, Gender)
- Appointment (AppointmentID, PatientID, DoctorID, AppointmentDate, Duration)
- Loan (LoanID, CustomerID, LoanAmount, InterestRate, Term)
- InventoryItem (ItemID, Name, Description, QuantityInStock, UnitPrice)
- Project (ProjectID, ProjectName, StartDate, EndDate, ProjectManager)
- Flight (FlightNumber, DepartureAirport, ArrivalAirport, DepartureTime, ArrivalTime)
- Reservation (ReservationID, CustomerID, FlightNumber, SeatNumber, ReservationDate)
Examples of business rules
- Validation Rules (Example: In an e-commerce application, a business rule might state that the quantity of items in a customer's shopping cart must be greater than zero before they can proceed to checkout.)
- Price Calculation Rules (Example: A financial application might have a business rule specifying how interest is calculated on a loan based on factors such as the principal amount, interest rate, and loan term.)
- Discount rules (Example: A retail system might have rules that determine eligibility for discounts based on criteria such as the total purchase amount, customer loyalty status, or specific promotional campaigns.)
- Credit Approval Rules (Example: In a banking application, there might be business rules that define the criteria for approving a credit application, considering factors such as credit score, income, and debt-to-income ratio.)
- Inventory Management Rules (Example: A rule in an inventory management system might dictate that a product cannot be shipped if its quantity in stock is below a certain threshold to avoid stockouts.)
- Regulatory Compliance Rules (Example: A healthcare application must adhere to regulatory rules regarding the privacy and security of patient data, ensuring compliance with laws like HIPAA.)
- Appointment Scheduling Rules (Example: A scheduling application might have rules that prevent double booking of resources or dictate the lead time required for scheduling appointments.)
- Tax Calculation Rules (Example: An accounting system may implement rules for calculating taxes based on regional tax rates, taxable income, and applicable tax exemptions.)
- Shipping Rules (Example: An e-commerce platform might have rules governing shipping options, costs, and delivery times based on factors such as the destination, shipping method, and order value.)
- Employee Leave Approval Rules (Example: In a human resources system, rules might define how employee leave requests are processed, considering factors like available leave balances, company policies, and team workload.)
- Product Return Rules (Example: An online marketplace might have rules for handling product returns, specifying conditions under which returns are accepted, return windows, and refund processes.)
- Customer Eligibility Rules (Example: A subscription-based service might have rules to determine customer eligibility for specific subscription tiers, considering factors like payment history or account status.)