business-logic

Business rules - where do they go in OOP?

假如想象 提交于 2019-12-05 18:44:51
I have a class : Schedule. public class Schedule { private int locationNum; private int cost; private String costReason; private Date weekOfChange; private Date dayOfChange; private String changeReason; // and all those getters and setters public Schedule(int locationNum, int cost, String costReason, Date weekOfChange, Date dayOfChange, String changeReason) throws ApplicationException { //change is all or nothing - all attributes are present or none if((weekOfChange!=null && dayOfChange!=null && changeReason!=null) || (weekOfChange==null && dayOfChange == null && changeReason == null)) { this

What's the best way to localize non Data Annotation Errors with ASP.NET MVC 3?

最后都变了- 提交于 2019-12-05 10:03:32
With Data Annotations it's now easy to localize error messages using Resource.resx files like this for example: public class Student { . . . [Required(ErrorMessageResourceName ="Required", ErrorMessageResourceType = typeof(StudentResources))] [StringLength(16)] [Display(Name = "FirstName", ResourceType = typeof(StudentResources))] public string FirstName { get; set; } . . . } Now, let's say I want to check if a Student has already made a Payment for a given month and year: public bool CheckIfAlreadyPaid(Payment payment) { return repository.GetPayments().Any(p => p.StudentId == payment

Is it a bad idea to use a database's primary key as business object identifier?

家住魔仙堡 提交于 2019-12-05 08:56:48
I wonder, is it bad or good idea to use auto increment primary key as business entity identifier such as Partner Id or Account Number ? Also, what pitfalls I can face if I'll choose that approach? I don't think everyone shares the same opinion, but I do think it is bad practice. Passing ID's to the user as the 'key' is bad in my opinion, for a number of reasons: ID's aren't natural to users. They are not talking about project '1474623', they are talking about project 'ABC'. They aren't talking about person '363528', they are talking about 'Patrick Hofman'; ID's are fragile. You can't really

Symfony2: best approach to use business (repository) logic in entity or controller

时光毁灭记忆、已成空白 提交于 2019-12-05 01:26:20
问题 I'm having a design issue in my project, related to where put some business logic. I have three entities, Event, TicketOrder and Ticket. One Event has a lot of TicketOrders and one TicketOrder has a lot of Tickets. In my template, I have to show how many tickets an Event has. I've thinking of the best approach to achieve this and didn't get a good solution. I've tried this: 1) Create a private member 'ticketsCount' in Event entity, with setTicketsCount and getTicketsCount method. Create a

C# - Usage of transactions in business layer (SQLServer 2005+ , Oracle) - good examples

喜欢而已 提交于 2019-12-04 23:36:14
问题 I am gonna build a service using 3-tier architecture and I am really worried about how to handle operations in a transacted way. I know I have 2 options: IDbTransaction and TransactionScope ... but I am not really decided for which one to go, although I did a lot of research. I would go for TransactionScope but I don't want to involve DTC... plus I need support for SQLServer2005 and Oracle. (I am aware that I need to have only one connection opened at a time) I would like to see good examples

CQRS: business logic on the query side

和自甴很熟 提交于 2019-12-04 19:47:53
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 stored in DB also. const Single Tax = 15; //View Model for the Employee Screen class EmployeeViewModel {

Best designs for breaking down business logic and data layer when they seem to overlap? [closed]

喜你入骨 提交于 2019-12-04 13:55:04
问题 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 last year . I'm building a MVC web application (using the Spring MVC framework), and I'm a little stumped on the best way to design a particular area. The application has to interact with a series of web services which are not really all that greatly designed, and don't offer much

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

寵の児 提交于 2019-12-04 12:46:24
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 appreciated. This can be solved with a CTE: WITH business_days_back AS ( WITH RECURSIVE bd(back_day, go_back)

Why is it called 'business logic'? Where did this term come from?

不问归期 提交于 2019-12-04 07:57:37
问题 I'm going through all sorts of WPF documentation, and I'm feeling unnecessarily confused. The term 'business logic' is scattered throughout it, as if everyone should know what it is. I can see what business logic is, according to this question here: What exactly consists of 'Business Logic' in an application? But where did the term come from? Why is it called 'business logic' and not, say, 'core logic' or 'main algorithms' or any other more generic terms? Very few of the programs I write have

What is domain logic?

社会主义新天地 提交于 2019-12-04 07:39:27
问题 What is domain logic? The Wikipedia page for domain logic redirects to business logic. Are they the same thing, and, if not, how do they differ? 回答1: The domain is what you are modelling. If you are modelling a business problem, they are the same thing. If you are modelling something else, physics for instance, there is probably no business logic in your system, but the physics parts are still domain logic. 回答2: Domain is the world your application lives in. So if you are working on say a