Monday, January 18, 2010

Giving Aid to Haiti

OK, OK, I know that only believers are supposed to be charitable, and I've tried to resist the temptation to give in to my humanity. As much as I have struggled to resist the temptation, I could no longer resist. I have donated to the international Red Cross and Doctors without borders.

Won't you take a minute to help the Red Cross or Doctors without borders too?

Follow the link on this page, or choose a different route. There are so many ways to get your money there.

Cheers!

in reference to: Skeptic » eSkeptic » Sunday, January 17th, 2010 (view on Google Sidewiki)

Wednesday, January 13, 2010

Groovy business rules

I love this way to make the DSL presented here. I just wish I could find more ways to put it into a sandbox, besides the heavy hand of the java security sand box.

in reference to: Practical Groovy DSL (view on Google Sidewiki)

Great post on showing code in blogger

Thanks Vivian for showing me how to post code on blogspot. As a burgeoning code blogger, this really helps out!

in reference to: Vivian's Tech Blog: How to post source code in blogspot.com (view on Google Sidewiki)

Creating a Groovy DSL for Financial Product Fee Schedules


I'm currently working on a project that requires a variable fee schedule.
E.g.

Product Name Category Feature Value Date Range Functional Setting Applicability
General ACH Generation






ACH Generation Fees ACH Transaction Fee 1.00 Account Open Date Account Closed Date 0 to 10 transactions


ACH Transaction Fee .50 Account Open Date Account Closed Date 10 or more transactions

Credit Card Generation Fees CC Transaction Fee 1.00 Account Open Date Account Closed Date 0 to 10 transactions


CC Transaction Fee .50 Account Open Date Account Closed Date 10 or more transactions

I need a way to specify the date range that would include things such as account open date and plus 3 months and transaction ranges. Groovy DSL seems like the perfect fit. See Guillame Laforge's example here.

I came up with the following:

package com.aps.utils

import com.aps.util.DateUtil
import org.codehaus.groovy.runtime.TimeCategory


class ProductCatalogDSLTests extends GroovyTestCase {


def account

void setUp() {
account = new Account(from: DateUtil.sdf.parse("01-01-2010"))
}

void testAccountOpenedDate() {
def rule = 'transactionDate > account.from'
def binding = new Binding()
binding.account = account
def shell = new GroovyShell(binding)
def date = DateUtil.sdf.parse('01-10-2010')
binding.transactionDate = date
assert shell.evaluate(rule)
binding.transactionDate = DateUtil.sdf.parse('05-10-2009')
assertFalse shell.evaluate(rule)

}

void testAccountOpenedDate_plus3() {
def rule = 'transactionDate < account.from+6.months'
def binding = new Binding()
binding.account = account
def shell = new GroovyShell(binding)
def date = DateUtil.sdf.parse('01-10-2010')
binding.transactionDate = date
use(TimeCategory) {
assert shell.evaluate(rule)
binding.transactionDate = DateUtil.sdf.parse('05-10-2010')
assert shell.evaluate(rule)
}
}

void testTransactionMinimum() {
def rule1 = 'account.transactions.size < 10'
def rule2 = 'account.transactions.size >= 10'
def date = DateUtil.sdf.parse('01-10-2010')
0..5.each {
account.transactions << new AccountTransaction(amount: 15.00, postDate: date)
}
def binding = new Binding()
binding.account = account
def shell = new GroovyShell(binding)
binding.transactionDate = date
use(TimeCategory) {
assert shell.evaluate(rule1)
assertFalse shell.evaluate(rule2)
}
}

void testTransactionMinimumThisMonth() {
def rule1 = 'account.transactions.collect{it.postDate.month == transactionDate.month}.size < 10'
def rule2 = 'account.transactions.collect{it.postDate.month == transactionDate.month}.size >= 10'
def date = DateUtil.sdf.parse('01-10-2010')
use(TimeCategory) {
assertEquals 0 , date.month
assertEquals 10 , date.date
assertEquals 2010 - 1900 , date.year
0..5.each {
account.transactions << new AccountTransaction(amount: 15.00, postDate: date)
}
def binding = new Binding()
binding.account = account
def shell = new GroovyShell(binding)
binding.transactionDate = date
assert shell.evaluate(rule1)
assertFalse shell.evaluate(rule2)
}
}
}
class Account {
Date from
Date to
def transactions = []
}
class AccountTransaction {
BigDecimal amount
Date postDate
}

It ended up working well for dynamic business rule selectors.

Monday, January 4, 2010

A reason for Death

My friend Mike studies Evolution, Biology and Bioinformatics at UVU. He and I often engage in wonderful thought provoking discussions on life, and our part in it.

I appreciate Mike's thoughts here on the evolution of death. Death was developed through evolution. It reminds me of the gentlemen from Canada who continuously talks about developing gene therapy to continuously delay death. But none of that will happen while researchers continue on the assumption of death as a requirement of part of life.

in reference to: Evolution and Bioinformatics: Life Ascending and the evolution of death (view on Google Sidewiki)