Ask HN: Keeping track of the business rules
Quick example - we only start charging for our customer campaigns once they have been active for at least 72 hours, but at the same time we stop creating invoices for campaigns that belong to insolvent accounts and close such accounts within a month of the first failed charge. That does not apply to accounts that are set to "non-chargeable" which most commonly belongs to us since we are using the service ourselves. The invoices are created on the 1st of each month and include charges from the previous month + any current balance that the account might have. However, some customers are charged only 4 days after their invoice has been generated due to issues with their billing department. In addition to that, invoices are also created when customer deactivates his campaign, but that can only be done once the campaign is not longer under mandatory 6 month contract, unless account manager approves early deactivation.
I know, that's quite a lot of rules that need to be taken into account when answering a question "when do we bill our customers", but actually I could still append an asterisk at the end of each sentence in order to disclose some rare exceptions. Of course, it would be easiest just to keep the business rules to the minimum, but we need to adapt to changing marketplace - i.e. less than a year ago we had no contracts whatsoever.
One idea that I had so far was a simplistic wiki with categories corresponding to areas such as "Account activation", "Invoicing", "Collection procedures" and so on. Another idea would be to have giant interactive flowchart showing the entire customer "life cycle" from prospecting to account deactivation.
What are your experiences / suggestions?
5 comments
[ 3.1 ms ] story [ 24.4 ms ] threadEvery business of a certain age has more business rules than any one person can keep in their head at one time. These rules manifest themselves in your code. They are the business rules. Everyone has their own opinion on what the rules are, but the developers know the answers are in the code, not in our foggy memory.
Now that we know what business rules are and where we keep them, we need to think about how we organize them. Instead of a business problem, we have a technical problem. Organizing 'business rules' becomes organizing software. This is a well-worn field, so you'll find lots of good advice on domain-driven design and the organization of software (object-oriented or otherwise).
A related software principal here is 'tell, don't ask' (http://pragprog.com/articles/tell-dont-ask). This is especially important in environments with lots of conditional rules, which must be considered at various times.
I've built several eCommerce back-ends, for example, and they each had a ton of very specific rules that were unique to the businesses, the products they sold, and the type of customers the services targeted. If you want to know precisely how the site validated address and credit card information, you'd really need to check the code. However, you could certainly say (and market) that you provide security measures to prevent fraud.
The snag to avoid is attempting to document the specifics of the rules anywhere but the code itself.
I.e. right now the only way a new developer can find out that we create invoices upon campaign deactivation would be by doing search in project files for instances where invoicing module is called. Is it possible to have some auto documenting system which could list all files w/ line numbers where specific function is called?
This assumes, of course, that the application is well designed, continually refactored and well tested. Every app has skeletons in the closet, though, and this perfect world often leaves something to be desired.
If your code is relatively clean though, you'll have one and only one place where you instruct an account to be invoiced, and you can trace through that code anytime you have questions about how that scenario works.
Suggestion: Every time you go diving into the code to investigate some scenario and wish to discover the business rules, start by writing a test for it. Write tests that expect that behavior, then execute the scenario and ensure your tests pass. Better yet, write those test first and you're all the way there. :)