In reply to Romain2511:
Some suggestions:
You can use
`uvm_object_param_utils(bar) instead of `uvm_object_utils(bar). This simply removes the string-based factory registration.
Type based factory registration is more efficient and gives you earlier compilation errors for most mistakes. String comparison in SystemVerilog is cumbersome and checking can only be performed at runtime. Use instance-based string overrides only if absolutely necessary.