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

Hi,

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

This
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?
Example:
objDepartment.Insert(ARGUMENTS.Event)

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:
[code]
<cfscript>
var sProductCod = ARGUMENTS.Event.getValue("productcod",
"");
var sProductName = ARGUMENTS.Event.getValue("productName", "");
var
sProductType = ARGUMENTS.Event.getValue("productType", "");
var sProductPrice =
ARGUMENTS.Event.getValue("productPrice", "");
</cfscript>
[/code]

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

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.

Thanks,
Ronan

http://www.luismajano.com/forums/index.cfm?event=ehMessages.dspMessages&threadid=7CB3B46B-123F-6116-42DCE73F53617C59