Callbacks Vs Factory

Callbacks and factory both addresses different areas of reusability in UVM.

Callback: 

  • Add functionality to existing logic.
  • Suitable for rare or minimal feature need to be enhanced in focus
  • Popular for error injection/to corrupt the sequence from VIP.
  • Easy to maintain callbacks

Factory: 

  • It used to substitute the existing component before build, keeps environment same.
  • Suitable for so many features need to be enhanced in focus.
  • Multiple copies are required
  • Not suitable for VIP components

As the callback and factory can be interchangeably used to address the same problem. Depending on the requirement, a wise decision should be made on which feature the user should use.