Algernon Tutorial 4.c
System Design


previous   index

System Design

One class that worked on this problem produced the following design document:
  1. Ontology Changes
    1. Make a subclass of Person called Customer.
    2. Add slot address from Customer to String. Use slot phone_number on Customer.
    3. Create a slot advertisements from Customer to Advertisement.
    4. Create a cost slot from Advertisement to Float. Calculate its value based on the number of words in the ad.
    5. Make a new subclass of Transaction called Payment.
    6. Create a slot payments from Customer to Payment.
    7. Create new transaction slots: amount, Date.
    8. Create a Balance slot from Customer to Number.
    9. Create a rate_per_word slot from Advertisement to Float.
  2. Later, we realized we also needed:
    1. A content_size slot from Content to Integer.
    2. Instead of an advertisements slot on Customer, use the purchaserOf slot that is the inverse of purchaser. This was renamed from inverse_of_purchaser.
    3. Add a payer slot from Payment to Customer, with inverse slot payments.
    4. Create a Reports class that contains generated reports.
  3. Rules
    1. FC: calculate cost of ad when the content of the ad changes. Get rate per word from the rate_per_word slot on Advertisement.
    2. FC: Validation: payment must be > 0.00.
    3. BC: Produce a report of all customers with a balance > 0.00.
    4. FC: Calculate cost of the ad, add it to customer's balance.
    5. FC: When a new payment is received, subtract from customer's balance.
  4. Testing
    1. Create a new customer. ((:ADD-INSTANCE (?x Customer) (:NAME ?x TestCustomer)))
    2. Assert the content_size of the Personals Ad "Silly". Assert a purchaser for it too. ((content_size instance_00091 75) (purchaser instance_00091 TestCustomer))
    3. Or create a new ad and assert its rate_per_word and content_size. This should fire Rule 1, which should fire Rule 3.
    4. Then you can get the list of customers with balances, using ask: ((BalanceReport Reports ?report))
    5. Then, assert a payment for the purchaser of the ad, and check the balance again.

Notes


previous   index
Author: Micheal Hewett
Email: mhewett@users.sf.net
Last Updated: Monday, June 06, 2005