business-logic

Enforcing an “end” call whenever there is a corresponding “start” call

爱⌒轻易说出口 提交于 2019-12-28 18:04:11
问题 Let's say I want to enforce a rule: Everytime you call "StartJumping()" in your function, you must call "EndJumping()" before you return. When a developer is writing their code, they may simply forget to call EndSomething - so I want to make it easy to remember. I can think of only one way to do this: and it abuses the "using" keyword: class Jumper : IDisposable { public Jumper() { Jumper.StartJumping(); } public void Dispose() { Jumper.EndJumping(); } public static void StartJumping() {...}

How shoud be a parameters table designed and used on businesses and GUI layers? [closed]

眉间皱痕 提交于 2019-12-24 18:24:25
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . I'm currently designing an application and I need to know how should be designed a constants parameter table. Also, I want to know how to use this table on the application. For example: for a parameter sex (M or F) in a system, it should be in its own table or is better to

How can I improve this design that calls third party methods from JSF based front end

故事扮演 提交于 2019-12-24 10:02:45
问题 I want opinions and expert advice on design . I am developing an application using JSF2 and EJB3 and I am not using CDI. I have been given an API (jar) from an other team and there are three main methods in it. One searches the database and returns a list of cars and one returns a list of pushbikes and one returns list of boats. So basically we have three different lists of different vehicles. At the ui side user has a search form with three radio buttons one for each type of vehicle that

Where to put restrictions on entities when separating Business layer from Data Layer

不问归期 提交于 2019-12-23 12:35:31
问题 I am attempting to create the the business and data layers for my big ASP.NET MVC application. As this is the first time for me attempting a project of this scale I am reading some books and trying to take good care at separating things out properly. Usually my applications mix the business logic and data access layers, and multiple business entities are intertwined in the single class (which has confused me a few times when I was trying to figure out where to add things). Most of what I have

BL Services: Exception or Method Result?

北城以北 提交于 2019-12-22 09:47:53
问题 What is the best way and why? V1: try { var service = IoC.Resolve<IMyBLService>(); service.Do(); } catch(BLException ex) { //Handle Exception } V2: var service = IoC.Resolve<IMyBLService>(); var result = service.Do(); if (!result.Success) { //Handle exception } 回答1: Exceptions are better in my opinion. I think that DDD code is first and foremost good object oriented code. And the debate about using exceptions vs return codes in OO languages is mostly over. In DDD context I see following

Django Rest Framework Business Logic

半城伤御伤魂 提交于 2019-12-22 01:34:27
问题 I am trying to create a backend with Django Rest Framework and am trying to determine where to place the business logic. Would it go in the views.py? I would like to create more complex services than just getting a list of objects or grabbing one specific object. Any guidance would be appreciated, thanks. I realize there is a discussion about the business logic in a generic Django project but I am asking specifically about the django rest framework. 回答1: It is more about design patterns

CQRS: business logic on the query side

馋奶兔 提交于 2019-12-21 23:18:18
问题 Following the concept of CQRS (Command Query Responsibility Segregation), I am directly referring the DAL in my MVC application and doing all reads via the ViewModels. However a colleague of mine is asking me what will you do when any business logic has to be applied when doing a read. For e.g. if you need to compute a percentage value in scenario like below: //Employee domain object class Employee { string EmpName; Single Wages; } //Constant declared in some utility class. This could be

How do you get a dynamic 12 business day view in Postgresql?

岁酱吖の 提交于 2019-12-21 20:46:44
问题 Here is the code I currently have that gives me the last 12 days SELECT * FROM table WHERE analysis_date >= current_date - interval '12' day; analysis_date is the date column in the table. I understand why this isn't working because it's not accounting for business days. How can I rewrite this so that I get an interval of the last 12 business days? I tried search online and found extract(dow from (date)) But I couldn't find an example where I need a weekday interval. Any help would be

How to simplify complicated business “IF” logic?

自闭症网瘾萝莉.ら 提交于 2019-12-20 09:03:45
问题 What are the good ways to handle complicated business logic that from the first glance requires many nested if statements? Example: Discount Coupon. could be: 1a) Value discount 1b) Percentage discount 2a) Normal discount 2b) Progressive discount 3a) Requires access coupon 3b) Do not require access coupon 4a) Applied only to the customer who already bought before 4b) Applied to any customer 5a) Applied to customer only from countries (X,Y,…) That requires code even more complicated then this:

Storing Business Logic in Database

可紊 提交于 2019-12-20 08:10:08
问题 We want to write some business logic rules that work on top of certain data to build reports. Not sure which is the best to store them in the database MySQL. It can have a chain of the rules and then a statement for the result as shown above. 回答1: For building reports you can convert business logic in any programming language. And use database data for generating reports. Against of business logic stored in database I place a high value on the power of expression, and I don't find the SQL