How do you keep track of the business rules in your application code?
Lets say we are designing an order entry system. One of the business rules might be:
If the stock level of an item drops below its reorder point, create a purchase order for that item to bring its stock level back up to the minimum.
So, in our code, we might have a method somewhere that checks for this:
function check_stock_level() {
if (this.stock_level < this.reorder_level) {
po = new PurchaseOrder();
po.add_item(this.item_type, this.minimum_level - this.stock_level);
}
}
So how would you mark up your code (with comments maybe?) or document your code with a third party system to cross reference your business rule to the code that makes it work? Especially, how would you do this with code that might not be contained in one simple method (like the above example) but might stretch across multiple methods or multiple files even?
Are there any tools out there to manage this?
I remember reading somewhere about how NASA programmers must fill out a form for every change they make to the code base to describe what they did and why - I imagine this type of system would make development slow down considerably but then when you need to fix a bug it must be much easier to go back and find out where to start looking.