Business Rules

No, we don t mean business is the tops. It s a fact of life that we all have rules we must follow, and a business is no different. As you might guess, a business rule defines a rule a business must follow. For example, a business rule of our registration system might be that students can only enroll in a new course if they have paid for all their previous courses in full.

Any actor or SME of the system can define business rules. Going back to the actor may be a government agency example, a government agency might define certain rules under which a student is eligible for financial aid, and your system must implement those rules for each student.

Business rules are implemented in a method of a class. Let s go back to the student must be paid in full business rule for our registration example.

 class Student { 
bool PaidInFull() {
/* Search database to determine if paid in full */
bool Enroll( const Course& aCourse ) {
if( PaidInFull() == false )
return( false );
/* Proceed with enrollment */

Note how the preceding class enforces the business rule about being fully paid. Because the business rule is placed in the Enroll method, it is now impossible to enroll students who aren t completely paid in full. Of course, there might always be waivers or special cases, so don t be surprised to find out there are exceptions to the rules. Hopefully though, if your actor interviews are done well, you can avoid these surprises .

We also decided to make the PaidInFull method a public method instead of a protected method (which would only be usable from within the Student class or one of its derivatives). We might decide that other portions of the system need to know whether the student is paid in full, without actually trying to do an enrollment to find out.

We might also create classes that are, in essence, nothing but business rules. There are times when COM and CORBA technologies work well with this, because these technologies are more plug and play adaptable than typical classes. In other words, if we have some sort of scheduling business rule class, and we identify that those business rules have changed, we can modify the one business rule class, which then can be used by a number of different programming languages or systems immediately.

COM stands for Component Object Model, and CORBA stand for Common Object Request and Brokering Architecture. Both provide a similar goal: to create a class that can be instantiated by different programming languages. For example, a COM class can be instantiated as an object by C++, Visual Basic, Java, and a number of other programming languages. COM is a Windows-based technology, whereas CORBA is found more on the Unix platform.

Business rules are documented in a numbered fashion, such as BR1: Students must be paid in full before registration for any new classes will be accepted. These business rules are the outcome of your actor interviews and meetings, and often the SMEs provide the most detailed and accurate business rules.

OOP Demystified
OOP Demystified
ISBN: 0072253630
EAN: 2147483647
Year: 2006
Pages: 130

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: