String name in constructors

Hi,

WHy do we need to mention some string name while constructing an object? When it comes to the construction of components, its not mandatory to give string name.

//COnstruction of components
function new (string name, uvm_component parent);
super.new(name, parent);
endfunction

//Construction of objects
function new (string name="class_name");
super.new(name);
endfunction

Someone please make me understand this?

In reply to janudeep3:

It is not that way.

Here in object constructor, You have provided “class_name” as a default argument for field called ‘name’ which has type ‘string’. So now, if you are not mentioning any string value during the object creation, then it will take “class_name” as a object name by default.

UVM is not restricting to create ‘component’ without default string name and ‘object’ with string name.

In reply to janudeep3:

Clifford Cummings talks about this a little in his factory paper. last 2 paragraphs of section 2 “factory”.

In reply to bmorris:

it has been said that , components need not mention class name in the argument , as parent builds the child components and the name is overridden by it .

So ,where does the parent is given child component names to be overridden ??
Explain quoting with an example

In reply to rajivdesh:

Every single UVM example that creates hierarchy shows this in the build_phase of the parent component. Testbench/Build | Verification Academy