New() versus Create()

Hi,

I searched the forum for the answer but could not find one. Hence the basic question.

Could you pls let me know the difference between new() and create() functions?
And also what are the context or situation we use new() and create() ?

Thanks
/Sachin

Hi,

it is actually pretty simple “create” registers your instance inside
of the “Factroy” which “new” doesn’t.
For all uvm based classes you should use “create” over “new” otherwise
you will get in trouble if anyone tries to use the “Factory” to get
hold of your instance or override it inside of the TC.

Bye,

Christoph

In reply to frodus:

Is this also true:
Create will honor any type overrides and new will not?

Thanks
Steve.

New() hardcords the type, but create returns the constructed instance from the factory.
Hence using create, we will have flexibility for instance override

In reply to stevenag:

Yes this is correct.