Hi,
To answer your question, CoC is better.
But please note, there are three types:
CoC (you can use it on tables, forms, form datasources, form datasource field, form control, classes)
It lets you add logic before or after a method runs (the method doesn't have to be related to a table event like insert, it could be any method)
so it gets called before/after any logic of the method we are extending
So if the original method was like the code below, then when you use CoC, your code will be either called before the "Hi" or after the "bye" depends if you put the code before next or after it
public void insert()
{
Info("Hi");
super();
Info("Bye");
}
Pre/post event handler methods (you can find them on table/form methods, classes)
Exactly same as CoC, It lets you add logic before or after a method runs (the method doesn't have to be related to a table event like insert, it could be any method)
so it gets called before/after any logic of the method we are extending
So again. it's just like CoC but CoC is better for the reasons Martin mentioned in the first reply (for me i like CoC because it's easier, no hardcoding and i feel it's more organized)
And maybe another reason that i noticed, is that CoC can be written for form datasources, form datasource fields and form controls, but i couldn't see pre/post for sth other than tables/forms/classes (i mean if u right click on form data source method, you won't see pre/post)
The third one is different:
Event handlers ( you can find them on tables, forms, form datasources, form datasource fields, formControls and classes)
Example: OnInserted/OnInserting, they occur automatically whenever a record is inserted
Those event handlers are related to database changes, so it doesn't work on any method like CoC or pre/post event handlers.
The event handler will be called by the super() itself and not before/after the method runs
There could be cases where you might want to use those event handlers instead of CoC as they have benefits too. For me if the logic would work using both with no differences, then i would go with CoC always (i think this not the scope for your question so i won't go further)
So if the original method was like below, when you use table event handles, your code will be called inside the super (OnInserting/OnInserted) and not before Hi/bye as CoC or pre/post methods
public void insert()
{
Info("Hi");
super();
Info("Bye");
}
Thanks,
Layan Jweihan
Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future.