Luis Majano Forums Notification: Post to Best Practices X Event Handler

Title: RE: Best Practices X Event Handler
Thread: Best Practices X Event Handler
Forum: Discussions
Conference: ColdBox
User: ronanlucio


OK, now I have my ehDepartments EH that has the event doInsert.

event have some logic blocks (Validate content, check for duplicate and the
INSERT operation) which will be put in the model layer (model/Department.cfc).
What do you think about pass the Event as the argument?

Well, I know best practices says to the
values as arguments (objDepartment.Insert(name: sDepName)), but I´m think about
two main points:

1) I´ll need transfer object in the model layer to search
for duplicated names and insert the new department in the database.
As a tip
from Coldbox TransferSample I´m injecting transfer in the EventCollection.
Passing Event as argument don´t create a new dependency as
objDepartment.setTransfer() would do.

2) I´d like to keep the controller
clear in a way it can tell me the event´s logic and flow in few lines.
Imagine a big register of products that has so many fields and I would create:
var sProductCod = ARGUMENTS.Event.getValue("productcod",
var sProductName = ARGUMENTS.Event.getValue("productName", "");
sProductType = ARGUMENTS.Event.getValue("productType", "");
var sProductPrice =
ARGUMENTS.Event.getValue("productPrice", "");

It would
add so many line in the controller layer that I like to add it in the model

To finish, I know ColdSpring is a good tip, but I leaving it for
later. I think Coldbox and Transfer are enough to learn in one time.
When it´s
clear and fixed in my mind I´d like to see ColdSpring closier.