Tag Info

Hot answers tagged

13

If you mean representing individual business rule checks with exceptions, then I don't think it's a very good idea. Many times you have to report more than one failed condition, and not stop on the first one. On the other hand, I do believe that checking for all rules and then throwing an exception with the summary is a good practice.


8

In the example you've given us I think that raising an exception is a bad idea. If you know that the user is not authorized before they start working and you still allow them to do some function and then smack them with an message AFTER they've already completed the task, that's just a bad design. Using exceptions to enforce business rules is not a good ...


7

I would use WF or Drools if you're trying to create an abstraction that non-programmers could work with to develop business rules. However, if you're dealing with programmers than the abstraction of WF isn't worth the time it takes to develop a solution, I fail to see the added value for your investment. A database is a good way to maintain rules that ...


6

Based on what you've said in comments, this is how I would handle it: Implement the story as a finite state machine, with a twist. Each State is a page of the story, and each Transition is a link from one page to another. But each Transition also has Conditions. The Conditions could be null, in which case the Transition always shows up as an available ...


5

I don't see what value throwing an Exception has in creating good business logic. There are dozens of approaches to handling business logic that do not involve using a system that is meant for addressing unexpected conditions in the operation of a system. It is expected that in business logic, conditions will not be met; that's the reason for having it in ...


5

Your latter strategy is likely the better choice. It will be difficult to find all the problems in the data while it is still resting in its current format. I would treat this an ETL process of sorts, combined with an iterative approach. Something like this: Build a beta version of the schema. Write a program to read the old data, scrub/transform it, and ...


5

Users do not like change. Even when the change is objectively superior from an UX perspective, the human resistance to change habits will result in them finding it subjectively worse. So when you already have a userbase you are developing the new application for, it is not a bad idea at all to follow the UI conventions they are used to instead of following ...


4

Well, all performance and redundancy considerations aside, unless .net database exceptions are more sophisticated than in every other language I've ever worked with, the simple fact of needing to construct an error message readable by non-programmers sort of necessitates the first method, unless you prefer error messages that read something like: Error ...


4

I think the answer is in the title: you need a rules engine. If you are planning to write your application with Java, you of course can write your own as Gilbert Le Blanc suggested, OR you might want to take a look at Drools, a rules engine. what options does a player have given the situation and his current state With Drools, or any other rules ...


4

I come across this kind of requirement all the time. Let's say you have a date range you want to check (ie, find free units for) which is defined with a start and an end date. In the database, for the sake of making it clear what we're talking about, lets say existing reservations have a first and a last date (of the reservation). So there's six possible ...


3

Given that you have already defined what a rule is, the corresponding data structure would be straightforward (pseudo-code): class Rule { Condition condition; ActionSet positiveActions, negativeActions } However, as you indicated by your reference to a ruleset, the interesting part of rule engines is the process of rule selection and their execution ...


2

expressing business rules is one thing, implementing them is another think about the user experience; if the user is not a salesperson, why give them a button that says 'create invoice' at all?


2

These guidelines/idioms are called Constrained Programming, which is not easy thing to do. It is used for modeling and solving combinatorial problems (NP-hard, NP-complete). I can recommend you one book - Principles of Constraint Programming. This book is one of the best books on the subject, but, still, after reading it you still won't be able to apply it ...


2

Conceptually, your game is straightforward. In psudeocode, it would look something like this: while not at end of adventure story display text get response Now, chaining all of the text together so it flows from one action to the next is the hard part. You could use a relational database. You could use a tree. It's a little hard to be more ...


2

Well, how will you invoke this thing? I would assume it's something like this: for (auto rule: ruleset) { if (rule.matches(context)) { if (rule.execute() == Stop) break # so rules can stop early # else: default action is to continue } } So, you have an object with with two methods bool Rule::matches(Context const& ...


2

I would suggest you try to go away using actual boolean expressions and figure out what actions or events you're doing to the "system" that you're developing. If you're using if-statements you might as well use a scripting language. Once upon a time I've created a DSL in JSON format that defined rules as actions or events instead of using boolean ...


2

This is why they used to recommend taking the Artificial Intelligence class. Back in the 1970s and 1980s, there was a HUMONGOUS amount of work done on Rule-Based Systems, mostly for Expert Systems work. That included huge amounts of work done on rules engines. A fair amount of this work found its way into undergraduate AI textbooks. Take a look at ...


2

I regularly use approach two. Downside is that tests require a database. Some will argue that depending on a database is not 'unit-testing'. Indeed. The problem with this critique is that it considers unit tests as the One Size Fits All. Clearly unit tests are not tailored to be used with foreign systems. That does not mean you should not rely on those ...


1

There aren't any download or storage limits for your app (other than available space on the device, of course); if there were, they'd be mentioned in the iOS Data Storage Guidelines. However, you do need to consider how your data files will work with iCloud -- in particular, you should decide whether it's okay for the device to discard your downloaded data ...


1

Interestingly enough, our company just went through a similar exercise. Our application was similar but different. In our case, we are processing messages, and we wanted a way to define "rules" for how to transform the message values. We considered 2 main approaches: embedding a scripting engine (Groovy, Jython, Javascript) using an existing open source ...


1

The state machine sounds like a safe approach to model your game. There are lots of libraries for interactive fictions: http://en.wikipedia.org/wiki/Category:Text_adventure_game_engines not mentioned in wikipedia, twine is very popular at the moment.


1

In the database, you won't be able to validate the password length at all (since it's hashed and not plaintext, right? RIGHT?). Testing for invalid characters in the username must be done before you write your INSERT statement, otherwise you're wide open to a SQL injection attack. Which would be much less likely if you used a parameterized query instead, ...


1

This is somewhat oblique to your question, but it sounds to me as though what you are talking about in this case is actually the creation of a Domain Specific Language- if you start researching those you will find all kinds of interesting articles. Martin Fowler provides a good starting point. DSLs are a very useful area to be conscious of and something ...


1

I built a reservation system a while ago and faced a similar problem. It was slightly different in that I had a fixed number of spots (units) to fill (they weren't indexed). My solution was similar to the answer posted by @rrufai, except that in my case that query would give me the reservations for that date range, not the availability. I created a MySQL ...


1

Lets assume that the customer wants the date range date_from to date_to, where date_from <= date_to. You told us that you have a reservation table, let's call it reservation_table. Using the column names you provided, i.e. reservation_table = unit_id, check_in, check_out, such that check_in <= check_out How about the following query in mysql? select ...


1

Since this post is tagged as "architecture" I'll weigh in from an architecture perspective. You're on the right track with respect to the kinds of requirements you are gathering. I would classify what you've shared more generally as architectural drivers. That is, some minimalist set of information that you can use to drive the architecture design. Most ...


1

Narrow it WAY done and use an Agile methodology to do it piece by piece. Given the situation you describe (basically a mess) and the system you desire (cleaned up) I would recommend you tackle this one small piece at a time. I would also remove these 'qualities' Fast developer turn-around for bug fixes. Error-free implementation of new features. ...


1

As Robert noted in a comment, I really don't think you can fully encompass all your design constraints in one place. Since you mention that you're intending to document your design constraints to assist with your design decisions, I'm assuming you are working in a waterfall-style development environment. See the Criticism section on Wikipedia regarding ...


1

To add a bit more information to the comment I left on World Engineer's answer: This is generally referred to as multi-objective optimisation. Wikipedia has a pretty good summary of the topic, I recommend you go through it. The good news is that it's a very well researched area, with plenty of ideas and algorithms available. The bad news is that it is a ...



Only top voted, non community-wiki answers of a minimum length are eligible